You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Mathieu Larchet <ma...@univ-nancy2.fr> on 2005/07/19 15:39:44 UTC

Dynamic ServiceLocator

Hello,

I'am using wsdl2java to generate client classes for my service.
wsdl2java generate a <service-name>ServiceLocator.java class which
contains direct references to my service endpoint (something like
http://server.mydomain.com/axis/MyService).

I want to specify in my client only the WSDL url. The service locator
should be able to find dynamically the webservice endpoint but I can't
find how.

Does anybody have already done something like this ?

Thanks

PS : Axis should work like this, PHP and Perl already work like this.

-- 
Mathieu Larchet
Centre de Ressources Informatiques
Université Nancy 2
mathieu.larchet@univ-nancy2.fr
03-83-39-64-06
http://www.univ-nancy2.fr/ANNUAIRE/PERS/detail_pres.php?uid=mlarchet


Re: java.lang.NoClassDefFoundError: javax/xml/rpc/Service

Posted by Javier Gonzalez <ja...@gmail.com>.
You have classpath issues. You must explicitly name all the jars in
your classpath declaration (having them in the same directory isn't
enough) in the command line (java -classpath ...) or set the classpath
env variable before running java -jar.

A better idea would be to create a shell script (.bat in your windows
case) that invokes the proper classpath when running your jar. That
way you don't have to define the classpath env variable or write the
whole classpath every time you want to run your jar.

On 7/19/05, Dipty Maybhate <di...@gmail.com> wrote:
> Hi Everyone,
> 
> I have implements a web services client using AXIS. I am trying to
> make a jar file with all the jars and classes needed to run the
> client. When I run the jar it throws the following exception
> 
> C:\Program Files\Java\jdk1.5.0\bin>java -jar API.jar
> Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/Se
> rvice
> 
>        at java.lang.ClassLoader.defineClass1(Native Method)
>        at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
>        at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja=
> va:12
> 4)
>        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>        at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> 
> I have included all the axis - jar files along with my class files and
> those generated using WSDL2Java
> 
> c:/axis/axis-1_2_1/lib/axis-ant.jar
> c:/axis/axis-1_2_1/lib/axis.jar
> c:/axis/axis-1_2_1/lib/commons-discovery-0.2.jar
> c:/axis/axis-1_2_1/lib/commons-logging-1.0.4.jar
> c:/axis/axis-1_2_1/lib/jax-qname.jar
> c:/axis/axis-1_2_1/lib/jaxrpc-1_1-fr-spec-api.jar
> c:/axis/axis-1_2_1/lib/jaxrpc.jar
> c:/axis/axis-1_2_1/lib/log4j-1.2.8.jar
> c:/axis/axis-1_2_1/lib/saaj.jar
> c:/axis/axis-1_2_1/lib/wsdl4j-1.5.1.jar
> c:/axis/axis-1_2_1/lib/xmlsec-1.2.1.jar
> Does anyone have an idea why there is a problem?
> Thank you very much!
> Dipty
> 


-- 
Javier Gonzalez Nicolini

java.lang.NoClassDefFoundError: javax/xml/rpc/Service

Posted by Dipty Maybhate <di...@gmail.com>.
Hi Everyone,

I have implements a web services client using AXIS. I am trying to
make a jar file with all the jars and classes needed to run the
client. When I run the jar it throws the following exception

C:\Program Files\Java\jdk1.5.0\bin>java -jar API.jar
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/Se
rvice

       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
       at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja=
va:12
4)
       at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
       at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
       at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)

I have included all the axis - jar files along with my class files and
those generated using WSDL2Java

c:/axis/axis-1_2_1/lib/axis-ant.jar
c:/axis/axis-1_2_1/lib/axis.jar
c:/axis/axis-1_2_1/lib/commons-discovery-0.2.jar
c:/axis/axis-1_2_1/lib/commons-logging-1.0.4.jar
c:/axis/axis-1_2_1/lib/jax-qname.jar
c:/axis/axis-1_2_1/lib/jaxrpc-1_1-fr-spec-api.jar
c:/axis/axis-1_2_1/lib/jaxrpc.jar
c:/axis/axis-1_2_1/lib/log4j-1.2.8.jar
c:/axis/axis-1_2_1/lib/saaj.jar
c:/axis/axis-1_2_1/lib/wsdl4j-1.5.1.jar
c:/axis/axis-1_2_1/lib/xmlsec-1.2.1.jar
Does anyone have an idea why there is a problem?
Thank you very much!
Dipty

Re: Dynamic ServiceLocator

Posted by Martin Grotzke <ma...@javakaffee.de>.
On Wed, 2005-07-20 at 08:28 +0200, Mathieu Larchet wrote:
> Martin Grotzke wrote: 
> > Hi Mathieu,
> > 
> > On Tue, 2005-07-19 at 15:39 +0200, Mathieu Larchet wrote:
> >   
> > > Hello,
> > > 
> > > I'am using wsdl2java to generate client classes for my service.
> > > wsdl2java generate a <service-name>ServiceLocator.java class which
> > > contains direct references to my service endpoint (something like
> > > http://server.mydomain.com/axis/MyService).
> > > 
> > > I want to specify in my client only the WSDL url. The service locator
> > > should be able to find dynamically the webservice endpoint but I can't
> > > find how.
> > >     
> > You might want to try the following:
> > 
> > YourServiceLocate sl = new YourServiceLocator();
> > URL portAddress = new URL( "http://server.mydomain.com/YourService" );
> > YourService service = sl.getYourService( portAddress );
> > 
> > Cheers,
> > Martin
> >   
> Again, you're submitting the service URL in your client.
> I want to submit only the WSDL URL in my client ant let it find itself
> the service endpoint.

So what about
http://ws.apache.org/axis/java/apiDocs/org/apache/axis/client/Service.html#Service(java.lang.String,%20javax.xml.namespace.QName) ?

Cheers,
Martin

> > 
> >   
> > > Does anybody have already done something like this ?
> > > 
> > > Thanks
> > > 
> > > PS : Axis should work like this, PHP and Perl already work like this.
> > > 
> > >     
> 
> 
> -- 
> Mathieu Larchet
> Centre de Ressources Informatiques
> Université Nancy 2
> mathieu.larchet@univ-nancy2.fr
> 03-83-39-64-06
> http://www.univ-nancy2.fr/ANNUAIRE/PERS/detail_pres.php?uid=mlarchet
-- 
Martin Grotzke
Hohenesch 38, 22765 Hamburg
Tel.      +49 (0) 40.39905668
Mobil     +49 (0) 170.9365656
E-Mail    martin.grotzke@javakaffee.de
Online    http://www.javakaffee.de

Re: Dynamic ServiceLocator

Posted by Mathieu Larchet <ma...@univ-nancy2.fr>.
Martin Grotzke wrote:

>Hi Mathieu,
>
>On Tue, 2005-07-19 at 15:39 +0200, Mathieu Larchet wrote:
>  
>
>>Hello,
>>
>>I'am using wsdl2java to generate client classes for my service.
>>wsdl2java generate a <service-name>ServiceLocator.java class which
>>contains direct references to my service endpoint (something like
>>http://server.mydomain.com/axis/MyService).
>>
>>I want to specify in my client only the WSDL url. The service locator
>>should be able to find dynamically the webservice endpoint but I can't
>>find how.
>>    
>>
>You might want to try the following:
>
>YourServiceLocate sl = new YourServiceLocator();
>URL portAddress = new URL( "http://server.mydomain.com/YourService" );
>YourService service = sl.getYourService( portAddress );
>
>Cheers,
>Martin
>  
>
Again, you're submitting the service URL in your client.
I want to submit only the WSDL URL in my client ant let it find itself
the service endpoint.

>
>  
>
>>Does anybody have already done something like this ?
>>
>>Thanks
>>
>>PS : Axis should work like this, PHP and Perl already work like this.
>>
>>    
>>


-- 
Mathieu Larchet
Centre de Ressources Informatiques
Université Nancy 2
mathieu.larchet@univ-nancy2.fr
03-83-39-64-06
http://www.univ-nancy2.fr/ANNUAIRE/PERS/detail_pres.php?uid=mlarchet


Re: Dynamic ServiceLocator

Posted by Martin Grotzke <ma...@javakaffee.de>.
Hi Mathieu,

On Tue, 2005-07-19 at 15:39 +0200, Mathieu Larchet wrote:
> Hello,
> 
> I'am using wsdl2java to generate client classes for my service.
> wsdl2java generate a <service-name>ServiceLocator.java class which
> contains direct references to my service endpoint (something like
> http://server.mydomain.com/axis/MyService).
> 
> I want to specify in my client only the WSDL url. The service locator
> should be able to find dynamically the webservice endpoint but I can't
> find how.
You might want to try the following:

YourServiceLocate sl = new YourServiceLocator();
URL portAddress = new URL( "http://server.mydomain.com/YourService" );
YourService service = sl.getYourService( portAddress );

Cheers,
Martin


> 
> Does anybody have already done something like this ?
> 
> Thanks
> 
> PS : Axis should work like this, PHP and Perl already work like this.
> 
--