[jboss-user] [JBossWS] - java.lang.ClassCastException: javax.naming.Reference while a

atulksh do-not-reply at jboss.com
Wed Jan 17 21:07:03 EST 2007


Hi,
I am fresh to webservices under jboss. I have jboss4.0.4 with ejb3 and jdk 1.5 setup. I have downloaded the jboss web services 1.0.4 package and deployed it to the jboss instance. I then compiled the samples and was successful at it. I wanted to run the rpcstyle-client example (jaxrpc endpoint) and access the webservice using a standalone java client. I deployed the generated

jaxrpc-samples-rpcstyle.war
jaxrpc-samples-rpcstyle-client.jar

and wrote a simple client as follows -

import javax.naming.*;

import java.util.*;

import javax.xml.rpc.*;
import javax.rmi.*;

import org.jboss.test.ws.jaxrpc.samples.rpcstyle.TrivialService;

public class TestWSClient {
    
public void testTrivialAccess() throws Exception
    {
       InitialContext iniCtx = getInitialContext();
       Service service = (Service)iniCtx.lookup("java:comp/env/service/TrivialService");
       TrivialService port = (TrivialService)service.getPort(TrivialService.class);
       String person = "Kermit";
       String product = "Ferrari";
       String status = port.purchase(person, product);
       System.out.println("Status: " + status);
    }
   
    protected InitialContext getInitialContext() throws NamingException
    {
        Properties env = new Properties();
        env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
        env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.naming.client:org.jboss.naming");
        env.setProperty(Context.PROVIDER_URL, "jnp://localhost:1099");
        env.setProperty("j2ee.clientName", "jbossws-client");
        Properties p = System.getProperties(); 
        p.put("com.sun.xml.namespace.QName.useCompatibleSerialVersionUID", "1.0"); 
        System.setProperties(p);
        return new InitialContext(env);
    }
    
    public static void main(String[] args) {
        try {
        TestWSClient wsClient = new TestWSClient();
        wsClient.testTrivialAccess();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

But on running the code I got the following exception

java.lang.ClassCastException: javax.naming.Reference

When I looked at the object returned by JNDI lookup it is of type

org.jboss.ws.jaxrpc.ServiceReferenceable

According to the documentation - 

http://labs.jboss.com/portal/jbossws/user-guide/en/html/clients.html

this should work and return a Service refrence. What am I doing wrong? Your help is greatly appreciated.

Thank you.



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4003126#4003126

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4003126



More information about the jboss-user mailing list