Java wsgen和应用程序引擎

Java wsgen和应用程序引擎,java,web-services,google-app-engine,webmethod,wsgen,Java,Web Services,Google App Engine,Webmethod,Wsgen,我正在尝试执行wsgen命令来创建一个Web服务。我的命令行是: 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" 出现以下错误: 警告:在类型“javax.jd

我正在尝试执行wsgen命令来创建一个Web服务。我的命令行是:

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"
出现以下错误: 警告:在类型“javax.jdo.annotations.Persisten”中找不到注释方法“valueStrategy()”:找不到javax.jdo.annotations.Persistent的类文件。 错误:找不到com.example.prototipo21.Greeting的类文件 1错误 1警告 错误:编译失败,应报告错误

我认为问题可能在于我正在将数据存储应用程序集成到Web服务应用程序中,因此我的类具有不同的注释。例如:

@WebService
public class Greeting {

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

@Persistent
private User author;

你知道我的意思吗??任何想法都会非常有用!!谢谢

这些是我的命令和整个跟踪:

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

该错误与您编写的代码没有任何问题。问题在于类路径。如果检查错误,您可以清楚地看到:

找不到com.example.prototipo21.Greeting1的类文件


修复您的类路径,以便该类可供wsgen使用,您可能会领先一步,并在下一组错误中绊倒:)祝您好运

我也遇到了同样的错误。出现此错误的原因是您必须向wsgen提供对GAE正在使用的库的引用

只需修改类路径以包含其他jar文件。请注意,在Unix中我们使用冒号“:”来分隔目录,在Windows中我们使用分号“;”

(只需相应地更改目录路径)


嗯,我已经更改了jdk的路径,现在cmd中的错误是:警告:apt工具及其相关API计划在下一个主要jdk版本中删除[…更多警告…]错误:无法为注释类型javax.jdo.annotations创建声明。PrimaryKey。错误:无法为注释类型javax.jdo.annotation.Persistent[…]创建声明。有什么想法吗??谢谢!!=)你能发布完整的错误吗?详细信息不足以正确回答任何问题是的,我编辑了我的主要问题,添加了逗号、警告和错误,请看那里!非常感谢。
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
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