views:

98

answers:

2

I created the webservice stubs using axis2-1.5's wsdl2java.bat. This created a src folder with the following structure in it:

src/net/mycompany/www/services/SessionIntegrationStub.java

The package of the SessionIntegration.java file is: package net.mycompany.www.services;

Now, I am trying to use this stub in my java code. I placed my java file in the same services folder. I set the same package. Here is my entire class:

package net.mycompany.www.services;
import net.mycompany.www.services;

public class DynamicProxy 
{
  public static void main(String[] args) 
  {
    try 
    {
      SessionIntegrationStub stub = new SessionIntegrationStub();
      System.out.println(stub.getSessionIntegration("test"));
    }
    catch (Exception e) 
    {
      System.out.println(e);
    } 
  } 
}

Then I tried to compile this code with the following cmd:

javac DynamicProxy.java

However I keep getting this error message:

C:\data\net\mycompany\www\services>javac DynamicProxy.java
DynamicProxy.java:9: cannot find symbol
symbol  : class SessionIntegrationStub
location: package net.mycompany.www.services
import net.mycompany.www.services.SessionIntegrationStub;
                                       ^
DynamicProxy.java:17: cannot find symbol
symbol  : class SessionIntegrationStub
location: class net.mycompany.www.services.DynamicProxy
                        SessionIntegrationStub stub = new SessionIntegrationStub();
                        ^
DynamicProxy.java:17: cannot find symbol
symbol  : class SessionIntegrationStub
location: class net.mycompany.www.services.DynamicProxy
                        SessionIntegrationStub stub = new SessionIntegrationStub();
                                                          ^
3 errors

Any idea what I am missing here?

Update 1:

I compiled the stubs (thanks to the answers below) and I got rid of the first error. I changed the import to this import net.americanapparel.www.services.*; however I still get an error for the SessionIntegrationStub: cannot find symbol. I also tried this import: net.americanapparel.www.services.SessionIntegrationStub, but that did not help either. Is there anything else I am missing?

A: 

You have to compile your stub first or both together, since wsdl2java only creates a .java file, not the .class file. The compiler error clearly says it don't know the SessionIntegrationStub.

The other answer is right too: you have to

import net.mycompany.www.services.*;

not

import net.mycompany.www.services;
ZeissS
Thanks, Please see my edit above **Update 1**.
vikasde
A: 

You don't seem to import it.

import net.mycompany.www.services.SessionIntegrationStub;

should do the trick.

and then:

shell$ javac my/package/*.java

which should enable javac to find or compile all the files it needs.

extraneon
Thanks, Please see my edit above **Update 1**.
vikasde
Still doesnt work. I am getting the same errors as in Update 1.
vikasde
Javac can see the package but not the class. However I can see the SessionIntegrationStub.class file. I am surely missing something here.
vikasde
Well, it should be on the classpath. That's why I suggested compiling all files in 1 batch (javac ...*)
extraneon
Ok. I did. Now I get this when I try to execute the .class file: Exception in thread "main" java.lang.NoClassDefFoundError: C:\data\net\mycompany\www\services\dynamicproxy/java Caused by: java.lang.ClassNotFoundException: C:\data\net\mycompany\www\services\dynamicproxy.java. I compiled all java files like this: javac -cp . C:\data\net\mycompany\www\services\*.java
vikasde
Forgot to mention: I am trying to run it like that as well: javac -cp . C:\data\net\mycompany\www\services\dynamicproxy
vikasde