<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ralf Schäftlein&#039;s Blog &#187; cxf</title>
	<atom:link href="http://ralf.schaeftlein.de/tag/cxf/feed/" rel="self" type="application/rss+xml" />
	<link>http://ralf.schaeftlein.de</link>
	<description>tech stuff, talk,...</description>
	<lastBuildDate>Sat, 27 Mar 2010 11:24:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>OC4J and JAXP Parser conflicts</title>
		<link>http://ralf.schaeftlein.de/2008/11/21/oc4j-and-jaxp-parser-conflict/</link>
		<comments>http://ralf.schaeftlein.de/2008/11/21/oc4j-and-jaxp-parser-conflict/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 11:08:44 +0000</pubDate>
		<dc:creator>ralf</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[jaxp]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[oc4j]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=56</guid>
		<description><![CDATA[´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 &#8220;Oracle OC4J Standalone Server 10.1.3.n&#8221; and add the [...]]]></description>
			<content:encoded><![CDATA[<p>´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 &#8220;Oracle OC4J Standalone Server 10.1.3.n&#8221; and add the Web Application to this new J2EE container. When i start the server i got:</p>
<pre name="code" class="java">
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.<init>(WSDLManagerImpl.java:110)
</pre>
<p>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.</p>
<p>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.</p>
<pre name="code" class="xml">
		<dependency>
			<groupId>apache-xerces</groupId>
			<artifactId>xercesImpl</artifactId>
			<version>2.9.1</version>
			<type>jar</type>
			<scope>compile</scope>
		</dependency>
</pre>
<p>So create with &#8216;mvn package&#8217; a war file in the target directory.</p>
<p>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</p>
<p><a href="http://localhost:8888/em/console/ias/oc4j/home">http://localhost:8888/em/console/ias/oc4j/home</a></p>
<p> 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 &#8220;Search first locally for classes&#8221;. 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 </p>
<p><a href="http://localhost:8888/cxf-sample/">http://localhost:8888/cxf-sample/</a></p>
<p>Keep in mind to adopt the context path &#8220;cxf-sample&#8221; of the url to your needs.</p>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2008/11/21/oc4j-and-jaxp-parser-conflict/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache cxf 2.1 with spring 2, maven 2 and eclipse wtp</title>
		<link>http://ralf.schaeftlein.de/2008/05/04/apache-cxf-21-with-spring-2-maven-2-and-eclipse-wtp/</link>
		<comments>http://ralf.schaeftlein.de/2008/05/04/apache-cxf-21-with-spring-2-maven-2-and-eclipse-wtp/#comments</comments>
		<pubDate>Sun, 04 May 2008 14:38:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[cxf]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[webservices]]></category>
		<category><![CDATA[wtp]]></category>

		<guid isPermaLink="false">http://ralf.schaeftlein.de/?p=11</guid>
		<description><![CDATA[Apache CXF 2.1 is released. I know XFire since a long time as web service provider. CXF is a merger of XFire with celtix, which provided an enterprise service bus. The main reason for choosing XFire rather then Axis was the WS-I BP compatibility. It&#8217;s a better arguing with a commercial eai provider when your [...]]]></description>
			<content:encoded><![CDATA[<p>Apache CXF 2.1 is <a href="http://cxf.apache.org/" target="_blank">released</a>. I know <a href="http://xfire.codehaus.org/" target="_blank">XFire</a> since a long time as web service provider.  CXF is a merger  of XFire with <a href="http://celtix.objectweb.org/" target="_blank">celtix</a>, which provided an enterprise service bus. The main reason for choosing XFire rather then Axis was the <a href="http://www.ws-i.org/" target="_blank">WS-I</a> BP compatibility. It&#8217;s a better arguing with a commercial eai provider when your webservice is at least WS-I BP 1.0 conform.  CXF is <a href="http://java.sun.com/webservices/technologies/index.jsp" target="_blank">JAX-WS 2.1</a> compatible. You can enable Pojo services with standard annotations as web services. To try that new release out i created with eclipse <a href="http://www.eclipse.org/webtools/" target="_blank">web tools platform</a> a new dynamic web project with <a href="http://tomcat.apache.org/" target="_blank">tomcat</a> 6 as web container.  First step is to add the libs needed for CXF. Normally i would download by myself the libs and copy it in to Web-inf/lib folder. Disk space is not a problem but you can&#8217;t share such projects by mail because of the size needed for the libs. So i use <a href="http://maven.apache.org/" target="_blank">maven 2</a> to define the needed libs.  The pom.xml define the project and its dependencies. Place it in the root of the project:</p>
<pre name="code" class="xml">
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                       http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<modelVersion>4.0.0</modelVersion>
	<groupId>de.schaeftlein.dev</groupId>
	<artifactId>cxf-sample</artifactId>
<packaging>war</packaging>
	<name>
	</name>
	<version>0.0.1-SNAPSHOT</version>
	<description>
	</description>
	<dependencies>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-core</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-simple</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-databinding-aegis</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-local</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-http-jetty</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-transports-jms</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-management</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-common-utilities</artifactId>
			<version>2.1</version>
		</dependency>
		<dependency>
			<groupId>org.mortbay.jetty</groupId>
			<artifactId>jetty</artifactId>
			<version>6.1.6</version>
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>3.8.2</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring</artifactId>
			<version>2.0.8</version>
		</dependency>
	</dependencies>
	<build>
<plugins>
<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
		<defaultGoal>war:install</defaultGoal>
	</build>
</project>
</pre>
<p>So the libs are defined but nothing happened in eclipse. I use the <a href="http://m2eclipse.codehaus.org/" target="_blank">M2</a> Eclipse plugin. Now i enable maven with right click on the project and choose from M2 the &#8220;Enable dependency management&#8221; entry.  The plugin now download the libs into the local repository for all projects. In the eclipse build path you will find now a new library called &#8220;maven dependencies&#8221;. Eclipse WTP does not deploy out of the box this library. Inside the project configuration you will find a section called &#8220;j2ee module dependencies&#8221;. Just click the check box beside the &#8220;maven dependencies&#8221; library. Now all dependent libs are deployed as well.  As controller act the CXFServlet and for spring need a listener to be defined both in the web.xml:</p>
<pre name="code"  class="xml">
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>cxf-sample</display-name>
	<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/beans.xml</param-value>
	</context-param>
<listener>
<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>

	<servlet>
		<servlet-name>CXFServlet</servlet-name>
		<servlet-class>
			org.apache.cxf.transport.servlet.CXFServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>CXFServlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</servlet-mapping>
</web-app>
</pre>
<p>I use <a href="http://springframework.org/" target="_blank">spring</a> as main configuration tool. CXF depends on spring 2.0.8. The beans.xml imports the default cxf settings and defines the HelloWorld service:</p>
<p>The web service has a interface:</p>
<pre name="code"  class="java">package demo.spring;

import javax.jws.WebService;

@WebService
public interface HelloWorld {
    String sayHi(String text);
}</pre>
<p>and a implementation:</p>
<pre name="code"  class="java">package demo.spring;

import javax.jws.WebService;

@WebService(endpointInterface = "demo.spring.HelloWorld")
public class HelloWorldImpl implements HelloWorld {

    public String sayHi(String text) {
        return "Hello " + text;
    }
}</pre>
<p>If not set up a local server during creation of the project you need to go to the servers tab in eclipse. Define a new server with server type &#8220;Tomcat v6.0 Server&#8221;. If the adapter does not appear click on the link to &#8220;download additional server adapters&#8221;. Under &#8220;installed runtime&#8221; should be a tomcat 6 server. If not you have to add a new runtime. For tomcat 6 i recommend at least java 1.5 as jre.  In the last step you can  directly add the  created project  for cxf.  Spring and CXF use commons logging for logging. So i provide in the classpath a simple log4j.xml to output everything interesting to std out:</p>
<pre name="code" class="xml">
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
	<appender name="ConsoleAppender"
		class="org.apache.log4j.ConsoleAppender">
		<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
				value="%d{ISO8601} %-5p %c - %m%n" />
		</layout>
	</appender>
	<category name="demo.spring">
<priority value="debug" />
	</category>
	<root>
<priority value="info" />
		<appender-ref ref="ConsoleAppender" />
	</root>
</log4j:configuration>
</pre>
<p>Setup and implementation are now done. So i started the server inside eclipse. The console should contains lines from spring configuring cxf.  To see  a list of deployed web services  just open a browser to http://localhost:8080/cxf-sample/services, where cxf-sample is the name of your eclipse project. You should see a list of links to the generated wsdl&#8217;s of the defined services. Copy the url to the HelloWorldImplPort in the clipboard.  For testing i use the free tool <a href="http://www.soapui.org/" target="_blank">soapui</a> which will be started and installed by <a href="http://www.soapui.org/jnlp/2.0.2/soapui.jnlp" target="_blank">webstart</a>. Choose under file the point &#8220;new wsdl project&#8221;. Give it a name and paste the url from the wsdl. Leave the tack for creating sample requests and choose ok. In the tree you see the project, the service, the operations and a request for each operation. Double Click on the only request for our service.  Replace the ? with a value of your own inside the arg0 tag and hit the green run button:</p>
<pre name="code"  class="xml">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:spr="http://spring.demo/">
   <soapenv:Header/>
   <soapenv:Body>
      <spr:sayHi>
         <!--Optional:-->
         <!--type: string-->
         <arg0>John Doe</arg0>
      </spr:sayHi>
   </soapenv:Body>
</soapenv:Envelope>
</pre>
<p>You should see a response like that on right side of the request in a new window:</p>
<pre name="code"  class="xml">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:sayHiResponse xmlns:ns2="http://spring.demo/">
         <return>Hello John Doe</return>
      </ns2:sayHiResponse>
   </soap:Body>
</soap:Envelope>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ralf.schaeftlein.de/2008/05/04/apache-cxf-21-with-spring-2-maven-2-and-eclipse-wtp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
