users@jax-rpc.java.net

Re: NoSuchMethodError

From: Doug Kohlert <doug.kohlert_at_sun.com>
Date: Mon, 17 Mar 2003 16:12:43 -0800

Julian, a new User class should have been generated for you
when you generated the client artifacts from the WSDL. You
must use the generated User class and not the original class.

Julian Gantner wrote:
> Hello list,
>
> i am somewhat familiar with webservices, but i have the following
> problem. I am user the actual jwsdp from SUN, which uses tomcat:
>
> i have a package A and a package B. in package A i define my jax-rpc
> webservice consisting of TestIF (the interface definition, see below)
> and my TestImpl (the implementation). In Package B i have my class
> B.User with the two private variables "username" (String) and "roles".
> The latter is a java.util.Vector(). The class B.User has the required
> getter and setter methods.
>
> TestIF:
> ------------
> package A;
> import B.User;
>
> public interface TestIF extends Remote {
> public String printUser(User user) throws RemoteException;
> }
>
>
> TestImpl:
> -----------
> package A;
> import B.User;
>
> public class TestImpl implements TestIF {
> public String printUser(User user) throws RemoteException {
> return user.getUsername();
> }
> }
>
> When I now deploy my webservice using the deploytool (wsdeploy) and
> restart the server, i can access the WSDL and the webservice site. now I
> compile the client (stubs). The config.xml-file hat as packageName="A".
> Then I jar the generated classes in a jarfile. When I then implement a
> client (see below) and try to run it, i get the NoSuchMethodError. My
> suspicion is, that it is not allowed to use self made classes out of
> diffrent packages as the interface declaration is.
>
> package A;
>
> import B.User; // (but that package does not exist in the packed jarfile
> containing the stubs?!
>
> public class Client {
> public static void main(String ars[]) {
> try {
> Stub stub = (Stub)createProxy();
> TestIF inst = (TestIF)stub;
> inst.printUser(new User("username")); // here the compiles
> says "NoSuchMethodError", although the method exists in the packed jarfile
> } catch (Exception e) {
> e.printstacktrace();
> }
> }
>
> private static Stub createProxy() {
> return (Stud)(new Test_Impl().getTestIFPort());
> }
> }
>
>
> I would be very happy, if someone can give me a hint how to solve this
> problem.
>
> Many many thanks in advance.
>
> Julian Gantner, Karlsruhe


-- 
Doug Kohlert
Java Software Division
Sun Microsystems, Inc.
phone: 503 345-9806