无法在 Java Web 服务中创建 JAXBContext
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1198462/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to create JAXBContext in Java Web service
提问by Sulaiman
I used NetBeans to create a Metro Web service and to be deployed on GlassFish. I get an error when I try to build but onlyif one of the operations in the web service returns an Object instead of a primitive type or String.
我使用 NetBeans 创建 Metro Web 服务并部署在 GlassFish 上。当我尝试构建时出现错误,但仅当 Web 服务中的操作之一返回对象而不是原始类型或字符串时。
The error:
错误:
Deploying application in domain failed; Deployment Error -- Exception occured in the wsgen process javax.xml.ws.WebServiceException: Unable to create JAXBContext
build-impl.xml:569: The module has not been deployed.
BUILD FAILED (total time: 2 seconds)
The containing code:
包含代码:
<target if="netbeans.home" name="-run-deploy-nb">
<nbdeploy clientUrlPart="${client.urlPart}" debugmode="false" forceRedeploy="${forceRedeploy}"/>
</target>
Any help is appreciated!
任何帮助表示赞赏!
采纳答案by VonC
This threadis also a good illustration of your problem:
此线程也很好地说明了您的问题:
The problem is that the custom class has public access for the properties and also it has getter/setter methods.
I discover because you can use Netbeans to generate theWSDL
files for theWebservice
to inspect them. Doing so it returned the detailed error.
If you want to use it, write your Web Service, then go to "Web Services
" node, select your Web Service, right click it and select "Generate and CopyWSDL
".
问题在于自定义类具有对属性的公共访问权限,并且还具有 getter/setter 方法。
我发现因为您可以使用 Netbeans 生成WSDL
文件以供Webservice
检查。这样做会返回详细的错误。
如果要使用它,请编写您的Web Service,然后转到“Web Services
”节点,选择您的Web Service,右键单击它并选择“生成并复制WSDL
”。
You can find some practical advices here on the definition of your object.
您可以在此处找到有关对象定义的一些实用建议。
And of course you still have the Java Web Service Tutorialexposing the Requirements of a JAX-WS Endpoint.
当然,您仍然拥有公开JAX-WS 端点的需求的Java Web 服务教程。
回答by Sulaiman
I found the Solution..
我找到了解决方案..
The class I am returning has a public value also, set and get so delete them and worked fine
我返回的类也有一个公共值,设置并获取所以删除它们并且工作正常
回答by gherson
Above steps didn't work for me. What did was adding an empty constructor to MyClass of the object being returned, an ArrayList<MyClass>.
以上步骤对我不起作用。所做的是向正在返回的对象的 MyClass 添加一个空构造函数,一个 ArrayList<MyClass>。
(NB6.9.1, GF2.X, Windows XP x64)
(NB6.9.1, GF2.X, Windows XP x64)