2 Replies Latest reply on Feb 12, 2007 9:00 AM by skymic

    EJB lookup on standalone tomcat to remote jboss

    skymic

      hi,

      I have a WS endpoint deployed on a standalone tomcat V5.5.9 server.
      The ws endpoint was generated from a wsdl file using jaxws (jwsdp2.0).

      In this ws endpoint I try to lookup a session bean (EJB3.0) which is deployed on a remote JBoss V4.0.5 (on a different machine).

      In my tomcat war I have all jaxws libraries which are needed for the ws endpoint plus jbossall_client.jar which is needed for the EJB lookup.
      The libraires deployed are the following:
      from jaxws:
      activation.jar,jaxb-api.jar,jaxb-impl.jar,jaxb1-impl.jar,jaxws-api.jar,jaxws-rt.jar,jsr173_api.jar,jsr181-api.jar,jsr250-api.jar,resolver.jar,saaj-api.jar,saaj-impl.jar,sjsxp.jar
      from Jboss:
      jbossall-client.jar

      When trying to do the lookup I get the following exception:
      tomcat log:

      java.lang.NoSuchMethodError: javax.xml.soap.MessageFactory.newInstance(Ljava/lang/String;)Ljavax/xml/soap/MessageFactory

      and

      SAAJ0537: Invalid Content-Type. Could be an error message instead of a SOAP message
      Couldn't create SOAP message due to exception: com.sun.xml.messaging.saaj.SOAPExceptionImpl: Invalid Content-Type:text/html. Is this an error message instead of a SOAP response?

      I think there is a collision with the javax.xml.soap.MessageFactory classes in the jaxws libs and jbossall-client.jar.

      Are there any other jboss client libs which I can use in order to perform the EJB lookup?

      Any help?

      Thanks

      skymic



        • 1. Re: EJB lookup on standalone tomcat to remote jboss
          raist_majere

          Are you connecting to the remote session bean through a WebService?
          But apart from that thing, the problem you have is that you're calling javax.xml.soap.MessageFactory.newInstance() passing a String value, and that method doesn't let you put any params...

          • 2. Re: EJB lookup on standalone tomcat to remote jboss
            skymic

            Yes, I am trying to connect to a remote session bean through a web service endpoint.
            But I am not calling the javax.xml.soap.MessageFactory explicitly. This is done in the code which was generated from jaxws2.0 (wsdl to java).

            However I am a bit further now. I threw out the jbossall-client.jar and replaced it with jnp-client.jar and jboss-common-client.jar. Now the webservice can lookup the remote EJB but fails in the final PortableObject.narrow call.

            Here's my lookup code:
            String urlName = "jnp://localhost:1099";
            Properties p = new Properties();
            p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
            p.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
            p.put(Context.PROVIDER_URL, urlName);
            p.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");

            InitialContext ic = new InitialContext(p);

            Object ref = ic.lookup("SDOCI/remote/SDOCIBusinessService");

            SDOCIBusinessService busiService = (SDOCIBusinessService) PortableRemoteObject.narrow(ref, SDOCIBusinessService.class);

            Here is the exception:
            java.lang.ClassCastException
            at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229)
            at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
            at ch.skyguide.aim.interfaces.ws.server.SDOCustomerInterfacesImpl.login(SDOCustomerInterfacesImpl.java:77)
            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.sun.xml.ws.server.PeptTie._invoke(PeptTie.java:58)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.invokeEndpoint(SOAPMessageDispatcher.java:254)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher$SoapInvoker.invoke(SOAPMessageDispatcher.java:547)
            at com.sun.xml.ws.protocol.soap.server.SOAPMessageDispatcher.receive(SOAPMessageDispatcher.java:140)
            at com.sun.xml.ws.server.Tie.handle(Tie.java:88)
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.handle(WSServletDelegate.java:279)
            at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:232)
            at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:77)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
            at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
            at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
            at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
            at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
            at java.lang.Thread.run(Thread.java:595)
            Caused by: java.lang.ClassCastException: javax.naming.Reference
            at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:212)

            Does anyone know what I must do to lookup an remote EJB3.0 from a tomcat webapp?

            Any help is appreciated.