<?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>Olaf&#039;s blog &#187; java</title>
	<atom:link href="http://olafsblog.sysbsb.de/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://olafsblog.sysbsb.de</link>
	<description>Olaf&#039;s blog on software development and life</description>
	<lastBuildDate>Thu, 18 Nov 2010 07:57:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Testing SSL (HTTPS) clients with Junit and Jetty</title>
		<link>http://olafsblog.sysbsb.de/testing-ssl-https-clients-with-junit-and-jetty/</link>
		<comments>http://olafsblog.sysbsb.de/testing-ssl-https-clients-with-junit-and-jetty/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 07:54:17 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven 2]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[unit test]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=124</guid>
		<description><![CDATA[I recently ran into a situation where a web service client had issues when invoking a webservice via HTTPS. To reproduce, I needed a lightweight, JUnit-based test to reproduce the problem and write a regression test. Here is how I got it to work:
First, I used the basic HTTP test setup. Now however, I needed [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into a situation where a web service client had issues when invoking a webservice via HTTPS. To reproduce, I needed a lightweight, JUnit-based test to reproduce the problem and write a regression test. Here is how I got it to work:</p>
<p>First, I used the <a href="/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/">basic HTTP test setup</a>. Now however, I needed Jetty to provide a HTTPS connector. For this to work, Jetty &#8211; just like any other webserver, such as <a href="http://httpd.apache.org/docs/2.2/ssl/">apache</a> &#8211; needs a server certificate and a private key in a keystore. To create the keystore, I simply followed the excellent <a href="http://docs.codehaus.org/display/JETTY/How+to+configure+SSL">Jetty SSL guide</a>. Namingly, I did this (using Ubuntu, see the above link for alternatives):</p>
<pre class="brush: plain;">
openssl genrsa -des3 -out jetty.key
openssl req -new -x509 -key jetty.key -out jetty.crt
openssl pkcs12 -inkey jetty.key -in jetty.crt -export -out jetty.pkcs12
$JAVA_HOME/bin/keytool -importkeystore -srckeystore jetty.pkcs12 -srcstoretype PKCS12 -destkeystore keystore
</pre>
<p>Once I had the keystore set up, I placed it in the src/main/resources folder (the root of the classpath, in case you&#8217;re not a maven user) and extended the HttpTestServer like so:</p>
<pre class="brush: java;">
import java.net.URL;

import org.junit.Ignore;
import org.mortbay.jetty.Connector;
import org.mortbay.jetty.security.SslSocketConnector;

/**
 * A test server for testing SSL requests.
 *
 * @author Olaf Otto
 */
@Ignore
public class SslTestServer extends HttpTestServer {
	private static final int HTTPS_PORT = 50443;

	public SslTestServer() {
	}

	public SslTestServer(String mockData) {
		super(mockData);
	}

	@Override
	protected void configureServer() {
		super.configureServer();
		Connector secureConnector = createSecureConnector();
		getServer().addConnector(secureConnector);
	}

	private Connector createSecureConnector() {
		SslSocketConnector connector = new SslSocketConnector();
		connector.setPort(HTTPS_PORT);
		URL keystoreUrl = getClass().getClassLoader().getResource(&quot;keystore&quot;);
		connector.setKeystore(keystoreUrl.getFile());
		connector.setKeyPassword(&quot;test&quot;);
		return connector;
	}

	public static void main(String[] args) {
		SslTestServer server = new SslTestServer();
		try {
			server.start();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
</pre>
<p>(I added the @Ignore annotation as I placed the class in the test sources folder, though it&#8217;s not a test&#8230;)<br />
You might use it in your JUnit-based test like so:</p>
<pre class="brush: java;">
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Olaf Otto
 */
public class MySslTest {
	private SslTestServer _server;

	@Before
	public void startServer() throws Exception {
		_server = new SslTestServer();
		_server.start();
	}

	@After
	public void stopServer() throws Exception {
		_server.stop();
	}

	@Test
	public void mySsltest() {
		_server.setMockResponseData(&quot;&lt;xml&gt;My client expects this response&lt;/xml&gt;&quot;);
		// Perform tests on port 50443...
	}
}
</pre>
<p>Here is <a href="http://olafsblog.sysbsb.de/wp-content/uploads/2010/07/https-testserver.zip">the whole package as a maven 2 project</a> (including the keystore with a self-signed certificate). Download, unzip, and give it a try (<code>mvn test</code>).</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/testing-ssl-https-clients-with-junit-and-jetty/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lightweight testing of (webservice) HTTP clients with JUnit and Jetty</title>
		<link>http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/</link>
		<comments>http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 07:48:01 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven 2]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[http clients]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[test]]></category>
		<category><![CDATA[webservices]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=133</guid>
		<description><![CDATA[If you&#8217;re working with webservice clients you will certainly have noticed the complexity of integration-testing your webservice clients. Building webservice clients can already be quite a complex task, but providing a mock-up webservice backend delivering useful test responses is quite often just to much work, if not impossible, since many web service backends are very [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re working with webservice clients you will certainly have noticed the complexity of integration-testing your webservice clients. Building webservice clients can already be quite a complex task, but providing a mock-up webservice backend delivering useful test responses is quite often just to much work, if not impossible, since many web service backends are very complex constructs. Furthermore, setting up a backend for each integration test consumes valuable build time.</p>
<p>As an alternative, one may simply replace the backend with a mock HTTP server that does one thing: deliver the <em>expected webserver response</em> &#8211; i.e. XML data  &#8211; when called by the client. All you need to set this up is a HTTP server and a pre-recorded service response (quite often this comes with WS client specifications). If you don&#8217;t have this data, you can record it, for example using a proxy server in between your WS client and a real WS backend, or a tool such as <a href="http://www.wireshark.org/">wireshark</a>.</p>
<p>The recorded XML response thus represents your assumptions against which you test the client. This makes your tests fast, lightweight and a lot better to understand. </p>
<p>Here is my Jetty-based test HTTP server:</p>
<pre class="brush: java;">
package de.sysbsb.test;

import static javax.servlet.http.HttpServletResponse.SC_OK;
import static org.apache.commons.io.IOUtils.write;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.junit.Ignore;
import org.mortbay.jetty.Handler;
import org.mortbay.jetty.HttpConnection;
import org.mortbay.jetty.Request;
import org.mortbay.jetty.Server;
import org.mortbay.jetty.handler.AbstractHandler;

/**
 * A server for answering HTTP requests with test response data.
 *
 * @author Olaf Otto
 */
@Ignore
public class HttpTestServer {
	public static final int HTTP_PORT = 50036;

	private Server _server;
	private String _responseBody;
	private String _requestBody;
	private String _mockResponseData;

	public HttpTestServer() {
	}

	public HttpTestServer(String mockData) {
		setMockResponseData(mockData);
	}

	public void start() throws Exception {
		configureServer();
		startServer();
	}

	private void startServer() throws Exception {
		_server.start();
	}

	protected void configureServer() {
		_server = new Server(HTTP_PORT);
		_server.setHandler(getMockHandler());
	}

	/**
	 * Creates an {@link AbstractHandler handler} returning an arbitrary String as a response.
	 *
	 * @return never &lt;code&gt;null&lt;/code&gt;.
	 */
	public Handler getMockHandler() {
		Handler handler = new AbstractHandler() {

			public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch) throws IOException, ServletException {
				Request baseRequest = request instanceof Request ? (Request) request : HttpConnection.getCurrentConnection().getRequest();
				setResponseBody(getMockResponseData());
				setRequestBody(IOUtils.toString(baseRequest.getInputStream()));
				response.setStatus(SC_OK);
				response.setContentType(&quot;text/xml;charset=utf-8&quot;);
				write(getResponseBody(), response.getOutputStream());
				baseRequest.setHandled(true);
			}
		};
		return handler;
	}

	public void stop() throws Exception {
		_server.stop();
	}

	public void setResponseBody(String responseBody) {
		_responseBody = responseBody;
	}

	public String getResponseBody() {
		return _responseBody;
	}

	public void setRequestBody(String requestBody) {
		_requestBody = requestBody;
	}

	public String getRequestBody() {
		return _requestBody;
	}

	public static void main(String[] args) {
		HttpTestServer server = new HttpTestServer();
		try {
			server.start();
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	public void setMockResponseData(String mockResponseData) {
		_mockResponseData = mockResponseData;
	}

	public String getMockResponseData() {
		return _mockResponseData;
	}

	protected Server getServer() {
		return _server;
	}
}
</pre>
<p>You can use it in a JUnit test like so:</p>
<pre class="brush: java;">
package de.sysbsb.test;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * @author Olaf Otto
 */
public class MyClientTest {
	private HttpTestServer _server;

	@Before
	public void startTestServer() throws Exception {
		_server = new HttpTestServer();
		_server.start();
	}

	@After
	public void stopTestServer() throws Exception {
		_server.stop();
	}

	@Test
	public void someClientTest() throws IOException {
		_server.setMockResponseData(&quot;&lt;xml&gt;&lt;testdata&gt;hello, world&lt;/testdata&gt;&lt;/xml&gt;&quot;);
		// or as a much more elegant alternative:
		_server.setMockResponseData(getRecordedResponse(&quot;testdata.xml&quot;));
		// run your client tests, using the HttpTestServer.HTTP_PORT
	}

	private String getRecordedResponse(String recordedResponseFile) throws IOException {
		InputStream testDataStream = getClass().getClassLoader().getResourceAsStream(recordedResponseFile);
		return IOUtils.toString(testDataStream);
	}
}
</pre>
<p><a href="http://olafsblog.sysbsb.de/wp-content/uploads/2010/07/http-testserver.zip">Here are is the HTTP test server and a JUnit test example as a maven 2 project</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/lightweight-testing-of-webservice-http-clients-with-junit-and-jetty/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Obtaining the default charset (aka platform encoding) in JAVA</title>
		<link>http://olafsblog.sysbsb.de/obtaining-the-default-charset-aka-platform-encoding-in-java/</link>
		<comments>http://olafsblog.sysbsb.de/obtaining-the-default-charset-aka-platform-encoding-in-java/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 10:57:09 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Charset]]></category>
		<category><![CDATA[Platform encoding]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/obtaining-the-default-charset-aka-platform-encoding-in-java/</guid>
		<description><![CDATA[&#8230; is really simple since JDK 1.5:

java.nio.charset.Charset.defaultCharset()

So please don&#8217;t use messy, old workarounds such as this:

byte [] byteArray = {'a'};
InputStream inputStream = new ByteArrayInputStream(byteArray);
InputStreamReader reader = new InputStreamReader(inputStream);
String defaultEncoding = reader.getEncoding();

Which, unfortunately, is one of the first things you stumble upon when searching for this topic.
]]></description>
			<content:encoded><![CDATA[<p>&#8230; is really simple since JDK 1.5:</p>
<pre class="brush: java;">
java.nio.charset.Charset.defaultCharset()
</pre>
<p>So please don&#8217;t use messy, old workarounds such as this:</p>
<pre class="brush: java;">
byte [] byteArray = {'a'};
InputStream inputStream = new ByteArrayInputStream(byteArray);
InputStreamReader reader = new InputStreamReader(inputStream);
String defaultEncoding = reader.getEncoding();
</pre>
<p>Which, unfortunately, is one of the first things you stumble upon when searching for this topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/obtaining-the-default-charset-aka-platform-encoding-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using RPC-style, encoded Axis 1 webservices with spring-remoting</title>
		<link>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/</link>
		<comments>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 20:16:55 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[Axis 1]]></category>
		<category><![CDATA[Jax-ws]]></category>
		<category><![CDATA[Spring-Remoting]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=76</guid>
		<description><![CDATA[Preamble
When working with enterprise integration you will quite often deal with the integration of legacy systems.
I was recently tasked with the integration of webservices and much to my surprise there are huge issues when attempting to integrate old webservices (i.e. pre axis-2 and pre jax-ws webservices).
These webservices use outdated or unsupported methods, such as rpc-style/encoded [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>When working with enterprise integration you will quite often deal with the integration of legacy systems.</p>
<p>I was recently tasked with the integration of webservices and much to my surprise there are huge issues when attempting to integrate old webservices (i.e. pre axis-2 and pre jax-ws webservices).</p>
<p>These webservices use outdated or unsupported methods, such as <a href="http://ws.apache.org/axis2/1_2/Axis2-rpc-support.html">rpc-style/encoded</a> communication, or even worce, outdated elements in the XML messages, for instance &lt;multiref&gt;&#8217;s. Having to integrate such services of course implies that you cannot change anything on the server side, and thus the outdated format must still be consumed by your webservice client.<br />
This however is a huge problem, since the current WS implementations, such as the popular axis2 framework, do simply not support these outdated formats.</p>
<p>What surprised me the most about this is that webservices are designed to make systems independent by defining a common communication and data format, which is the exact opposite of what is going on here &#8211; and these formats are not that old, actually, they where pretty common just about 5 years ago.</p>
<p>Developers facing these issues are taking rather desperate measures to work around these problems, such as <a href="http://www.jroller.com/0xcafebabe/entry/migrating_smoothly_from_rpc_encoded">using on-the-fly XSLT transformation to convert incoming and outgoing WS messages</a>. However, this binds your application even stronger to the outdated format and specific service data.</p>
<p>In my case I wanted to use <a href="http://static.springsource.org/spring/docs/2.5.x/reference/remoting.html">Spring-remoting</a>. Since the service was RPC-style, I wanted to use the <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/remoting/jaxrpc/JaxRpcPortProxyFactoryBean.html">JaxRpcPortProxyFactoryBean</a> to create an on-the-fly proxy implementing the service interface. What I did not want to do is having to write any additional code to consume the service. Furthermore, I wanted the complex objects transferred by the services to be represented by standard JAVA beans, and not be generated using the wsdl2java axis1 tools since they contain a lot of ugly dependencies. Here is how I got this to work.<br />
<span id="more-76"></span></p>
<h2>Using Spring-remoting&#8217;s jax-rpc support with axis 1</h2>
<h3>Required maven dependencies</h3>
<p>First, I was willing to make the compromise of having axis1 on my classpath. This might not be the way to go for everyone, unless you are using an OSGI framework, which was not an option in my case. Using jax-rpc with axis1 from spring requires the following dependencies (I am using <a href="http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html">maven&#8217;s dependency management</a> for the sake of simplicity):</p>
<pre class="brush: xml;">
&lt;dependency&gt;
  &lt;groupId&gt;commons-io&lt;/groupId&gt;
  &lt;artifactId&gt;commons-io&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;commons-discovery&lt;/groupId&gt;
  &lt;artifactId&gt;commons-discovery&lt;/artifactId&gt;
  &lt;version&gt;0.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis-jaxrpc&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.apache.axis&lt;/groupId&gt;
  &lt;artifactId&gt;axis-saaj&lt;/artifactId&gt;
  &lt;version&gt;1.4&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;wsdl4j&lt;/groupId&gt;
  &lt;artifactId&gt;wsdl4j&lt;/artifactId&gt;
  &lt;version&gt;1.6.2&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
  &lt;version&gt;2.5.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.springframework&lt;/groupId&gt;
  &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
  &lt;version&gt;2.5.6&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;cglib&lt;/groupId&gt;
  &lt;artifactId&gt;cglib-nodep&lt;/artifactId&gt;
  &lt;version&gt;2.2&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>Note that this setup is for JDK 1.5. JDK 1.6 ships with quite a lot of jax-ws libraries, so you might want to check whether all of these dependencies are still required when using 1.6, but they might.</p>
<h3>Configuring the service using the port proxy factory bean</h3>
<p>First, I downloaded the WSDL&#8217;s from the services and placed them within my src/main/resources folder to use them offline. This is not required, but I do recommend it. The Next step was to set up the factory beans for jax-rpc in order to let Spring generate implementations of my service interfaces:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;

  &lt;bean id=&quot;myWebService&quot; class=&quot;org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean&quot;&gt;
    &lt;property name=&quot;serviceInterface&quot; value=&quot;my.package.MYServiceInterface&quot; /&gt;
    &lt;property name=&quot;wsdlDocumentUrl&quot; value=&quot;classpath:path/to/my/wsdl.swdl&quot; /&gt;
    &lt;property name=&quot;namespaceUri&quot; value=&quot;namespace/as/defined/in/wsdl&quot; /&gt;
    &lt;property name=&quot;serviceName&quot; value=&quot;ServiceNameFromWsdl&quot; /&gt;
    &lt;property name=&quot;portName&quot; value=&quot;PortNameFromWsdl&quot; /&gt;
    &lt;property name=&quot;servicePostProcessors&quot;&gt;
      &lt;list&gt;
        &lt;!--
          This is for mapping your POJO's to the complex service objects (if you are using any).
          You can use an arbitrary number of mapping &lt;bean&gt; configurations for every model
          namespace of your WSDL.
        --&gt;
        &lt;bean
          class=&quot;org.springframework.remoting.jaxrpc.support.AxisBeanMappingServicePostProcessor&quot;&gt;
	  &lt;!-- encoding style as in WSDL, in my case the outdated soap/encoding --&gt;
          &lt;property name=&quot;encodingStyleUri&quot; value=&quot;http://schemas.xmlsoap.org/soap/encoding/&quot; /&gt;
          &lt;property name=&quot;typeNamespaceUri&quot; value=&quot;namespace/for/models/as/defined/in/wsdl&quot; /&gt;
          &lt;property name=&quot;beanMappings&quot;&gt;
            &lt;props&gt;
              &lt;prop key=&quot;my.package.MyPojo&quot;&gt;ModelNameInWsdl&lt;/prop&gt;
            &lt;/props&gt;
          &lt;/property&gt;
        &lt;/bean&gt;
      &lt;/list&gt;
    &lt;/property&gt;
  &lt;/bean&gt;
&lt;/beans&gt;
</pre>
<p>If the service specifies an operation such as <code>ComplexResponseVO getResults(ComplexRequestVO)</code>, you would thus define an interface like so:</p>
<pre class="brush: java;">
public interface MyService {
     MyResponsePojo getResults(MyRequestPojo);
}
</pre>
<p>And map the <code>MyResponsePojo</code> and <code>MyRequestPojo</code> using the AxisBeanMappingServicePostProcessor in the above spring configuration. Spring will serialize and deserialize the pojos using standard getter and setter methods to obtain the values, thus you do not have to care for serialization or marshalling. In fact, your pojos do not even have to be Serializable.</p>
<p>Once you have this stuff up and running, you can inject the <code>MyService</code> implementation into any other spring bean and use it like any other bean. Spring will convert the usually annoying and unrecoverable RemoteExceptions into unchecked remote exceptions, thus if you want to handle these, catching <a href="http://static.springsource.org/spring/docs/2.5.6/api/org/springframework/remoting/RemoteAccessException.html">remote access exceptions</a> is recommended.</p>
<p>Using an interface as the service representation has the additional advantage that it is pretty easy to <a href="http://www.martinfowler.com/bliki/SelfInitializingFake.html">fake or mock the service for integration testing</a>.</p>
<h3>Handling uppercase data type attributes</h3>
<p>Legacy services sometimes violate the JAVA standards of good coding and specify uppercase attribute names for their data types. This is like writing</p>
<pre class="brush: java;">
public class MyService {
     private SomeType MyFieldName;
     ...
}
</pre>
<p>And thus pretty ugly. When using spring&#8217;s <code>JaxRpcPortProxyFactoryBean</code> things are getting a lot worce: the <code>BeanDeserializer</code> will look for a getter/setter pair (aka &#8220;property&#8221;) to set a value obtained from the Webservice. Such a property must, by specification, start with a lowercase letter. However, in case of an uppercase attribute in the webservice, the Beandeserializer will look for an uppercase property &#8211; and will never find it. In example you&#8217;d have a getter/setter pair <code>getMyfieldName() / setMyFieldName()</code> that translates to the java beans property &#8220;myFieldName&#8221;, however the deserializer will look for a &#8220;MyFieldName&#8221; property. <a href="http://issues.apache.org/jira/browse/AXIS-1761">This is a known issue in Axis 1.x</a>, and there is no fix released for it (and most likely there will never be one). </p>
<p>I solved the problem by providing a subclass of the <code>org.apache.axis.encoding.ser.BeanDeserializer</code> to the <code>JaxRpcPortProxyFactoryBean</code> using a subclassed <code>AxisBeanMappingServicePostProcessor</code> and a customized <code>BeanDeserializerFactory</code>:</p>
<pre class="brush: xml;">
&lt;bean id=&quot;myWebService&quot; class=&quot;org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean&quot;&gt;
...
  &lt;property name=&quot;servicePostProcessors&quot;&gt;
    &lt;list&gt;
      &lt;bean class=&quot;my.package.MyServicePostProcessor&quot;&gt;
      ....
</pre>
<p>Here is the sourcecode for this post processor, the deserializer factory and deserializer:</p>
<h4>The post processor:</h4>
<pre class="brush: java;">
package my.package;

import javax.xml.namespace.QName;
import javax.xml.rpc.encoding.TypeMapping;

import org.apache.axis.encoding.ser.BeanSerializerFactory;
import org.springframework.remoting.jaxrpc.support.AxisBeanMappingServicePostProcessor;

/**
 * This {@link AxisBeanMappingServicePostProcessor} registers a
 * {@link MyBeanDeserializerFactory} during
 * {@link #registerBeanMapping(TypeMapping, Class, QName) mapping registration}.
 *
 * @author Olaf Otto
 */
public class MyServicePostProcessor extends AxisBeanMappingServicePostProcessor {

  /**
   * Registers the {@link MyBeanDeserializer} for the given mapping.
   */
  @Override
  @SuppressWarnings(&quot;unchecked&quot;)
  protected void registerBeanMapping(TypeMapping mapping, Class javaType, QName wsdlType) {
    mapping.register(javaType, wsdlType, new BeanSerializerFactory(javaType, wsdlType), new MyBeanDeserializerFactory(javaType, wsdlType));
  }
}
</pre>
<h4>The deserializer factory:</h4>
<pre class="brush: java;">
package my.package;

import javax.xml.namespace.QName;

import org.apache.axis.encoding.Deserializer;
import org.apache.axis.encoding.ser.BeanDeserializerFactory;
import org.apache.axis.encoding.ser.EnumDeserializer;

/**
 * This {@link BeanDeserializerFactory} provides a {@link #getGeneralPurpose(String) general-purpose}
 * deserializer {@link MyBeanDeserializer capable of handling local names not conforming to the java beans spec}.
 *
 * @author Olaf Otto
 */
public class MyBeanDeserializerFactory extends BeanDeserializerFactory {
  private static final long serialVersionUID = -8880103201020594221L;

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializerFactory(Class javaType, QName xmlType) {
    super(javaType, xmlType);
  }

  /**
   * Returns either:
   * &amp;lt;ol&amp;gt;
   *       &amp;lt;li&amp;gt;
   *           The super types general-purpose deserializer if the target type or
   *           the XML type is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; or the pre-defined deserializer class
   *           is an {@link EnumDeserializer}
   *      &amp;lt;/li&amp;gt;

   *      &amp;lt;li&amp;gt;A {@link MyBeanDeserializer} otherwise (standard case)&amp;lt;/li&amp;gt;
   * &amp;lt;/ol&amp;gt;
   *
   *  @return never &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;, rather throws a {@link RuntimeException}.
   */
  @Override
  protected Deserializer getGeneralPurpose(String mechanismType) {
    Deserializer deserializer;
    if (javaType == null || xmlType == null || deserClass == org.apache.axis.encoding.ser.EnumDeserializer.class) {
      deserializer = super.getGeneralPurpose(mechanismType);
    } else {
      deserializer = new MyBeanDeserializer(javaType, xmlType, typeDesc, propertyMap);
    }
    return deserializer;
  }
}
</pre>
<h4>The deserializer:</h4>
<pre class="brush: java;">
package my.package;

import static org.springframework.util.Assert.hasText;

import java.util.Map;

import javax.xml.namespace.QName;

import org.apache.axis.description.TypeDesc;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.ser.BeanDeserializer;
import org.apache.axis.message.SOAPHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

/**
 * This {@link BeanDeserializer} takes care of non-normal local names,
 * i.e. local names starting with an uppercase character.&amp;lt;br /&amp;gt;
 * Such a local name, usually derived from a WSDL description, will
 * lead to a property lookup for a getter/setter pair on the target bean of the deserialization
 * with an uppercase name start. However, all property names start with a lowercase character
 * according to the java beans spec, thus a property with an upper case name start
 * is never found, causing the deserialization to fail.&amp;lt;br /&amp;gt;
 *
 * @author Olaf Otto
 */
public class MyBeanDeserializer extends BeanDeserializer {
  private static final long serialVersionUID = 1183255594948119370L;

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc, Map propertyMap) {
    super(javaType, xmlType, typeDesc, propertyMap);
  }

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType, TypeDesc typeDesc) {
    super(javaType, xmlType, typeDesc);
  }

  @SuppressWarnings(&quot;unchecked&quot;)
  public MyBeanDeserializer(Class javaType, QName xmlType) {
    super(javaType, xmlType);
  }

  /**
   * {@link #normalizeLocalName(String) normalizes} the localName and invokes
   * {@link BeanDeserializer#onStartChild(String, String, String, Attributes, DeserializationContext)}.
   */
  @Override
  public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes1, DeserializationContext deserializationcontext) throws SAXException {
    String normalizedLocalName = normalizeLocalName(localName);
    return super.onStartChild(namespace, normalizedLocalName, prefix, attributes1, deserializationcontext);
  }

  /**
   * Converts the first character of the local name to
   * {@link Character#toLowerCase(char) lower case}, if it is
   * {@link Character#isUpperCase(char) upper case}.
   *
   * @param localName must not be &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; and not empty.
   * @return The normalized local name, never &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt;.
   */
  public String normalizeLocalName(String localName) {
    hasText(localName, &quot;The local name must not be null or empty.&quot;);
    char localNameStart  = localName.charAt(0);
    String normalizedLocalName = localName;
    if (Character.isUpperCase(localNameStart)) {
      StringBuilder builder = new StringBuilder(32)
                    .append(Character.toLowerCase(localNameStart))
                    .append(localName.substring(1));
      normalizedLocalName = builder.toString();
    }
    return normalizedLocalName;
  }
}
</pre>
<p>You might also write you own Serializer if you have the problem &#8220;in the opposite direction&#8221; which, luckily, I didn&#8217;t.</p>
<p>Let&#8217;s hope the current WS standards are not deprecated this fast&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/using-rpc-style-encoded-axis-1-webservices-with-spring-remoting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using apache to redirect from the root “/” context to a webapp context</title>
		<link>http://olafsblog.sysbsb.de/using-apache-to-redirect-from-the-root-%e2%80%9c%e2%80%9d-context-to-a-webapp-context/</link>
		<comments>http://olafsblog.sysbsb.de/using-apache-to-redirect-from-the-root-%e2%80%9c%e2%80%9d-context-to-a-webapp-context/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 19:54:26 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=75</guid>
		<description><![CDATA[Just a short note:
The best way of doing this avoiding endless recursion is to use apaches RedirectMatch rule, like this:

   RedirectMatch ^/$ http://targethost/mywebapp

Easy, agreed. But i&#8217;ve seen (and done it wrong my self) quite often&#8230;
]]></description>
			<content:encoded><![CDATA[<p>Just a short note:</p>
<p>The best way of doing this avoiding endless recursion is to use <a href="http://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch">apaches RedirectMatch rule</a>, like this:</p>
<p><code><br />
   RedirectMatch ^/$ http://targethost/mywebapp<br />
</code></p>
<p>Easy, agreed. But i&#8217;ve seen (and done it wrong my self) quite often&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/using-apache-to-redirect-from-the-root-%e2%80%9c%e2%80%9d-context-to-a-webapp-context/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorry guys, server crash&#8230;</title>
		<link>http://olafsblog.sysbsb.de/sorry-guys-server-crash/</link>
		<comments>http://olafsblog.sysbsb.de/sorry-guys-server-crash/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 23:38:18 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[dude]]></category>
		<category><![CDATA[oh crap]]></category>
		<category><![CDATA[where is that backup]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=74</guid>
		<description><![CDATA[Folks,
There was a hardware crash at the hosting center that has caused a complete exchange and re-installation of this server.
I&#8217;ve got older backups running now, recent posts are not up yet but will be within the next week.
Posts may still look crappy and outtakes may occur, but for now, a least the older stuff is [...]]]></description>
			<content:encoded><![CDATA[<p>Folks,</p>
<p>There was a hardware crash at the hosting center that has caused a complete exchange and re-installation of this server.<br />
I&#8217;ve got older backups running now, recent posts are not up yet but will be within the next week.<br />
Posts may still look crappy and outtakes may occur, but for now, a least the older stuff is back online&#8230;</p>
<p>Greetings<br />
Olaf</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/sorry-guys-server-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running mvn:release with Subversion 1.5.x</title>
		<link>http://olafsblog.sysbsb.de/running-mvnrelease-with-subversion-15x/</link>
		<comments>http://olafsblog.sysbsb.de/running-mvnrelease-with-subversion-15x/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 16:26:22 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[SCM]]></category>
		<category><![CDATA[System engineering]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven 2]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=73</guid>
		<description><![CDATA[When attempting to prepare a release using maven and the maven-release-plugin, you are currently very likely to see your build fail with a message such as:

[INFO] Executing: svn --non-interactive copy --file /tmp/...commit . https://subversion..../tags/...
[INFO] Working directory: ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: [...]]]></description>
			<content:encoded><![CDATA[<p>When attempting to prepare a release using maven and the <a href="http://maven.apache.org/plugins/maven-release-plugin/">maven-release-plugin</a>, you are currently very likely to see your build fail with a message such as:</p>
<p><code><br />
[INFO] Executing: svn --non-interactive copy --file /tmp/...commit . https://subversion..../tags/...<br />
[INFO] Working directory: ...<br />
[INFO] ------------------------------------------------------------------------<br />
[ERROR] BUILD FAILURE<br />
[INFO] ------------------------------------------------------------------------<br />
[INFO] Unable to tag SCM<br />
Provider message:<br />
The svn tag command failed.<br />
Command output:<br />
svn: Commit failed (details follow):<br />
svn: File '...' already exists<br />
</code></p>
<p>If you do, you are using subversion 1.5.x which no longer supports tagging from a local working copy, thus causing the unfortunately very misleading error message.</p>
<p>This is a <a href="http://jira.codehaus.org/browse/SCM-406"> known issue of the subversion sourcecode management  (SCM)</a> and there is a simple workaround:<br />
<span id="more-73"></span><br />
Use the latest 2.x snapshot version of the maven release plugin and configure it to use remote tagging (on the subversion server) rather than tagging from your local copy.</p>
<p>You can do so by </p>
<h3>1.) Adding the apache snapshots repository to your plugin repositories list</h3>
<pre class="brush: xml;">
    &lt;pluginRepositories&gt;
        &lt;pluginRepository&gt;
            &lt;id&gt;apache-snapshots&lt;/id&gt;
            &lt;name&gt;Apache Snapshot Repository&lt;/name&gt;
            &lt;url&gt;http://repository.apache.org/snapshots/&lt;/url&gt;
            &lt;snapshots&gt;
                &lt;enabled&gt;true&lt;/enabled&gt;
            &lt;/snapshots&gt;
        &lt;/pluginRepository&gt;
        ...
    &lt;/pluginRepositories&gt;
</pre>
<h3>2.) Configuring the release plugin&#8217;s version and tagging</h3>
<pre class="brush: xml;">
        ...
        &lt;build&gt;
        ...
        &lt;pluginManagement&gt;
            &lt;plugins&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-release-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.0-beta-9-SNAPSHOT&lt;/version&gt;
                    &lt;configuration&gt;
                        &lt;tagBase&gt;full url to the tags directory on the svn server&lt;/tagBase&gt;
                        &lt;!-- See http://jira.codehaus.org/browse/SCM-406 --&gt;
                        &lt;remoteTagging&gt;true&lt;/remoteTagging&gt;
                        &lt;!-- Further non-mandatory but useful settings... --&gt;
                        &lt;preparationGoals&gt;clean install&lt;/preparationGoals&gt;
                        &lt;autoVersionSubmodules&gt;true&lt;/autoVersionSubmodules&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;
        ...
        &lt;/build&gt;
        ...
</pre>
<p>This fixed it for me.</p>
<p>Note: i had problems getting this to function with the scp:// protocol (provider) for my distribution repository. It seems logic, tough, that the choosen provider must support remote tagging, thus i choose the scpexe:// protocol (using a local scp executable) instead, that worked:</p>
<pre class="brush: xml;">
...
&lt;distributionManagement&gt;
&lt;repository&gt;
  &lt;id&gt;myReo&lt;/id&gt;
  &lt;name&gt;myreo&lt;/name&gt;
  &lt;url&gt;scpexe://...&lt;/url&gt;
 &lt;/repository&gt;
...
&lt;/distributionManagement&gt;
...
</pre>
<p>Apparently, the upcoming 2.0 release of the maven-release-plugin will have remote tagging as default, so if you read this and the 2.0 version has been released, simply using it should do the job.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/running-mvnrelease-with-subversion-15x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Modular development with OSGI about to be very, very popular &#8211; finally.</title>
		<link>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/</link>
		<comments>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 11:40:32 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JPA]]></category>
		<category><![CDATA[OSGI]]></category>
		<category><![CDATA[System architecture]]></category>
		<category><![CDATA[eclipselink]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=72</guid>
		<description><![CDATA[It&#8217;s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.<br />
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented programming, dependency injection and a freely available range of lightweight yet extremely powerful frameworks, libraries and API&#8217;s finally permitted the humble programmer to do what he always wanted to do &#8211; analyze problems, and elegantly write them down without spending all of his precious time on the syntax.</p>
<p>I would even go as far as saying that there was no object orientation before programming crosscutting concerns and using dependency injection became established mechanisms.<br />
Think about it: The original goal of OO is not to use inheritance, encapsulation, identity and polymorphism, but to express the <em>real world of things</em> &#8211; our reality &#8211; using an <em>abstract world of things</em>, while preserving most of the properties and relationships we observe in reality. </p>
<p>Before AOP, before being able to separate the description of things from creating, configurating and connecting concrete instances through dependency injection frameworks, this goal was hard to achieve.</p>
<h3>Modules larger than classes with OSGI</h3>
<p>Now however, we are about to reach a new stage in development of object orientation in JAVA: Developing modules that are <em>larger than classes</em>, modules which can, once properly identified, be developed independently using all the wonderful technology described beforehand. The technology used to achieve this has a name: <a href="http://en.wikipedia.org/wiki/OSGi">OSGI</a>. This technology has quite a long history of development, but a certain lack of elegance and light-weightiness barred this component model from becoming a real hit in the worldwide development community. This is about to change.<br />
<span id="more-72"></span></p>
<h3>Impact of OSGI on the development process</h3>
<p>Let me stress out here how important it is to be able to develop, manage and deploy such modules. The larger your system, the more developers your project involves, the longer you maintain it &#8211; you will always face the same problem: Developers concurrently working with party of the system that are directly or transitively connected will run into conflicts. You will have different parts of your system requiring different versions of the same library on the same class path. Changing one part of the system will always affect other parts of the system, most of the times in an unplanned fashion. </p>
<p>Test driven developments helps a lot along the way, but you still have a responsibility problem if there&#8217;s one team changing something and this causes a problem in a different part of the system, and dependency issues can be a real mess.</p>
<p>This is where OSGI can play out it&#8217;s strengths. Not only does it offer you complete, classloader-based module isolation. I believe the greatest benefit lies in the development process: Concurrent development is a lot easier with OSGI bundles than with a huge pile of tightly interconnected classes. You can have a lot of changes in the bundle, while exposing a relatively stable interface through which other components access your bundle&#8217;s services. Separation into OSGI bundles can bring the power of the SOA-Idea into &#8220;stand-alone&#8221; applications, without the massive overhead of connecting systems or components through, for example web services.</p>
<p>Of course, this concept has quite an impact on your way of thinking, since you will start to add a new level of decomposition: Which classes form tightly coupled components that could be isolated from other components and used as a service through a well-defined, slim and easy-to-use interface? </p>
<h3>OSGI about to &#8220;break through&#8221;</h3>
<p>Now, why am i so convinced that OSGI is about to finally become as common as using AOP or dependency injection? Because all the popular technologies are just about to embrace OSGI:</p>
<ul>
<li>
    <a href="http://www.jroller.com/habuma/entry/modular_java">Craig walls (Spring framework) has just finished his book an modular JAVA with the spring framework, featuring OSGI and Spring</a>, a very powerful combination.
 </li>
<li>
    <a href="http://it-republik.de/jaxenter/jax/sessions/jax/speaker/#3271">Doug Clarke</a> and <a href="http://it-republik.de/jaxenter/jax/sessions/jax/speaker/#2213">Shaun Smith</a> will hold a presentation on persistence and OSGI with eclipselink (the reference implementation of the JAVA persistence API (JPA))</a>, thus suitable persistence mechanisms for this level of modularization are likely to be close at hand.
 </li>
</ul>
<p>And if you <a href="http://it-republik.de/jaxenter/jax/sessions/?tid=1053">look at the schedule for the JAX, Europe&#8217;s most important software &#038; development conference, there have never been more OSGI topics featured</a> &#8211; at least I would doubt that.</p>
<p>In other words: OSGI will soon be so smoothly integrated with you favorite frameworks, IDE&#8217;s and API&#8217;s that using it will be a breeze &#8211; and a must, if you want to take the quality of your development process and software to the next level.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/modular-development-with-osgi-about-to-be-very-very-popular-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven, Surefire, remote debugging and the -javaagent switch</title>
		<link>http://olafsblog.sysbsb.de/maven-surefire-remote-debugging-and-the-javaagent-switch/</link>
		<comments>http://olafsblog.sysbsb.de/maven-surefire-remote-debugging-and-the-javaagent-switch/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 12:31:17 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[J2EE]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[maven 2]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=70</guid>
		<description><![CDATA[When using maven surefire in conjunction with remote debugging (mvnDebug, for instance)
it seems necessary to disable forking of the test executions into separate processes, as the remote debugging works process wise. This is usually done by setting the the fork mode to never, e.g. by specifying -DforkMode=never on the command line.
This is, however, a misunderstanding. [...]]]></description>
			<content:encoded><![CDATA[<p>When using <a href="http://maven.apache.org/plugins/maven-surefire-plugin/">maven surefire</a> in conjunction with remote debugging (<code>mvnDebug</code>, for instance)<br />
it seems necessary to disable forking of the test executions into separate processes, as the remote debugging works process wise. This is usually done by setting the the fork mode to never, e.g. by specifying <code>-DforkMode=never</code> on the command line.</p>
<p>This is, however, a misunderstanding. mvnDebug is there to <em>enable debugging of the maven process</em> and not of the surefire execution &#8211; and disabling forking may have various side effects. One of those is the use of Java agents. When using agents, e.g. for <a href="http://static.springframework.org/spring/docs/2.5.x/reference/aop.html#aop-aj-ltw">loadtime-weaving in the Spring Framework</a>, one often specifies a <code>-javaagent:</code> as a JVM argument for surefire:<br />
<span id="more-70"></span></p>
<pre class="brush: xml;">
&lt;!-- See http://maven.apache.org/plugins/maven-surefire-plugin/ --&gt;
	&lt;plugin&gt;
	&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
	&lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt;
	&lt;configuration&gt;
		&lt;!--
			The following must be within one line of code, line breaks will
			cause surefire execution to fail.
		--&gt;
		&lt;argLine&gt;-javaagent:/path/to/myagent.jar&lt;/argLine&gt;
	&lt;/configuration&gt;
</pre>
<p>Java agents however <em>must be provided as an argument to the JVM when it starts</em> &#8211; which is exactly what happens when surefire &#8220;forks&#8221;.<br />
Thus: No forking, no agents, since the tests will be executed in the current jvm used to execute maven itself &#8211; and that one was not started with a -javaagent argument. In order to execute  surefire tests and use agents, the forkMode must at least be &#8220;once&#8221; (<code>-DforkMode=once</code>).</p>
<p>Thus, leave the forking as it is, and <a href="http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html">enable remote debugging as described in the surefire plug-in documentation</a>, i.e. without using mvnDebug:</p>
<p><code><br />
mvn test -Dmaven.surefire.debug<br />
</code></p>
<p>Which will open a remote debugging port at localhost:5005 for the test execution &#8211; and use the agents.</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/maven-surefire-remote-debugging-and-the-javaagent-switch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Repository search for maven artifacts</title>
		<link>http://olafsblog.sysbsb.de/repository-search-for-maven-artifacts/</link>
		<comments>http://olafsblog.sysbsb.de/repository-search-for-maven-artifacts/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 10:33:13 +0000</pubDate>
		<dc:creator>olaf</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[maven 2]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://olafsblog.sysbsb.de/?p=69</guid>
		<description><![CDATA[Most of the maven users know the site www.mvnrepository.com which provides a nice lookup of maven artefacts.
Now there is also a newer site, www.mvnbrowser.com which currently performs better than mvnrepository. In addition, you can lookup repositories actually containing your desired artifact &#8211; now that&#8217;s sweet!
]]></description>
			<content:encoded><![CDATA[<p>Most of the maven users know the site <a href="http://www.mvnrepository.com">www.mvnrepository.com</a> which provides a nice lookup of maven artefacts.<br />
Now there is also a newer site, <a href="http://www.mvnbrowser.com">www.mvnbrowser.com</a> which currently performs better than mvnrepository. In addition, you can lookup repositories actually containing your desired artifact &#8211; now that&#8217;s sweet!</p>
]]></content:encoded>
			<wfw:commentRss>http://olafsblog.sysbsb.de/repository-search-for-maven-artifacts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

