´The Oracle OC4J is based on the Orion Application Server source and still has some problems from the origin. I tested to deploy a little Apache CXF Annotation based Webservice into OC4J 10.1.3.4.0 with Eclipse WTP. Add in the Servers view a new local server from type “Oracle OC4J Standalone Server 10.1.3.n” and add the Web Application to this new J2EE container. When i start the server i got:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: oracle.xml.parser.v2.DTD cannot be cast to org.w3c.dom.Element Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: oracle.xml.parser.v2.DTD cannot be cast to org.w3c.dom.Element Caused by: java.lang.ClassCastException: oracle.xml.parser.v2.DTD cannot be cast to org.w3c.dom.Element at java.util.XMLUtils.load(XMLUtils.java:61) at java.util.Properties.loadFromXML(Properties.java:852) at org.apache.cxf.common.util.PropertiesLoaderUtils.loadAllProperties(PropertiesLoaderUtils.java:71) at org.apache.cxf.wsdl11.WSDLManagerImpl.registerInitialExtensions(WSDLManagerImpl.java:226) at org.apache.cxf.wsdl11.WSDLManagerImpl.registerInitialExtensions(WSDLManagerImpl.java:221) at org.apache.cxf.wsdl11.WSDLManagerImpl.
XML Parsing is done in Java based applications by a JAXP compliant Parser. The first Parser in the classpath sequence of jars wins and is used by all java classes of a application. Default for OC4J is to provide the Oracle XML Parser, which is a bit old. The solution is to force OC4J to use my JAXP Parser instead of the container Default Parser defined in the shared libraries.
My CXF Web Project is maven based. First thing to do is to add a new maven dependency to xerces 2.9.1 as JAXP Parser to use for CXF.
apache-xerces xercesImpl 2.9.1 jar compile
So create with ‘mvn package’ a war file in the target directory.
I removed the CXF Application from the OC4J Container inside the servers view in eclipse and start the OC4J server. Now log in the admin web console with
Go to Applications and click on the deploy button. Select on the first screen the WAR file as local archive location. Enter on the second screen a application name and change the context path to your needs. Click on the third screen on the link to change your class loading. Remove all imported shared libraries and click on the checkbox below for “Search first locally for classes”. Click ok to go back to the third screen and click on deploy to start progress. Now it will successfully start the Application and you can see e.g. all deployed webservices with
Keep in mind to adopt the context path “cxf-sample” of the url to your needs.