Hi,
I have problems using the Spring EJB access class to access a local EJB from a servlet.
My application server is JBoss4RC1.
I get the following Exception:
=============================
18:12:21,538 ERROR [Engine] StandardWrapperValve[HelloWorld]: Servlet.service()
for servlet HelloWorld threw exception
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.springframework.ejb.access.LocalSlsbInvokerInt erceptor.invoke(LocalSlsbInvokerInterceptor.java:6 0)
at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :138)
at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:152)
at $Proxy69.sayHello(Unknown Source)
at HelloWorld.doGet(HelloWorld.java:48)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:697)
My EJB consists of the following classes:
========================================
-local interface LocalHello.java
-bean LocalHelloBean.java
-home interface LocalHelloHome.java
In addition I have defined a business interface Local.java, my bean class implements
this interface.
My applicationContext.xml:
==========================
<beans>
<bean id="local" class="org.springframework.ejb.access.LocalStatele ssSessionProxyFactoryBean">
<property name="jndiName"><value>MeinEJB</value></property>
<property name="businessInterface"><value>test.Local</value></property>
</bean>
<bean id="myBD" class = "HelloWorld">
<property name="local"><ref bean="local"/></property>
</bean>
</beans>
My servlet:
===========
public class HelloWorld extends HttpServlet {
private static Local local=null;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// working version without Springs EJB Access classes
try {
InitialContext jndiContext= new InitialContext();
Object ref = jndiContext.lookup("MeinEJB");
LocalHelloHome home = (LocalHelloHome)PortableRemoteObject.narrow(ref,Lo calHelloHome.class);
LocalHello myLocal = home.create();
System.out.println(myLocal.sayHello("Test1234"));
} catch (Exception e) {
e.printStackTrace();
}
// version with Springs EJB access classes throws an exception
System.out.println(local.sayHello("Test789"));
}
public void init(){
ServletContext ctx=this.getServletContext();
ApplicationContext app=WebApplicationContextUtils.getWebApplicationCo ntext(ctx);
}
public void setLocal(Local hello){
this.local=hello;
}
}
I checked that init, setLocal were invoked. The version without Spring works fine, but
the line System.out.println(local.sayHello("Test789")); throws the exception.
Can you please tell me what's wrong?
Thanks and best regards
Nicole Wengatz


Reply With Quote
