3

我有一个首先创建 WSDL 的 CXF 服务服务,当我将 WAR 部署到 glassfish 应用服务器 2.1.1 中时,出现以下异常:

java.io.FileNotFoundException: C:\Sun\AppServer\domains\domain1\config\TestService.wsdl

如果我将 WSDL 放在那个位置,一切正常。如何设置我的 WAR 以便将 TestService.wsdl 放入配置文件夹?

谢谢!

更新:我仍然无法将此服务部署到 Glassfish。因为它在 Tomcat 中部署和运行良好。

我在构建期间将 -wsdlLocation 属性设置为“WEB-INF/wsdl/TestService.wsdl”,但是现在当我在 glassifish 中部署应用程序时,我在 server.log 中得到以下异常

[#|2010-02-01T10:47:06.164-0500|SEVERE|sun-        
appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=23;_ThreadName=Thread-  
501;_RequestID=d3a3f49b-9329-477d-b6fc-24e0f4e4f3fa;|wsdl file 
file:/C:/development/wexlink/FileUploadService/wsdl/FileUploadService.wsdl does not 
exist for web service FileUploadService|#]

[#|2010-02-01T10:47:06.977-0500|SEVERE|sun     
appserver2.1|javax.enterprise.system.tools.deployment|_ThreadID=23;_ThreadName=Thread-  
501;_RequestID=d3a3f49b-9329-477d-b6fc-24e0f4e4f3fa;|Exception occured in J2EEC 
Phasejava.lang.RuntimeException: wsdl file 
file:/C:/development/wexlink/FileUploadService/wsdl/FileUploadService.wsdl does not 
exist for web service FileUploadService
com.sun.enterprise.deployment.backend.IASDeploymentException: Error loading deployment   
descriptors for module [FileUploadService] -- wsdl file 
file:/C:/development/wexlink/FileUploadService/wsdl/FileUploadService.wsdl does not 
exist for web service FileUploadService
    at   com.sun.enterprise.deployment.backend.Deployer.loadDescriptors(Deployer.java:406)
    at com.sun.enterprise.deployment.backend.ModuleDeployer.loadDescriptors(ModuleDeployer.java:426)
    at com.sun.enterprise.deployment.backend.WebModuleDeployer.deploy(WebModuleDeployer.java:160)
    at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:182)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:208)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:966)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:283)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:835)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:187)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:225)

引起:java.lang.RuntimeException:wsdl 文件文件:/C:/development/wexlink/FileUploadService/wsdl/FileUploadService.wsdl 不存在用于 com.sun.enterprise.deployment.util.ModuleContentValidator.accept 的 Web 服务 FileUploadService( ModuleContentValidator.java:187) 在 com.sun.enterprise.deployment.WebBundleDescriptor.visit(WebBundleDescriptor.java:1410) 在 com.sun.enterprise.deployment.archivist.WebArchivist.postOpen(WebArchivist.java:171) 在 com.sun .enterprise.deployment.archivist.Archivist.open(Archivist.java:215) 在 com.sun.enterprise.deployment.archivist.ApplicationArchivist.openArchive(ApplicationArchivist.java:813) 在 com.sun.enterprise.deployment.archivist.ApplicationArchivist .openArchive(ApplicationArchivist.java:794) 在 com.sun.enterprise.deployment.backend.Deployer。loadDescriptors(Deployer.java:365) ... 还有 10 个 |#]

4

2 回答 2

2

如果将 WSDL 文件放在 WEB-INF/wsdl/TestService.wsdl

你的代码应该是

@WebService(wsdlLocation="TestService.wsdl")

此外,您在日志中有一些内容表明

file:/C:/development/wexlink/FileUploadService/wsdl/FileUploadService.wsdl 不存在 Web 服务 FileUploadService

这似乎是硬编码在您的一个文件中进行文件扫描以确保您没有硬编码。

于 2010-09-10T02:04:32.333 回答
2

通常,你会把它放在 WEB-INF 的某个地方。然后,当您使用 wsdl2java 或 maven 插件生成代码时,您可以使用 WEB-INF/TestService.wsdl 或类似方法传入 -wsdlLocation 标志,以便将 get 生成到代码中。

也就是说,使用 CXF,在您的 jaxws:endpoint 配置中,您可以使用 jaxws:endpoint 上的属性覆盖 wsdlLocation 以指定类似“WEB-INF/TestService.wsdl”的内容。

于 2010-01-20T17:18:52.207 回答