6 Replies Latest reply on Nov 24, 2004 11:14 AM by Jason Greene

    javax.naming.NameNotFoundException: service not bound

    namitajain Newbie

      Hi All,
      I am trying to use a remote web service and have used Apache Axis Wsdl2Java tool to generate all the necessary client Service/Locator and stub classes. I wrote a servlet to access the functions provided by this remote web service and did the following :
      try
      {
      Context iniCtx = new InitialContext();
      MyServiceServiceService service = (MyServiceService)iniCtx.lookup("java:comp/env/service/MyService");
      MyService port = (MyService)service.getMyServiceQuery();
      } catch (Exception e) {
      System.err.println("Exception: " + e);
      }

      I have also added the service-ref in my web.xml as:
      <service-ref>
      <service-ref-name>service/MyServiceName</service-ref-name>
      <service-interface>MyServiceInterface</service-interface>
      <wsdl-file>WEB-INF/wsdl/myservice.wsdl</wsdl-file>
      </service-ref>

      I get the "javax.naming.NameNotFoundException: service not bound' error when I try to access the servlet.

      I would appriciate if someone can point out what am I missing so that my servlet can locate the jndi name. I am not dealing with ejb's at all and want to write a servlet based client to access the web service.

      I have gone through the web services wiki pages as well.

      Thanks much..
      N.J

        • 1. configuration of interceptors
          Jason Greene Master

          Ok

          just had an interesting IM with hiram. He essentially has implemented the proxy factory we were talking about. I think he is missing the client/server side of it but we can very simply add these.

          Essentially it would revolve around a central
          proxyFactory.createProxy(Interfaces[], client-interceptors[], client-configurations[], server-interceptors[], serverconfigurations[] targetMbean);

          that returns a Dynamic Proxy, hooked up for remote/local calls with client and server side interceptors. If you are in one vm you can safely assume client=server and only configure one or the other. (meaning if one is null then don't configure transport it will be invm
          only)

          In the case of hiram he has only one aspect of it (and he calls it aspect everywhere) but that construct is really what we need. I also think we should have the "MBean" in there, even though we are talking about a POJO.

          I believe he has solid code for it and I am really interested in adding this to the base. I am not sure it is a JMX level construct (due to the pojo nature) but having the JMX base manage these configurations and associations between target and interceptors/configuration is the only sane way I can imagine to have these puppies manageable. I want visibility on that configuration for a given mbean (the generalized mbean againg being just a pojo or target). This is our generalized
          proxy factory.

          The AOP framework of the future is staring us in the eye... we got it.

          marc f


          • 2. Re: javax.naming.NameNotFoundException: service not bound
            Thomas Diesler Master

            Apache Axis service locators do not enter the game with WS4EE. They are axis specific, hence not portable.

            Is it true, that you hava a service interface, that extends javax.xml.rpc.Service and it has no package?

            <service-interface>MyServiceInterface</service-interface>
            


            Most people use

            <service-interface>javax.xml.rpc.Service</service-interface>
            


            • 3. Re: javax.naming.NameNotFoundException: service not bound
              namitajain Newbie

              Hi Thomas,
              I replaced the <service-interface> tag as <service-interface>javax.xml.rpc.Service</service-interface> in my web.xml but I am getting the same error.

              Any other idea or suggestion will be helpful, as to how can I implement a servlet to access a remote web service.

              Thanks again:
              N.J

              • 4. Re: javax.naming.NameNotFoundException: service not bound
                Jason Greene Master

                A J2EE web componet client does not need stubs because it uses the service enpoint interface and the jaxrpc-mapping file of the service.

                The wiki states "The web service client must have access to the same mapping information as described for the EJB service endpoint or the Java service endpoint. The jaxrpc mapping file must be part of the deployment, it cannot be obtained at runtime."

                Which, for all practical purposes, means that a J2EE web service component client can only communicate with a J2EE service endpoint. If you are talking to a remote web service which is not a J2EE service endpoint (you don't have a jaxrpc-mapping file) then you must use another method of accessing the service. You can either use DII, or you can generate ordinary stubs with any web services toolkit. Be forewarned that AXIS client stubs are not portable. I would try using wscompile generated stubs from suns JWSDP to do this.

                -Jason

                • 5. Re: javax.naming.NameNotFoundException: service not bound
                  namitajain Newbie

                  Hi Jason,
                  Thanks for ur reply. I will try to use wscompile tool and see what I can get.

                  N.J

                  • 6. Re: javax.naming.NameNotFoundException: service not bound
                    namitajain Newbie

                    Hi Thomas,
                    This is in reply to ur question " Is it true, that you hava a service interface, that extends javax.xml.rpc.Service and it has no package? '

                    Yes, I do have a serveice interface that extends javax.xml.rpc.Service and it has a package name, which I have specified in my web.xml :

                    <service-ref>
                    <service-ref-name>service/MyService</service-ref-name>
                    <service-interface>com.webservice.MyServiceService</service-interface>
                    <wsdl-file>WEB-INF/wsdl/my-wsdl.wsdl</wsdl-file>
                    </service-ref>

                    I am not able to figure out why the serlvet cannot locate and lookup the web service name defined in web.xml !!Any help !!

                    Thanks..
                    N.J