users@glassfish.java.net

binding webservice to jndi name doesn't work

From: <glassfish_at_javadesktop.org>
Date: Mon, 12 Apr 2010 07:40:36 PDT

Hi,

I have a WebService client MyService generated from a WSDL by WSDL2Java.
I want to bind it to a JNDI name to use it that way:

[code]
Context cxt = new InitialContext();
MyServiceLocator serviceLocator = (MyServiceLocator)
     cxt.lookup(java:comp/env/service/MyService);
MyPort port = serviceLocator.getPort(new URL(wsEndpoint));
[/code]

I therefore wrote an ejb-jar.xml:

[code]
<?xml version="1.0"?>
 
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" version="3.0" >
   <enterprise-beans>
 
    <session>
      <ejb-name>MyClientBean</ejb-name>
      <ejb-class>com.example.MyClientBean</ejb-class>
 
      <service-ref>
        <service-ref-name>service/MyService</service-ref-name>
        <service-interface>javax.xml.rpc.Service</service-interface>
        <wsdl-file>/MyService.wsdl</wsdl-file>
        <jaxrpc-mapping-file>META-INF/MyService_mapping.xml</jaxrpc-mapping-file>
      </service-ref>
    </session>
  </enterprise-beans>
</ejb-jar>
[/code]

However, when calling cxt.lookup() an exception is thrown that there is no object bound to the name. The ejb-jar.xml is correctly read, because when the <wsdl-file> and <jaxrp-mapping-file> tags were missing, glassfish complained about it.

Also when looking at the JNDI tree in glassfish, the name isn't found there.

So what am I missing here?


I am using glassfish v2ur2.
[Message sent by forum member 'hupfdule']

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