Announcement Announcement Module
Collapse
No announcement yet.
Spring injecting EJB3 SLSB results in NPE Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring injecting EJB3 SLSB results in NPE

    Hello,

    I've deployed a simple slsb under JBoss 5.1.0 and want to access it with a minimalistic client (proof of concept).

    When doing the JNDI lookup without spring everything works fine.
    When using Spring 2.5 and the jee:jndi-lookup tag, then I get a NullPointerException:
    Code:
    Exception in thread "main" java.lang.NullPointerException
    	at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:379)
    	at org.jboss.ejb3.session.InvokableContextClassProxyHack._dynamicInvoke(InvokableContextClassProxyHack.java:53)
    	at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:91)
    	at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:82)
    	at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:891)
    	at org.jboss.remoting.transport.socket.ServerThread.completeInvocation(ServerThread.java:744)
    	at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:697)
    	at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:524)
    	at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:232)
    	at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
    	at org.jboss.remoting.Client.invoke(Client.java:1634)
    	at org.jboss.remoting.Client.invoke(Client.java:548)
    	at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:62)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:67)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
    	at $Proxy4.invoke(Unknown Source)
    	at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
    	at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
    	at $Proxy2.test(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    	at $Proxy3.test(Unknown Source)
    	at MainClass.testEjb(MainClass.java:24)
    	at Client.main(Client.java:9)
    	at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:74)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.tx.ClientTxPropagationInterceptor.invoke(ClientTxPropagationInterceptor.java:67)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.security.client.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:65)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:74)
    	at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
    	at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
    	at $Proxy4.invoke(Unknown Source)
    	at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:207)
    	at org.jboss.ejb3.proxy.impl.handler.session.SessionProxyInvocationHandlerBase.invoke(SessionProxyInvocationHandlerBase.java:164)
    	at $Proxy2.test(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    	at $Proxy3.test(Unknown Source)
    	at MainClass.testEjb(MainClass.java:24)
    	at Client.main(Client.java:9)
    applicationContext.xml:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:jee="http://www.springframework.org/schema/jee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/jee
               http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
    	<jee:jndi-lookup id="wsTransactionTest"
    		jndi-name="WSTransactionEAR/WSTransactionTest/remote" proxy-interface="com.inet_logistics.ejb.WSTransactionTestRemote"
    		expected-type="com.inet_logistics.ejb.WSTransactionTestRemote" />
    
    	<bean id="mainClass" class="MainClass">
    		<property name="ttr" ref="wsTransactionTest" />
    	</bean>
    </beans>
    MainClass.java:
    Code:
    import ejb.WSTransactionTestRemote;
    
    public class MainClass {
    	private WSTransactionTestRemote _oTtr;
    
    	public void setTtr(WSTransactionTestRemote oTtr) {
    		_oTtr = oTtr;
    	}
    
    	public void testEjb() {
    		_oTtr.test("Hallo Welt!");
    		System.out.println("Fertig!");
    	}
    }
    WSTransactionTest.java:
    Code:
    package ejb;
    
    import java.util.Properties;
    
    import javax.ejb.Stateless;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionAttributeType;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    
    import entity.TestEntity;
    
    /**
     * Session Bean implementation class WSTransactionTest
     */
    @Stateless
    public class WSTransactionTest implements WSTransactionTestRemote {
    	@PersistenceContext(unitName = "WSTransactionEJB")
    	private EntityManager em;
    	private TestEntity _oTe;
    
    	@TransactionAttribute(TransactionAttributeType.REQUIRED)
    	public String test(String testString) {
    		System.out.println("Starting test method.");
    		_oTe = new TestEntity();
    		_oTe.setText(testString);
    		em.persist(_oTe);
    		return testString;
    	}
    }
    WSTransactionTestRemote.java:
    Code:
    package ejb;
    
    import javax.ejb.Remote;
    
    @Remote
    public interface WSTransactionTestRemote {
    	public String test(String testString);
    }
    What am I doing wrong?

    With kind regards

    freiser

  • #2
    I've found it!
    I've used the JBoss-4.2.3.GA libs

    Comment

    Working...
    X