1 Reply Latest reply on Nov 12, 2008 5:40 AM by Thorsten Moeller

    NullPointerException on combined EJB3 session bean and JAX-W

    Thorsten Moeller Newbie

      Hello,

      I'm implementing a class that is both a EJB3 stateless session bean and also exposes itself as a JAX-WS Web service. Below you can see relevant excerpt from the code.

      When I want to access the WSDL document from a Web browser I get an NPE, see below. When I remove the EJBContext variable declaration including the @Resource annotiation the exception does not appear.

      I'm using JBoss 4.2.3GA and jbossws-cxf-3.0.4.GA.

      It seems to me that it is related to CXF but appears only for classes that are both EJBs and JAX-WS Web services. Am I right or did I missed something? Should I try with jbossws-native or jbossws-metro again or would they fail as well?

      Regards,
      Thorsten



      
      // ...
      
      @Local(BankServiceLocal.class)
      @Remote(BankServiceRemote.class)
      @Stateless
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
      @WebService(name="BankService", targetNamespace="http://myCompany.com")
      public class BankServiceImpl implements BankService
      {
       @PersistenceContext
       protected EntityManager em;
      
       @Resource
       protected EJBContext context;
      
       @WebResult(name = "customer")
       public Customer getCustomerDetails(
       @WebParam(name = "bic") String bic,
       @WebParam(name = "iban") String iban) throws UnknownAccountException
       {
       // ...
       }
      
      // ...
      
      }
      



      14:35:43,937 INFO [ServerImpl] Setting the server's publish address to be http://127.0.0.1:8080/dis.ws/BankServiceImpl
      14:35:43,968 ERROR [AnnotationProcessor] an AnnotationVisitor (org.apache.cxf.common.injection.ResourceInjector@151e077) raised an exception on element protected javax.ejb.EJBContext ch.unibas.cs.dbis.dis.jaxws.BankServiceImpl.context.
      java.lang.NullPointerException
       at javax.naming.InitialContext.getURLScheme(InitialContext.java:269)
       at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:318)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at org.apache.cxf.transport.servlet.ServletContextResourceResolver.resolve(ServletContextResourceResolver.java:62)
       at org.apache.cxf.resource.DefaultResourceManager.findResource(DefaultResourceManager.java:99)
       at org.apache.cxf.resource.DefaultResourceManager.resolveResource(DefaultResourceManager.java:55)
       at org.apache.cxf.common.injection.ResourceInjector.resolveResource(ResourceInjector.java:401)
       at org.apache.cxf.common.injection.ResourceInjector.visitField(ResourceInjector.java:164)
       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.apache.cxf.common.annotation.AnnotationProcessor.visitAnnotatedElement(AnnotationProcessor.java:131)
       at org.apache.cxf.common.annotation.AnnotationProcessor.processFields(AnnotationProcessor.java:110)
       at org.apache.cxf.common.annotation.AnnotationProcessor.accept(AnnotationProcessor.java:89)
       at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector.java:81)
       at org.apache.cxf.common.injection.ResourceInjector.inject(ResourceInjector.java:76)
       at org.apache.cxf.jaxws.JaxWsServerFactoryBean.injectResources(JaxWsServerFactoryBean.java:217)
       at org.apache.cxf.jaxws.JaxWsServerFactoryBean.init(JaxWsServerFactoryBean.java:168)
       at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:161)
       at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:322)
       at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:244)
       at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:194)
       at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:380)
       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.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1242)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1208)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
       at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:427)
       at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
       at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
       at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
       at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
       at org.jboss.wsf.stack.cxf.CXFServletExt.loadAdditionalConfigExt(CXFServletExt.java:141)
       at org.jboss.wsf.stack.cxf.CXFServletExt.loadBus(CXFServletExt.java:118)
       at org.apache.cxf.transport.servlet.AbstractCXFServlet.init(AbstractCXFServlet.java:86)
       at org.jboss.wsf.stack.cxf.CXFServletExt.init(CXFServletExt.java:73)
       at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
       at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:806)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
       at java.lang.Thread.run(Thread.java:619)