1 Reply Latest reply on Feb 19, 2009 7:45 AM by andrea formica

    Access Session Bean from a Servlet in external WAR

    andrea formica Newbie

      Dear experts, I have an EAR containing some jar files (one with interfaces and POJOs, one with Session Beans, ...), which is correctly deployed and
      working in JBoss 5, and I'm trying to access some of the Session Beans methods from a separate WAR , which contains GWT based application.

      I did a test using the WAR deployed in hosted mode (with the tomcat delivered by GWT) , and I managed (putting the needed jar with the
      interfaces + the jboss client jars in the CLASSPATH) to access the session beans from the REMOTE interface.

      Now I'm trying to test the same but deploying the war inside JBoss 5, and I'm having lots of problems related to (I think) classloading issues.

      I read several posts on the forum, but I did not manage to succeed, while a similar application was working in Jboss 4.2.2.

      Just to summarize what I have in the WAR :
      there is a WEB-INF/lib containing only gwt-servlet.jar
      there is a WEB-INF/web.xml containing servlet definitions
      there is a WEB-INF/classes containing all the code
      there is the stuff generated by GWT...
      I also have a jndi.properties at the root level of the WAR, containing some
      parameters for jndi :

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://dapmcf121:1099
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      client.method=local
      web.host.url=http://dapmcf121:8080
      

      and here is where I try to retrieve the interface :
      if (clientmethod.equals("local")) {
       log.info("Getting local stub using jndi");
       InitialContext ctx = new InitialContext();
       tagDAO = (AligntagBD) ctx.lookup(SERVER_NAME
       + "/AligntagBDBean/local");
      }
      

      (in case it helps...)

      I did try to set in file deployers/jbossweb.deployer/META-INF/war-deployers-jboss-beans.xml the parameter useJBossWebLoader=true
      but nothing changed in the error message which is the following:


      
      11:05:45,757 ERROR [STDERR] java.lang.Exception: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@2db555]
      11:05:45,758 ERROR [STDERR] at align.gwt.monitor.server.impl.AlignMonitoringSvcImpl.initTagDAO(AlignMonitoringSvcImpl.java:137)
      11:05:45,758 ERROR [STDERR] at align.gwt.monitor.server.impl.AlignMonitoringSvcImpl.getTags(AlignMonitoringSvcImpl.java:203)
      11:05:45,758 ERROR [STDERR] at align.gwt.monitor.server.impl.AlignMonitoringSvcImpl.getTags(AlignMonitoringSvcImpl.java:326)
      11:05:45,758 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:05:45,758 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:05:45,758 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:05:45,758 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
      11:05:45,758 ERROR [STDERR] at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
      11:05:45,758 ERROR [STDERR] at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
      11:05:45,758 ERROR [STDERR] at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
      11:05:45,758 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      11:05:45,758 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      11:05:45,758 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      11:05:45,758 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      11:05:45,758 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      11:05:45,758 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      11:05:45,758 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      11:05:45,758 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
      11:05:45,759 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      11:05:45,759 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
      11:05:45,759 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
      11:05:45,759 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
      11:05:45,759 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
      11:05:45,759 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      11:05:45,759 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      11:05:45,759 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
      11:05:45,759 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      11:05:45,759 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
      11:05:45,759 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
      11:05:45,759 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
      11:05:45,759 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      11:05:45,759 ERROR [STDERR] at java.lang.Thread.run(Thread.java:613)
      11:05:45,759 ERROR [STDERR] Caused by: javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@2db555]
      11:05:45,759 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1463)
      11:05:45,759 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:809)
      11:05:45,759 ERROR [STDERR] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:673)
      11:05:45,759 ERROR [STDERR] at javax.naming.InitialContext.lookup(InitialContext.java:351)
      11:05:45,760 ERROR [STDERR] at align.gwt.monitor.server.impl.AlignMonitoringSvcImpl.initTagDAO(AlignMonitoringSvcImpl.java:125)
      11:05:45,760 ERROR [STDERR] ... 31 more
      11:05:45,760 ERROR [STDERR] Caused by: java.lang.RuntimeException: Can not find interface declared by Proxy in our CL + org.jboss.web.tomcat.service.WebCtxLoader$ENCLoader@2db555
      11:05:45,760 ERROR [STDERR] at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:341)
      11:05:45,760 ERROR [STDERR] at org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory.createProxy(SessionProxyObjectFactory.java:134)
      11:05:45,760 ERROR [STDERR] at org.jboss.ejb3.proxy.objectfactory.session.stateless.StatelessSessionProxyObjectFactory.getProxy(StatelessSessionProxyObjectFactory.java:79)
      11:05:45,761 ERROR [STDERR] at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:156)
      11:05:45,761 ERROR [STDERR] at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
      11:05:45,761 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1438)
      11:05:45,761 ERROR [STDERR] at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1455)
      11:05:45,761 ERROR [STDERR] ... 35 more
      11:05:45,761 ERROR [STDERR] Caused by: java.lang.ClassNotFoundException: asap.server.io.dao.AligntagBDLocal
      11:05:45,761 ERROR [STDERR] at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
      11:05:45,761 ERROR [STDERR] at java.security.AccessController.doPrivileged(Native Method)
      11:05:45,761 ERROR [STDERR] at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
      11:05:45,761 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
      11:05:45,761 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
      11:05:45,761 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:374)
      11:05:45,761 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
      11:05:45,761 ERROR [STDERR] at java.lang.Class.forName(Class.java:242)
      11:05:45,761 ERROR [STDERR] at org.jboss.ejb3.proxy.objectfactory.ProxyObjectFactory.redefineProxyInTcl(ProxyObjectFactory.java:337)
      11:05:45,761 ERROR [STDERR] ... 41 more
      11:05:45,762 ERROR [[/AlignGWTConsole]] Exception while dispatching incoming RPC call
      com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.extjs.gxt.ui.client.data.PagingLoadResult align.gwt.monitor.client.services.AlignMonitoringSvc.getTags(java.lang.String,com.extjs.gxt.ui.client.data.PagingLoadConfig)' threw an unexpected exception: java.lang.NullPointerException
       at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:360)
       at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:546)
       at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:164)
       at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:86)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
       at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
       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:158)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:613)
      Caused by: java.lang.NullPointerException
       at align.gwt.monitor.server.impl.AlignMonitoringSvcImpl.getTags(AlignMonitoringSvcImpl.java:354)
       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:585)
       at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:527)
       ... 24 more
      
      
      



      Please tell me if you have any hints to debug this, I'm not an expert in classloading and I'm a little bit lost...
      Andrea

        • 1. Re: Access Session Bean from a Servlet in external WAR
          andrea formica Newbie

          I think I can answer to my own post:
          in the EAR I had a META-INF/jboss-app.xml containing this:

          <jboss-app>
           <loader-repository>
           AlignServer:archive=AlignServer.ear
           </loader-repository>
          </jboss-app>
          
          


          and adding a jboss-web.xml to the WEB-INF/ of the WAR


          <jboss-web>
           <class-loading>
           <loader-repository>
           AlignServer:archive=AlignServer.ear
           </loader-repository>
           </class-loading>
          </jboss-web>
          


          it worked !!

          The only problem is that I do not really understand what I'm doing here ;-)

          I think that having a loader-repository defined in the EAR I'm activating a sort of isolation, and if I do not tell the war to use the same repository
          then I get the error...

          Andrea