我有一个使用Apache CXF生成和构建的Web服务客户端。接下来我有JAX-RS Jersey应用程序,我想从该webservice调用方法。当我尝试将这个简单的项目部署到Glassfish 4.0服务器时,我得到了这个例外:
Exception while deploying the app [pelijee] :
The lifecycle method [finalizeConfig] must not throw a checked exception.
Related annotation information: annotation [@javax.annotation.PostConstruct()] on annotated element [public void org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine.finalizeConfig() throws java.security.GeneralSecurityException,java.io.IOException] of type [METHOD]. Please see server.log for more details.
命令部署失败。
我在这个项目中唯一的CXF依赖是:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>2.7.6</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
是否还有其他与JSR 250兼容的CXF库? 谢谢
答案 0 :(得分:0)
Glassfish面临的挑战之一是整个服务器配置文件与Metro for JAX-WS Web服务和Jersey for JAX-RS休息服务一起打包。建议通过WAR的WEB-INF文件夹中包含的sun-web.xml文件配置类加载器。它应包括以下内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC
'-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN'
'http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd'>
<sun-web-app>
<class-loader delegate="false"/>
</sun-web-app>
过去,我发现偶尔会遇到部署问题;因此,我实际上已从Glassfish服务器配置文件中删除了Metro和Jersey功能。以下是有关部署的更多信息。
http://cxf.apache.org/docs/application-server-specific-configuration-guide.html
我注意到的另一件事是你发布了包含Jetty传输的日志消息。这意味着您正在运行Jetty HTTP服务器并运行Glassfish HTTP服务器。我建议只使用Glassfish作为Web服务器并使用CXF servlet传输。