users@glassfish.java.net

Webservice client is not getting the service reference from JNDI..

From: <glassfish_at_javadesktop.org>
Date: Wed, 28 Mar 2007 09:15:56 PST

Hi,

I have a web application which needs to talk to a service deployed in another glassfish server but it fails:

Please note these are JAX-RPC web services not JAX-WS 2.0 and I am using GF v2-b33e.

Here is the client code:

private Remote getPort(ServiceConfig config)
    {
        Remote clientPort;
        try
        {
            Context ic = new InitialContext();
            
            Service service = (Service) ic.lookup( config.getJndiEntry() );
            clientPort = service.getPort( config.getSei() );
            ((Stub)clientPort)._setProperty( Stub.ENDPOINT_ADDRESS_PROPERTY,
                config.getEndPointUrl() );
            return clientPort;
        } catch (Exception e)
        {
            throw new RuntimeException( errMsg, e);
        }
    }


Note:

        1. config.getJndiEntry() returns "java:comp/env/service/MyServiceRef" from a config file.
        2. config.getSei() return the com.xxxxx.ws.sei.MyServiceImpl_PortType class.

In the web.xml I have the service reference as follows:

    <service-ref>
        <service-ref-name>service/MyServiceRef</service-ref-name>
        <service-interface>javax.xml.rpc.Service</service-interface>
        <wsdl-file>WEB-INF/wsdl/MyProcess.wsdl</wsdl-file>
        <jaxrpc-mapping-file>
            WEB-INF/wsdl/MyProcessService-java-wsdl-mapping.xml
        </jaxrpc-mapping-file>
        <port-component-ref>
            <service-endpoint-interface>
                com.xxxx.ws.sei.MyServiceImpl_PortType
            </service-endpoint-interface>
        </port-component-ref>
    </service-ref>


During startup of the web application I see the following which seems to me indicating that the JNDI name is bound:

[#|2007-03-28T09:54:03.968-0700|INFO|sun-appserver9.1|javax.enterprise.system.core.naming|_ThreadID=10;_ThreadName=main;java:comp/env/service/MyServiceRef;|naming.bind|#]

And here is the EXCEPTION when I try to access the service:

[#|2007-03-28T09:56:50.812-0700|WARNING|sun-appserver9.1|javax.enterprise.system.core.naming|_ThreadID=11;_ThreadName=httpSSLWorkerThread-8080-0;_RequestID=3ab829f0-4ae7-4445-9a2f-8b6568c1d52e;|
javax.xml.ws.WebServiceException: null is not a valid service
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:171)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:159)
        at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:82)
        at javax.xml.ws.Service.<init>(Service.java:56)
        at javax.xml.ws.Service.create(Service.java:697)
        at com.sun.enterprise.naming.NamingManagerImpl.getClientServiceObject(NamingManagerImpl.java:1161)
        at com.sun.enterprise.naming.NamingManagerImpl.lookup(NamingManagerImpl.java:978)
        at com.sun.enterprise.naming.java.javaURLContext.lookup(javaURLContext.java:160)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:313)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at com.xxxxx.common.service.ServiceFactory.getPort(ServiceFactory.java:66)

I even placed a sun-web.xml in the WEB-INF having the service reference as follows but with the same failure:

        <service-ref>
                <service-ref-name>service/MyProcessRef</service-ref-name>
                <port-info>
                        <service-endpoint-interface>
                                com.xxxxx.ws.sei.MyServiceImpl_PortType
                        </service-endpoint-interface>
                </port-info>
        </service-ref>


What's could be happening here? Please let me know if you need any more information.

If I deploy this web app in Oracle server then it could talk to the glassfish server based web services.

Thanks,

luke3168
[Message sent by forum member 'luke3168' (luke3168)]

http://forums.java.net/jive/thread.jspa?messageID=210324