• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Axis 2 tutorial - client class compliation error

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi All,

I'm new to web services so I've been trying out the following APACHE AXIS 2 tutorial:

http://www.roseindia.net/webservices/axis2/apache-axis2-hello-world.shtml

I have managed to setup the environment (Axis 2 is running via Tomcat servlet container), create and deploy the web service etc.

However, when it came to testing the web service using a simple client class (the last stage)...

(instructions from tutorial..)
/**
*Now go to E:\Axis2Tutorial\Examples\HelloWorld\client\client\src directory and with the help of javac command compile the code.
*E:\Axis2Tutorial\Examples\HelloWorld\client\client\src>javac net/roseindia/*.java
**/

I get the following compliation errors:

package javax.xml.stream does not exist
package org.apache.axis2.client does not exist
package org.apache.axis2.addressing does not exist
package org.apache.axiom.soap does not exist
package org.apache.axis2.context does not exist
package org.apache.axis2.client does not exist
package org.apache.axis2.description does not exist


I'm assuming I have missing libraries, if so what can I do? and where can I get them?

I have checked that the environment variables are set up correctly for AXIS2_HOME and JAVA_HOME

I'm using JDK1.6 and axis2-1.5.1


Thanks,

Ben
 
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

double check if you have configured the build path to the 'axis2-1.5.1' library.

- Shinelin
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Shinelin,

Thanks for replying,

This is the Auto generated ant build file.

I have set AXIS2_HOME env variable to C:\axis2-1.5.1-bin\axis2-1.5.1 (this folder contains the lib folder)

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add "%AXIS2_HOME%\bin" to the PATH environment variable
for windows.
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is to say, You've made a system variable called AXIS2_HOME , now add it to the PATH. The PATH is a system variable that should exist in the same area as where you added AXIS2_HOME.

hope that helps
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kevin,

I have already added "%AXIS2_HOME%\bin" in PATH system variable.

This was part 1 of the tutorial.

I'm thinking, maybe the variables are set correctly but i'm missing certain libraries?

For example from two of the errors...,

package javax.xml.stream does not exist - is this a missing java lib??
package org.apache.axis2.client does not exist - is this a missing axis2 lib??

 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe try redownloading the axis2 stuff from here http://ws.apache.org/axis2/download/1_5_1/download.cgi
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm probably annoying you at this point, but is the axis2.war file in Tomcat\webapps directory?
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ben Linus wrote:Hi Kevin,

I have already added "%AXIS2_HOME%\bin" in PATH system variable.

This was part 1 of the tutorial.

I'm thinking, maybe the variables are set correctly but i'm missing certain libraries?

For example from two of the errors...,

package javax.xml.stream does not exist - is this a missing java lib??
package org.apache.axis2.client does not exist - is this a missing axis2 lib??



Okay, the javax.xml.stream seems to be in jsr173_1.0_api.jar
org.apache.axis2.client seems to exist in axis2-kernel-1.5.jar

you should have those jar files in your axis2-1.5\lib directory
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) I just downloaded the file again, it contains the same libs etc etc.

2) yes the .war is in the Tomcat\webapps directory and it works because the web service is running fine, i'm having problems with compiling the client class

3)you're NOT annoying!! you're really helping...alot!!!
 
Shinelin Samuel
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you restart your PC after setting the environment variable? I had a problem with this once.
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin,

I just checked the .jars in axis2\lib

i have axis2-kernel-1.5.jar - (so, now i'm really confused to why its not reading that package!)

but i dont have jsr173_1.0_api.jar - (this isn't in the axis\lib directory)

Shinelin,

yes i have tried that
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know this is a lot to ask, but can someone try the tutorial?

there are only two parts and the first part is setting up tomcat, axis and the env variables (which you have probably already done)
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin,

just curious, but how did you work out where to find the libraries?

 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ben Linus wrote:Kevin,

just curious, but how did you work out where to find the libraries?



I browsed around in the axis2 folder found the lib directory, saw the jar's and it was a combination of googling the packages you were missing and trial and error on opening up the jars with 7zip and browsing through the directories (packages) until I found where they were.

Sadly, I haven't had a lot of luck going through online java tutorials regarding web services of any kind, be it axis2 or jaxws. I'm currently going through the axis tutorial and am having problems making it through that. Axis seems to be completely different than Axis2. I know what a pain the tutorials can be.
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ben Linus wrote:Kevin,

I just checked the .jars in axis2\lib

i have axis2-kernel-1.5.jar - (so, now i'm really confused to why its not reading that package!)

but i dont have jsr173_1.0_api.jar - (this isn't in the axis\lib directory)

Shinelin,

yes i have tried that



try getting the jsr173_1.0_api.jar from here: http://www.findjar.com/jar/xmlbeans/jars/jsr173_1.0_api.jar.html
OR
It's part of the xmlBeans download which you can find here http://apache.mirrors.timporter.net/xmlbeans/binaries/
in that page is xmlbeans-2.5.0.zip
that's what I downloaded.
I used 7zip to open up the zip file and found it in the lib directory.
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help so far

I've added those jars, but hasn't helped.

I thought maybe i've missed a step in the tutorial, so I started again from scratch, but its the same!

I might have to find a different Axis2 tutorial.

Ben
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know of an Axis 2 tutorial that they have actually used (one that works) ??
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What IDE are you using?
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not using one, the point of the tutorial is to understand the workings and deployment of services and client.
compiling classes using javac cmd
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

I was stuck on the same problem, and i fix it !
The classs org.apache.axis2.client is under axis2-1.5.1/bin/lib/axis2-kernel-1.5.1.jar.

The problem is you have to specify the classpath during the compilation and the execution (even if you set environment variables):
javac -extdirs ~/axis2-1.5.1-bin/lib/ net/roseindia/*.java
and
java -classpath axis2-1.5.1/bin/lib/axis2-kernel-1.5.1.jar [and all your jars] net/roseindia/Test

Hope that helps !
 
Ben Linus
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yann,

With your help, I used javac -extdirs and my cilent classes have now complied! thanks

but when i execute the Test.java i get the following error...

D:\Axis 2 Tutorial\Examples\HelloWorld\client\client\src>java -classpath D:\Axis 2
Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib net/roseindia/Test

Exception in thread "main" java.lang.NoClassDefFoundError: 2
Caused by: java.lang.ClassNotFoundException: 2
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: 2. Program will exit.


Any Ideas where i have made a mistake?


 
yann bajard
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi ben linus,

You have to specify the jars files in the -classpath option (all the jars located in Axis2-1.5.1-bin directory) and not the directory.

java -classpath D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-1.5.1.jar:D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-codegen-1.5.1.jar.... net/roseindia/Test

(i don't remember if the seperator between jar files is ':' or something else ! )


I guess, with -classpath option, if you specify a directory, the jvm is looking for .class files and not jars ???

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

yann bajard wrote:hi ben linus,

You have to specify the jars files in the -classpath option (all the jars located in Axis2-1.5.1-bin directory) and not the directory.

java -classpath D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-1.5.1.jar:D:\Axis 2Tutorial/axis2-1.5.1-bin/axis2-1.5.1/lib/axis2-adb-codegen-1.5.1.jar.... net/roseindia/Test

(i don't remember if the seperator between jar files is ':' or something else ! )


I guess, with -classpath option, if you specify a directory, the jvm is looking for .class files and not jars ???




hi Yann,

i have also faced the same issue. I resolved the compilation error as given above.

But now am unable to run the Test client. Tried incluing jars as well. but still the same error.


D:\Axis2Tutorial\Examples\HelloWorld\client\client\src>java net\roseindia\Test
Exception in thread "main" java.lang.NoClassDefFoundError: net\roseindia\Test
Caused by: java.lang.ClassNotFoundException: net\roseindia\Test
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Could not find the main class: net\roseindia\Test. Program will exit.

Can you please help me in this.
 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Flamingo,

Can you try this way?

java -Djava.ext.dirs=..\path_to_axis2_lib -cp ..build\classes net.roseindia.Test
 
flamingo dcdt
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ravinderjit Singh wrote:Hi Flamingo,

Can you try this way?

java -Djava.ext.dirs=..\path_to_axis2_lib -cp ..build\classes net.roseindia.Test



Hi,

I have tried using alone

java -Djava.ext.dirs=..\path_to_axis2_lib net.roseindia.Test

The above didnt work.

Which path i have to take for

-cp ..build\classes
 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Flamingo,

Hope you have set your classpath to your current directory before running your compiled java class.

SET CLASSPATH=%CLASSPATH%;.

I think we have not been too much dragged out of Web Services to Java . Like Ivan said, atleast I mentioned the name .
 
Naren Chivukula
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Flamingo,

Hope you have set your classpath to your current directory before running your compiled java class.

SET CLASSPATH=%CLASSPATH%;.

I think we have not been too much dragged out of Web Services to Java . Like Ivan said, atleast I mentioned the name .
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic