9 Replies Latest reply on Oct 19, 2005 7:20 PM by thomas.diesler

    JNDI Lookup not returning 'javax.xml.rpc.Service'

    darranl

      I have been trying to put together my own web service based on the Sample and documentation in the Wiki.

      I can get a simple bean / web service deployed that takes a String as a paramter and returns a String. Executing a client for the simple bean is also fine.

      I run into problems when I try and implement a complex bean that takes a complex type as a parameter and returns a complex type.

      I have deployed my web service within an ear that contains the jar file for the WS and a jar file for the client.

      When I try and run my client code I try and lookup the service ref and cast it to 'javax.xml.Service', I keep getting ClassCastExceptions thrown.

      It turns out that the object I have retrieved from JNDI is a 'javax.naming.Reference' object.

      Looking at the jmx-console the item bound is a 'org.jboss.webservice.client.ServiceReferenceable' object: -

      +- ws4ee-client (class: org.jnp.interfaces.NamingContext)
       | +- service (class: org.jnp.interfaces.NamingContext)
       | | +- CustomerOrderService (class: org.jboss.webservice.client.ServiceReferenceable)


      I went back to the sample code downloaded from the Wiki to deploy that and see if I missed anything.

      The sample code (complexbean) compiles and deploys the same as my code, then running the JUnit test case I get the same behaviour as I get with my service?

      Is there a anything missing from the sample that needs changing to get the correct object returned?

      This is using the latest JBoss (jboss-head) code from CVS last night with Sun JDK 1.4.2_02 on Windows XP.


      I also looked at the JBoss testsuite and it doesn't look as if this scenario is tested yet, one thing I did notice is that the eclipse .classpath file for the testsuite currently excludes the 'org.jboss.test.webservices' package, I think this exclusion needs removing now that the tests are run as part of the build.

        • 1. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
          thomas.diesler

          That you see a Referencable is ok. The javax.xml.rpc.Service is constructed at the client side from information that is contained in the Referencable.

           +- CustomerOrderService (proxy: $Proxy63 implements interface org.jboss.webservice.complexbean.ejb.CustomerOrderHome,interface javax.ejb.Handle)
           +- ejb (class: org.jnp.interfaces.NamingContext)
           | +- mgmt (class: org.jnp.interfaces.NamingContext)
           | | +- MEJB (proxy: $Proxy46 implements interface javax.management.j2ee.ManagementHome,interface javax.ejb.Handle)
           | +- OrganizationClientBean (proxy: $Proxy53 implements interface com.underworld.crimeportal.ejb.OrganizationClientHome,interface javax.ejb.Handle)
           | +- OrganizationBean (proxy: $Proxy58 implements interface com.underworld.crimeportal.ejb.OrganizationHome,interface javax.ejb.Handle)
           +- ws4ee-client (class: org.jnp.interfaces.NamingContext)
           | +- service (class: org.jnp.interfaces.NamingContext)
           | | +- OrganizationServiceJSE (class: org.jboss.webservice.client.ServiceReferenceable)
           | | +- OrganizationServiceEJB (class: org.jboss.webservice.client.ServiceReferenceable)
           | | +- CustomerOrderService (class: org.jboss.webservice.client.ServiceReferenceable)
          



          The test works for me with 4.0.0RC2

          test:
           [junit] Running org.jboss.webservice.complexbean.ComplexBeanTestCase
           [junit] Tests run: 2, Failures: 0, Errors: 0, Time elapsed: 3.114 sec
          


          You could goto ServiceObjectFactory.getObjectInstance and trace through there to see what is happening with your JNDI lookup.


          • 2. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
            thomas.diesler

            The behaviour you describe might occur if the client is not seeing the ServiceObjectFactory. JNDI does not know howto create the real object through the factory and simply returns the Referencable. Don't know for sure though.

            • 3. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
              darranl

              Thomas,

              Yes the problem was that the required jars were not in my Classpath, I have been in the habit in the past of waiting for ClassNotFoundExceptions and then adding the required jars as required.

              Thanks for your help.

              From,
              Darran.

              • 4. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                hsutarwala

                I would like to know the ear structure for deployement of a Document Literal WS client. The tutorial does not indicate how the deployment artifact should be packaged.

                • 5. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                  thomas.diesler

                  You could checkout the samples, any of the test deployments, read the spec, etc

                  What is the issue?

                  • 6. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                    hsutarwala

                    I am getting a
                    ClassCastException:javax.naming.reference
                    I am following the WSDocClientStepByStep Tutorial and am getting the above error when I try to iniCtx.lookup("java:comp/env/service/XXX")

                    All help is appreciated.

                    • 7. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                      hsutarwala

                      Thomas,

                      Yes the problem was that the required jars were not in my Classpath, I have been in the habit in the past of waiting for ClassNotFoundExceptions and then adding the required jars as required.

                      Thanks for your help.

                      From,
                      Darran

                      Darran or Thomas
                      Which jars are you referring to here??
                      Husain

                      • 8. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                        craigpugsley

                        I'm in this tricky position as well. I've tried adding all the JBoss 4.0.3 libs to my classpath, but still when I try to lookup in JNDI, I get back this Reference object instead of my class that I expect to get.

                        Of note, I'm launching my client app from Eclipse with the JBoss running on a remote machine. This shouldn't make any difference though, yes?

                        • 9. Re: JNDI Lookup not returning 'javax.xml.rpc.Service'
                          thomas.diesler

                          The required client jars are listed in the FAQ wiki