wsgen and App Engine

5k views Asked by At

I'm trying to execute the wsgen command to create a Web Service. My command lines are:

PATH=%path%;C:\Program Files\Java\jdk1.6.0_24\bin
wsgen -cp ".\war\WEB-INF\classes" -wsdl -keep -r ".\war" -d ".\war\WEB-INF\classes" -             s ".\war" "com.example.prototipo21.Greeting"

And this error appears: warning: Cannot find annotation method 'valueStrategy()' in type 'javax.jdo.annotations.Persisten': class file for javax.jdo.annotations.Persistent not found. error: Could not find class file for com.example.prototipo21.Greeting 1 error 1 warning error: compilation failed, errors should have been reported

I think the problem could be I'm integrating a Datastore Application in a Web Service application so my class has different annotations. For example:

@WebService
public class Greeting {

@PrimaryKey
@Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

@Persistent
private User author;

...

@WebMethod  
public Key getKey() {
    return key;
}
@WebMethod
public User getAuthor(){
    return author;

....

you know what I mean?? Any idea will be very useful!! Thanks!

Those are my commands and the entire trace:

c:\Users\...\Desktop\....\Eclipse\Prototipo_21>PATH=%pa
th%;C:\Program Files\Java\jdk1.7.0_03\bin

c:\Users\...\Desktop\....\Eclipse\Prototipo_21>wsgen -c
p ".\war\WEB-INF\classes" -wsdl -keep -r ".\war" -d ".\war\WEB-INF\classes" -s "
.\war" "com.example.prototipo21.Greeting"

warning: The apt tool and its associated API are planned to be
removed in the next major JDK release.  These features have been
superseded by javac and the standardized annotation processing API,
javax.annotation.processing and javax.lang.model.  Users are
recommended to migrate to the annotation processing features of
javac; see the javac man page for more information.
.\war\WEB-INF\classes\com\example\prototipo21\Greeting.class: warning: Cannot fi
nd annotation method 'valueStrategy()' in type 'Persistent': class file for java
x.jdo.annotations.Persistent not found
warning: unknown enum constant IdGeneratorStrategy.IDENTITY
reason: class file for javax.jdo.annotations.IdGeneratorStrategy not found
error: Could not create declaration for annotation type javax.jdo.annotations.Pr
imaryKey
error: Could not create declaration for annotation type javax.jdo.annotations.Pe
rsistent
Problem encountered during annotation processing;
see stacktrace below for more information.
com.sun.tools.internal.ws.processor.modeler.ModelerException: modeler error: Cla
sses annotated with @javax.jws.WebService must have a public default constructor
. Class: com.example.prototipo21.Greeting
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.o
nError(WebServiceAP.java:229)
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisi
tor.isLegalImplementation(WebServiceVisitor.java:515)
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisi
tor.shouldProcessWebService(WebServiceVisitor.java:322)
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisi
tor.visitClassDeclaration(WebServiceVisitor.java:113)
    at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(Clas
sDeclarationImpl.java:113)
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.b
uildModel(WebServiceAP.java:319)
    at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.p
rocess(WebServiceAP.java:260)
    at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.
process(AnnotationProcessors.java:84)
    at com.sun.tools.apt.comp.Apt.main(Apt.java:480)
    at com.sun.tools.apt.main.AptJavaCompiler.compile(AptJavaCompiler.java:2
70)
    at com.sun.tools.apt.main.Main.compile(Main.java:1127)
    at com.sun.tools.apt.main.Main.compile(Main.java:989)
    at com.sun.tools.apt.Main.processing(Main.java:113)
    at com.sun.tools.apt.Main.process(Main.java:103)
    at com.sun.tools.apt.Main.process(Main.java:85)
    at com.sun.tools.internal.ws.wscompile.WsgenTool.buildModel(WsgenTool.ja
va:207)
    at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:111)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:120)
    at com.sun.tools.internal.ws.WsGen.main(WsGen.java:42)
error: compilation failed, errors should have been reported
2

There are 2 answers

3
Vishal Biyani On

The error has no issues with the code you have written. The issue is with the classpath. If you examine the error you can distinctly see:

Could not find class file for com.example.prototipo21.Greeting1

Fix your classpath so that the class is available to wsgen and you might get a step ahead and stumble in next set of errors :) Good luck

0
Mark Pazon On

I was having the same error. The reason why you are getting this error is that you have to give wsgen a reference to the libraries that GAE are using as well.

Just modify the classpath to include the other jar files. Note that in Unix we use colon ":" to separate directories and in Windows we use semi-colon ";".

(Just change the directory path accordingly)

class=com.sample.MyWebService
clpth='./war/WEB-INF/classes:/Applications/eclipse_jee/plugins/com.google.appengine.eclipse.sdkbundle_1.7.0/appengine-java-sdk-1.7.0/lib/opt/user/datanucleus/v2/jdo-api-3.1-SNAPSHOT-20110926.jar:/Applications/eclipse_jee/plugins/com.google.appengine.eclipse.sdkbundle_1.7.0/appengine-java-sdk-1.7.0/lib/user/appengine-api-1.0-sdk-1.7.0.jar'
resourcedir='./war'
outsourcedir='./src'
outdir='./war/WEB-INF/classes'
wsgen -cp "$clpth" -wsdl -keep -r "$resourcedir" -d "$outdir" -s "$outsourcedir"  $class