How to deploy Apache CXF web service in Glassfish

I have a web service client generated and created using Apache CXF. Then I have a JAX-RS Jersey application in which I want to call methods from this web service. When I try to deploy this simple project to a Glassfish 4.0 server, I get this exception:

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. 

Unable to deploy commands.

The only CXF dependency that I have in this project is:

  <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-bundle-jaxrs</artifactId> <version>2.7.6</version> <type>jar</type> <scope>runtime</scope> </dependency> 

Is there any other CXF library compatible with JSR 250? thank you

+6
source share
1 answer

One of Glassfishโ€™s problems is that the full server profile comes bundled with Metro for the JAX-WS web services and Jersey for the JAX-RS leisure services. It is recommended that you configure the class loader through the sun-web.xml file included in the WEB-INF folder of your WAR. It should contain the following content:

 <?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> 

In the past, I found that sometimes I still have deployment problems; so I actually removed the Metro and Jersey features from the Glassfish server profile. Here is more deployment information.

http://cxf.apache.org/docs/application-server-specific-configuration-guide.html

Another thing that I noticed was that you sent a log message that included a Jetty transport. This means that you are using the Jetty HTTP server and starting the Glassfish HTTP server. I would suggest just using Glassfish as your web server and using CXF servlet porting instead.

0
source

Source: https://habr.com/ru/post/954755/


All Articles