Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pick CXF over Metro on Glassfish

I'm having the following problem (reported there by someone else) when running my enterprise application under Glassfish. Under Jetty it works fine.

javax/xml/ws/spi/Provider mentions creating a META-INF/services/javax.xml.ws.spi.Provider resource, but this is already supplied with CXF and creating an additional resource file does not solve this problem under Glassfish.

Does anyone know how to ensure that CXF is picked up under GlassFish?
(I'm using a Maven Multi-modules project with CXF dependency 2.2.5)

Thanks!
Tim


EDIT #1

Skipping the problem for now and just working with Metro, but I'd really like to know how to use CXF instead if anyone has any pointers.. If nothing works I might have to switch web application container (or look into Metro to fill my requirements)


EDIT #2

Some of the solutions detail the fix for war's by adding <class-loader delegate="false"/> to the sun-web.xml file. However, this does not work for non-war ee apps.

like image 821
Tim Avatar asked Jan 14 '10 12:01

Tim


2 Answers

Add a sun-web.xml and set delegate=false to the class-loader:

<?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> 
like image 167
Nightwolf Avatar answered Nov 14 '22 15:11

Nightwolf


The Metro (Glassfish's JAX-WS implementation) jars are probably being included with Glassfish, can you exclude them from the classpath? Since you're using maven, you should analyze the glassfish dependencies and using an exclusion for the metro jars.


It seems that you need to have the CXF jars on the applications classpath before the Metro jars. You probably can't modify the system classloader/classpath but you can change the Thread.currentThread().getContextClassLoader() such that it loads CXF first. There also might a classpath settings in Glassfish you can modify

Check out the source for javax.xml.ws.spi.FactoryFinder#find() to see how the provider is actually loaded

like image 41
Kevin Avatar answered Nov 14 '22 16:11

Kevin