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

<channel>
	<title>Technical blog</title>
	<atom:link href="http://puretech.paawak.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://puretech.paawak.com</link>
	<description>My musings on software</description>
	<pubDate>Sun, 05 Sep 2010 09:42:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Annotation based Spring MVC, how tos</title>
		<link>http://puretech.paawak.com/2010/09/05/annotation-based-spring-mvc-how-tos/</link>
		<comments>http://puretech.paawak.com/2010/09/05/annotation-based-spring-mvc-how-tos/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 05:56:42 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[spring]]></category>

		<category><![CDATA[spring mvc]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=360</guid>
		<description><![CDATA[I will list here the common how to-s for the new Annotation based Spring MVC. Please note that I am using Spring version 3.0.0.RELEASE. This is a bit, only a small bit, different from the version 2.5.x. So, if you are using 2.5.x, you have to tweak things a bit before you get the same [...]]]></description>
			<content:encoded><![CDATA[<p>I will list here the common how to-s for the new Annotation based Spring MVC. Please note that I am using Spring version <strong>3.0.0.RELEASE</strong>. This is a bit, only a small bit, different from the version <strong>2.5.x</strong>. So, if you are using 2.5.x, you have to tweak things a bit before you get the same effect.</p>
<p>Consider the following screen:</p>
<p><img class="aligncenter size-full wp-image-361" title="samplehtml" src="http://puretech.paawak.com/wp-content/uploads/2010/09/samplehtml.png" alt="samplehtml" width="561" height="404" /></p>
<p>The fantatstic thing about Spring MVC is it lets you take an Object Oriented approach while designing the Model (Form Bean) and lets you bind that seamlessly to the View (JSP Form).  For the above scenario, we can break down the top section into a list of rows. I would denote the row with a class having select, itemName, price&#8230; attributes, as shown below (this is an inner class in my <em>ItemBean</em> class, which is my Form Bean):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> ItemRow <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">boolean</span> selected<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">String</span> itemName<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> price<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> quantity<span style="color: #339933;">;</span>
&nbsp;
        ...
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then, in my ItemBean class, I can have a <em>List</em> of <em>ItemRow</em>, as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ItemBean <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> List<span style="color: #339933;">&lt;</span>ItemRow<span style="color: #339933;">&gt;</span> items<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">float</span> totalPrice<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Date</span> expectedDelivery<span style="color: #339933;">;</span>
...
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>How do I display/bind my Model to View?</h2>
<p>This is how the  View (<em>Item.jsp</em>) looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="xhtml" style="font-family:monospace;">                                           &lt;c:forEach var=&quot;item&quot; items=&quot;${command.items}&quot; varStatus=&quot;count&quot;&gt;
						&lt;tr&gt;
							&lt;td&gt;
								&lt;form:checkbox id=&quot;chkSelect&quot; path=&quot;items[${count.index}].selected&quot; /&gt;
							&lt;/td&gt;
							&lt;td&gt;
								&lt;c:out value=&quot;${item.itemName}&quot;/&gt;
							&lt;/td&gt;
							&lt;td&gt;
								&lt;input id=&quot;txtUnitPrice&quot; type=&quot;text&quot; disabled=&quot;disabled&quot; value=&quot;${item.price}&quot; size=&quot;4&quot;/&gt;
							&lt;/td&gt;
							&lt;td&gt;								
								&lt;form:input id=&quot;txtQuantity&quot; path=&quot;items[${count.index}].quantity&quot; size=&quot;3&quot; disabled=&quot;${!item.selected}&quot;/&gt;
							&lt;/td&gt;
							&lt;td&gt;
								&lt;input id=&quot;txtItemPrice&quot; type=&quot;text&quot; readonly=&quot;readonly&quot; value=&quot;${item.price * item.quantity}&quot; size=&quot;6&quot;/&gt;
							&lt;/td&gt;
						&lt;/tr&gt;
						&lt;/c:forEach&gt;
                                                &lt;tr&gt;
							&lt;td style=&quot;height:30px;&quot;&gt;
							&lt;/td&gt;
						&lt;/tr&gt;
						&lt;tr&gt;
							&lt;td colspan=&quot;3&quot;&gt;
								Total Price:
							&lt;/td&gt;
							&lt;td&gt;
								&lt;form:input id=&quot;txtTotalPrice&quot; path=&quot;totalPrice&quot; readonly=&quot;true&quot; size=&quot;6&quot; /&gt;
							&lt;/td&gt;
						&lt;/tr&gt;</pre></div></div>

<p>Especially note the<br />
<blockquote><span style="color: #0000ff;">path=&#8221;items[${count.index}].selected&#8221; </span></p></blockquote>
<p> in the <span style="color: #0000ff;">form:checkbox </span> tag. This is the key. It binds a particular index of the <em>items</em> in the <em>ItemBean</em> class to the JSP.</p>
<h2>How to map a given url to my Controller method</h2>
<p>After the introduction of Annotation <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/stereotype/Controller.html" target="_blank">@Controller</a>, all Spring MVC controllers have become like <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/index.html?org/springframework/web/servlet/mvc/multiaction/MultiActionController.html" target="_blank">MultiActionController</a>, that is, you can handle multiple requests in the same controller. Mapping a url is very simple: you should annotate any public method with the <em>@RequestMapping(&#8221;/DesiredUrl.do&#8221;)</em>. Of course, you should make sure:</p>
<p>1.&gt; The class is annotated with <em>@Controller</em><br />
2.&gt; The following line is present in the Spring context file:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context:component-scan</span> <span style="color: #000066;">base-package</span>=<span style="color: #ff0000;">&quot;com.swayam.demo.web.controller&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>The method can have a motley combination of parameters and return type. Read the <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html" target="_blank">javadocs</a> for details. This annotation takes an optional parameter <em>method</em>, which can be any enum <em>RequestMethod</em> type. If you do not specify anything, your method will handle all types of requests like GET, POST, DELETE, etc.</p>
<h2>How do I pre-load or customise my Form Bean before it reaches my controller method?</h2>
<p>In Spring MVC, the framework creates an instance of the Form Bean and binds it to the fields in JSP in case of a POST. In many cases, I would like to customise the Form Bean before it starts binding to the JSP fields. In older versions of Spring MVC, this was done by overriding the <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/servlet/mvc/AbstractFormController.html#formBackingObject(javax.servlet.http.HttpServletRequest)" target="_blank">formBackingObject() method in AbstractFormController</a>.<br />
With annotations, you do it by specifying the <em>@ModelAttribute</em> before the FormBean attribute in the request handler method and then again on a public method returning the customised Form Bean as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @RequestMapping<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/checkout.htm&quot;</span>, method <span style="color: #339933;">=</span> RequestMethod.<span style="color: #006633;">POST</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ModelAndView checkout<span style="color: #009900;">&#40;</span>
            @ModelAttribute<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;postBean&quot;</span><span style="color: #009900;">&#41;</span> ItemBean formBean,
            BindingResult errors<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ModelAndView model <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        model.<span style="color: #006633;">addObject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;command&quot;</span>, formBean<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
        <span style="color: #000000; font-weight: bold;">return</span> model<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @ModelAttribute<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;postBean&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ItemBean initBeanForPost<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ItemBean bean <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ItemBean<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        populateBean<span style="color: #009900;">&#40;</span>bean, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">return</span> bean<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Note that its always a good practice to specify the name in the <em>@ModelAttribute</em> annotation. This way you can pre-load different beans for different methods. As shown in the example above, the name specified in the <em>@ModelAttribute</em> annotation in the request handler method <em>checkout()</em> and that in the method <em>initBeanForPost()</em> should be an exact match. By the way, this works for GET as well as POST or any other request type.</p>
<h2>How do I do the validation?</h2>
<p>Spring version 3.x onwards, doing validations have become very easy. I will describe this in the following few steps:</p>
<h4>1. Write a Validator</h4>
<p>Your validator should implement the <em>Validator</em> interface. It has two methods that you need to override. The <em>supports()</em> method makes sure that the Validator can validate a given FormBean. The <em>validate()</em> method does the actual job of validating. A typical Validator will look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> ItemValidator <span style="color: #000000; font-weight: bold;">implements</span> Validator <span style="color: #009900;">&#123;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> validate<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> target, Errors errors<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ItemBean bean <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ItemBean<span style="color: #009900;">&#41;</span> target<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bean.<span style="color: #006633;">getTotalPrice</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            errors.<span style="color: #006633;">rejectValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;totalPrice&quot;</span>, <span style="color: #0000ff;">&quot;noItemsSelected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> supports<span style="color: #009900;">&#40;</span>Class<span style="color: #339933;">&lt;?&gt;</span> clazz<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> clazz <span style="color: #339933;">==</span> ItemBean.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<h4>2. Set the Validator</h4>
<p>You do this in a public method annotated with <em>@InitBinder</em> in the controller.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @InitBinder
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initBinder<span style="color: #009900;">&#40;</span>WebDataBinder binder, WebRequest webRequest<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>binder.<span style="color: #006633;">getTarget</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">instanceof</span> ItemBean<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            binder.<span style="color: #006633;">setValidator</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ItemValidator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>I am setting the validator inside the <em>if (binder.getTarget() instanceof ItemBean)</em> block as otherwise I get an <strong>ugly exception</strong> in case there are any <strong>validation errors</strong>. I am putting the stack trace below:</p>
<blockquote><p><span style="color: #ff0000;"><br />
java.lang.IllegalStateException: Invalid target for Validator [com.swayam.demo.web.controller.ItemController$1@11e7cc6]: org.springframework.validation.BeanPropertyBindingResult: 1 errors<br />
Field error in object &#8216;postBean&#8217; on field &#8216;totalPrice&#8217;: rejected value [0.0]; codes [noItemsSelected.postBean.totalPrice,noItemsSelected.totalPrice,noItemsSelected.float,noItemsSelected]; arguments []; default message [null]] with root cause<br />
java.lang.IllegalStateException: Invalid target for Validator [com.swayam.demo.web.controller.ItemController$1@11e7cc6]: org.springframework.validation.BeanPropertyBindingResult: 1 errors<br />
Field error in object &#8216;postBean&#8217; on field &#8216;totalPrice&#8217;: rejected value [0.0]; codes [noItemsSelected.postBean.totalPrice,noItemsSelected.totalPrice,noItemsSelected.float,noItemsSelected]; arguments []; default message [null]<br />
	at org.springframework.validation.DataBinder.setValidator(DataBinder.java:472)<br />
	at com.swayam.demo.web.controller.ItemController.initBinder(ItemController.java:63)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
	at java.lang.reflect.Method.invoke(Method.java:597)<br />
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doInvokeMethod(HandlerMethodInvoker.java:710)<br />
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.initBinder(HandlerMethodInvoker.java:329)<br />
	at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.updateModelAttributes(HandlerMethodInvoker.java:691)<br />
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:417)<br />
	at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:402)<br />
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:771)<br />
</span></p></blockquote>
<h4>3. Use @Valid before the Form Bean</h4>
<p>This is a new feature added in release 3.x. Now the validation happens with JSR-303 Bean Validation API. You can find the jar <a href="http://repo1.maven.org/maven2/javax/validation/validation-api/1.0.0.GA/" target="_blank">here</a>. If you are using Maven, you can add the following dependency:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.validation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>validation-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0.GA<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This is how you use it:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @RequestMapping<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/checkout.htm&quot;</span>, method <span style="color: #339933;">=</span> RequestMethod.<span style="color: #006633;">POST</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ModelAndView checkout<span style="color: #009900;">&#40;</span>
            @Valid ItemBean formBean,
            BindingResult errors<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ModelAndView model <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...
        <span style="color: #000000; font-weight: bold;">return</span> model<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The Form Bean is validated with the set Validator by the framework. Note that for Spring 2.5.x, you need to make the call to validator manually inside the handler method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">...
        <span style="color: #006633;">Validator</span> validator <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ItemValidator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        validator.<span style="color: #006633;">validate</span><span style="color: #009900;">&#40;</span>formBean, errors<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
...</pre></div></div>

<h2>In my Validator, how do I use messages from properties file for i18n?</h2>
<p>Lets say,  my properties file is <em>Messages.properties</em> located at <em>/com/swayam/demo/web/res/</em>. The contents are:</p>
<blockquote><p>noItemsSelected=You have not selected any items</p></blockquote>
<p>I have to create an instance of <em>MessageSource</em> in my Spring conf file as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;messageSource&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.context.support.ResourceBundleMessageSource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;basenames&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.demo.web.res.Messages<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now I can use the <em>property key</em> in my <em>validate()</em> method as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> validate<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> target, Errors errors<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ItemBean bean <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ItemBean<span style="color: #009900;">&#41;</span> target<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>bean.<span style="color: #006633;">getTotalPrice</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            errors.<span style="color: #006633;">rejectValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;totalPrice&quot;</span>, <span style="color: #0000ff;">&quot;noItemsSelected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<h2>How to display the Validation messages on my JSP?</h2>
<p>First, from the controller, you have to pass an instance of <em>BindingResult</em> to the JSP.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @RequestMapping<span style="color: #009900;">&#40;</span>value <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/checkout.htm&quot;</span>, method <span style="color: #339933;">=</span> RequestMethod.<span style="color: #006633;">POST</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> ModelAndView checkout<span style="color: #009900;">&#40;</span>
            @Valid ItemBean formBean,
            BindingResult errors<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        ModelAndView model <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ModelAndView<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        model.<span style="color: #006633;">addObject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;command&quot;</span>, formBean<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>errors.<span style="color: #006633;">hasErrors</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            model.<span style="color: #006633;">setViewName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Item&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            model.<span style="color: #006633;">addObject</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;errors&quot;</span>, errors<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            model.<span style="color: #006633;">setViewName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Checkout&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> model<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>And this is how the JSP looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="jsp" style="font-family:monospace;">		&lt;c:if test=&quot;${ not empty errors.allErrors }&quot;&gt; 
		&lt;div style=&quot;text-align:center; color:red;&quot;&gt;
			&lt;ul&gt;
				&lt;c:forEach var=&quot;error&quot; items=&quot;${errors.allErrors}&quot;&gt;
					&lt;li&gt;&lt;spring:message code=&quot;${error.code}&quot;  text=&quot;${error.defaultMessage}&quot;/&gt;&lt;/li&gt;
				&lt;/c:forEach&gt;
			&lt;/ul&gt;
		&lt;/div&gt;
		&lt;/c:if&gt;</pre></div></div>

<h2>How do I bind a complex object to my JSP form field?</h2>
<p>Often we have to display a complex object as text. The best example I can take is that of a Date. Its a <em>java.util.Date</em> in the model. How do I map this to a text field in my JSP? You have to extend the <em>PropertyEditorSupport</em> and override the following methods:<br />
1. <strong>getAsText()</strong>: Converts an Object to its String representation. Used for displaying a model object in the JSP.<br />
2. <strong>setAsText(String text)</strong>: Converts the text from the input field to the complex object that the model understands.<br />
A typical implementation would look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> DateEditorSupport <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">PropertyEditorSupport</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Logger LOG <span style="color: #339933;">=</span> Logger.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>DateEditorSupport.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Format</span> formatter<span style="color: #339933;">;</span>
&nbsp;
    DateEditorSupport<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> dateFormat<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        formatter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SimpleDateFormat</span><span style="color: #009900;">&#40;</span>dateFormat<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getAsText<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003399;">String</span> date <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">Object</span> value <span style="color: #339933;">=</span> getValue<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>value <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">Date</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            date <span style="color: #339933;">=</span> formatter.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">IllegalArgumentException</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expecting a &quot;</span>
                    <span style="color: #339933;">+</span> <span style="color: #003399;">Date</span>.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; class, got &quot;</span>
                    <span style="color: #339933;">+</span> value.<span style="color: #006633;">getClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> date<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAsText<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> text<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #003399;">Date</span> date <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Date</span><span style="color: #009900;">&#41;</span> formatter.<span style="color: #006633;">parseObject</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            setValue<span style="color: #009900;">&#40;</span>date<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">ParseException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            LOG.<span style="color: #006633;">fatal</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;error setting date for String: &quot;</span> <span style="color: #339933;">+</span> text, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Then, in the <em>@InitBinder</em> method, you need to register this against the class:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    @InitBinder
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> initBinder<span style="color: #009900;">&#40;</span>WebDataBinder binder, WebRequest webRequest<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        binder.<span style="color: #006633;">registerCustomEditor</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Date</span>.<span style="color: #000000; font-weight: bold;">class</span>, <span style="color: #000000; font-weight: bold;">new</span> DateEditorSupport<span style="color: #009900;">&#40;</span>
                <span style="color: #0000ff;">&quot;dd/MM/yyyy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Putting it all together</h2>
<p>You will find the sources <a href="http://puretech.paawak.com/resources/java/spring-mvc-example/SpringMVC_src.zip" >here</a>. Its an Eclipse project, using Maven. In order to get all the libraries, install <a href="http://maven.apache.org/" target="_blank">Maven</a> and run:<br />
<em>mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true -Dwtpversion=2.0</em><br />
You can also run <a href="http://puretech.paawak.com/resources/java/spring-mvc-example/SpringMVC.war">the war file</a> directly and go to <a href="http://localhost:8080/SpringMVC/" target="_blank">http://localhost:8080/SpringMVC/</a> to see it in action.</p>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/09/05/annotation-based-spring-mvc-how-tos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[How To] Convert a Maven Project to Eclipse Web Project</title>
		<link>http://puretech.paawak.com/2010/08/28/how-to-convert-a-maven-project-to-eclipse-web-project/</link>
		<comments>http://puretech.paawak.com/2010/08/28/how-to-convert-a-maven-project-to-eclipse-web-project/#comments</comments>
		<pubDate>Sat, 28 Aug 2010 06:48:37 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=334</guid>
		<description><![CDATA[Eclipse WTP has this nice feature where it allows you to deploy, run and debug Web Applications from the IDE. You start by going to the Server View, adding the target server (like Apache Tomcat in our case) and then adding the Web Project to the server. This is how the view looks like:

But I [...]]]></description>
			<content:encoded><![CDATA[<p>Eclipse WTP has this nice feature where it allows you to deploy, run and debug Web Applications from the IDE. You start by going to the Server View, adding the target server (like Apache Tomcat in our case) and then adding the Web Project to the server. This is how the view looks like:</p>
<p><img class="aligncenter size-full wp-image-346" title="addremovewebprojects_1" src="http://puretech.paawak.com/wp-content/uploads/2010/08/addremovewebprojects_1.png" alt="addremovewebprojects_1" width="882" height="669" /></p>
<p>But I have often faced this problem: when I run <em>mvn eclipse:eclipse</em> on a Maven Web Project to convert it to an Eclipse project, it is not recognised as a Web Project by Eclipse. When I right-click on the server and select <em>Add Remove Projects</em>, it does not appear in the option box. But to me  <em>mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true</em> is indispensable as it downloads and links all the sources and JavaDocs, which comes very handy. On the other hand if I cannot add my project as a Web Project in Eclipse, running and debugging becomes a big issue. So how do I reconcile these two?</p>
<h2>Solution 1: Specify the WTP Version</h2>
<p>While running <em>mvn eclipse:eclipse</em>, specify the WTP Version by passing the <em>-Dwtpversion=2.0</em> argument. The command looks like:</p>
<p><em>mvn eclipse:clean eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true <span style="color: #0000ff;">-Dwtpversion=2.0</span></em></p>
<p>Note that as of this writing, the supported versions of WTP are  1.0, 1.5, 2.0 and R7.</p>
<h2>Solution 2: Convert it to a Facted Project</h2>
<p>Right click on the project, go to <em>Properties</em>, then select <em>Project Facets</em>.</p>
<p><img class="aligncenter size-full wp-image-349" title="converttofacetedproject" src="http://puretech.paawak.com/wp-content/uploads/2010/08/converttofacetedproject.png" alt="converttofacetedproject" width="442" height="380" /></p>
<p>Another dialog appears having the available facets.</p>
<p><img class="aligncenter size-full wp-image-350" title="selectdynamicwebproject" src="http://puretech.paawak.com/wp-content/uploads/2010/08/selectdynamicwebproject.png" alt="selectdynamicwebproject" width="638" height="560" /></p>
<p>Select <em>Dynamic Web Module</em>.</p>
<h2>Solution 3: Manual editing</h2>
<p>I like this best as it gives lot of flexibility around configuration. First you need to modify the <em>.project</em> file as shown:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;projectDescription<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>MyWebProject<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;comment<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/comment<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;projects<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/projects<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;buildSpec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.jsdt.core.javascriptValidator<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.jdt.core.javabuilder<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.common.project.facet.core.builder<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.validation.validationbuilder<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/arguments<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/buildCommand<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/buildSpec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;natures<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.jem.workbench.JavaEMFNature<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.common.modulecore.ModuleCoreNature<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.common.project.facet.core.nature<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.jdt.core.javanature<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.eclipse.wst.jsdt.core.jsNature<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/nature<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/natures<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/projectDescription<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Then, inside the <em>.settings</em> directory, you need to create two files called <em>org.eclipse.wst.common.component</em> and <em>org.eclipse.wst.common.project.facet.core.xml</em>.</p>
<h3>org.eclipse.wst.common.component</h3>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project-modules</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;moduleCoreId&quot;</span> <span style="color: #000066;">project-version</span>=<span style="color: #ff0000;">&quot;1.5.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wb-module</span> <span style="color: #000066;">deploy-name</span>=<span style="color: #ff0000;">&quot;MyWebProject&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wb-resource</span> <span style="color: #000066;">deploy-path</span>=<span style="color: #ff0000;">&quot;/&quot;</span> <span style="color: #000066;">source-path</span>=<span style="color: #ff0000;">&quot;/src/main/webapp&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;wb-resource</span> <span style="color: #000066;">deploy-path</span>=<span style="color: #ff0000;">&quot;/WEB-INF/classes&quot;</span> <span style="color: #000066;">source-path</span>=<span style="color: #ff0000;">&quot;/src/main/java&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;context-root&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;MyWebProject&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;java-output-path&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/MyWebProject/build/classes&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/wb-module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project-modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h3>org.eclipse.wst.common.project.facet.core.xml</h3>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;faceted-project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;runtime</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Apache Tomcat v7.0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;jst.web&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;wst.jsdt.web&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fixed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;java&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;installed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;java&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.6&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;installed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;jst.web&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;3.0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;installed</span> <span style="color: #000066;">facet</span>=<span style="color: #ff0000;">&quot;wst.jsdt.web&quot;</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/faceted-project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/28/how-to-convert-a-maven-project-to-eclipse-web-project/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating an EAR with Maven</title>
		<link>http://puretech.paawak.com/2010/08/22/creating-an-ear-with-maven/</link>
		<comments>http://puretech.paawak.com/2010/08/22/creating-an-ear-with-maven/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 19:20:20 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[ear]]></category>

		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=315</guid>
		<description><![CDATA[Maven is the build tool of choice for many people due to the simplicity and flexibility of use. The real strength of Maven is vetted when handling real complex projetcs consisting of tens of modules, each requiring elaborate build requirements.
I had faced an uphill task of Mavenising one of our EAR projects. As is the [...]]]></description>
			<content:encoded><![CDATA[<p>Maven is the build tool of choice for many people due to the simplicity and flexibility of use. The real strength of Maven is vetted when handling real complex projetcs consisting of tens of modules, each requiring elaborate build requirements.</p>
<p>I had faced an uphill task of Mavenising one of our EAR projects. As is the typical case, our project consisted of a EJB module and a WAR module, package together in a EAR module. It was a bit complex as we had to deploy the same application in JBoss and Glassfish. I will write some of that experience here.</p>
<p>Let us consider an enterprise application having a structure as show below:</p>
<p><a rel="attachment wp-att-316" href="http://puretech.paawak.com/2010/08/22/creating-an-ear-with-maven/project-structure/"><img class="aligncenter size-full wp-image-316" title="Project Structure" src="http://puretech.paawak.com/wp-content/uploads/2010/08/project-structure.png" alt="Project Structure" width="340" height="332" /></a></p>
<p>I will briefly explain what the modules stand for:</p>
<ol>
<li><strong>swayam-ear</strong>: This is the enterprise application</li>
<li><strong>swayam-ejb</strong>: Is the EJB module</li>
<li><strong>swayam-war</strong>: Is the web module</li>
<li><strong>swayam-shared</strong>: Has the ejb remote interfaces. As the name indicates, its shared by the <em>sawaym-ejb</em> and the <em>swayam-war</em> modules</li>
<li><strong>swayam-ear-builder</strong>: Used for building all the modules</li>
</ol>
<p>I am using Netbeans (6.8) and Glassfish for convinience. But you can pretty much use anything.</p>
<p>I have kept things pretty simple. This is how the Remote interface looks like (its a Stateless Session Bean):</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@<span style="color: #003399;">Remote</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> MySessionBeanRemote <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003399;">String</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And this is how I access it from the servlet:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">...
<span style="color: #006633;">MySessionBeanRemote</span> remoteBean <span style="color: #339933;">=</span> <span style="color: #003399;">InitialContext</span>.<span style="color: #006633;">doLookup</span><span style="color: #009900;">&#40;</span>MySessionBeanRemote.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
...</pre></div></div>

<h2>Mavenising the EJB</h2>
<p>We will use the <em>maven-ejb-plugin</em> for this. This is how the pom looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">         <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/src<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-jar-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-ejb-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ejbVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>3.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ejbVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;archive<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;addClasspath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>true<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/addClasspath<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/archive<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-compiler-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javaee-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>6.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-shared<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Note that the packaging is <em>ejb</em> and not <em>jar</em>.</p>
<h2>Mavenising the WAR</h2>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">         <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven.java.net<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Java.net Maven2 Repository<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://download.java.net/maven/2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/src/java<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sourceDirectory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-compiler-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-war-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${basedir}/web<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>CVS/**<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>WEB-INF/lib/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclude<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/excludes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/resource<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webResources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-shared<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>                
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>javax.servlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>servlet-api<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.4<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>provided<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>    
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Mavenising the EAR</h2>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">         <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ear<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ear<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ear<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven.java.net<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Java.net Maven2 Repository<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://download.java.net/maven/2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepository<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/pluginRepositories<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ear<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/finalName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.apache.maven.plugins<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-compiler-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-resources-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UTF-8<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/encoding<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>maven-ear-plugin<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2.4.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;webModule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bundleFileName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war.war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bundleFileName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;contextRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/contextRoot<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/webModule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ejbModule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bundleFileName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ejb.jar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bundleFileName<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ejbModule<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plugins<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/build<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${swayam-version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${swayam-version}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependencies<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;swayam-version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/swayam-version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The most important thing here is the <em>type</em> tag inside the <em>dependency</em> tag. Without this, it will not work.</p>
<h2>Putting it all together</h2>
<p>Its often very cumbersome to build these modules one by one manually when one of them changes. This is more so in a development environment. So, I will conclude with one pom for building all the modules at one go. This pom is present in the <em>swayam-ear-builder</em> module.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>4.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modelVersion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.eardemo<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ear-builder<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>pom<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/packaging<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.0.0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>swayam-ear-builder<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../swayam-ear<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../swayam-ejb<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../swayam-war<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>../swayam-shared<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/module<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/modules<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Note that the path of the modules are relative to the pom.<br />
You can build the EAR project and deploy it on Glassfish or JBoss. Once successfully deployed, you can open <a href="http://localhost:8080/swayam-war/EjbInvoker">http://localhost:8080/swayam-war/EjbInvoker</a> This is how it looks like:</p>
<p><a rel="attachment wp-att-326" href="http://puretech.paawak.com/2010/08/22/creating-an-ear-with-maven/screenshot-servlet-ejbinvoker-google-chrome/"><img class="aligncenter size-full wp-image-326" title="screenshot-servlet-ejbinvoker-google-chrome" src="http://puretech.paawak.com/wp-content/uploads/2010/08/screenshot-servlet-ejbinvoker-google-chrome.png" alt="screenshot-servlet-ejbinvoker-google-chrome" width="620" height="235" /></a></p>
<h2>Resources</h2>
<ol>
<li><a href="http://puretech.paawak.com/resources/java/maven/ear-demo/swayam-ear-all-sources.zip">Sources</a></li>
<li><a href="http://puretech.paawak.com/resources/java/maven/ear-demo/swayam-ear.ear">Binaries</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/22/creating-an-ear-with-maven/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[How To] Configure GTalk on Kopete</title>
		<link>http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/</link>
		<comments>http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 19:40:34 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[im]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=292</guid>
		<description><![CDATA[Kopete is one of the most versatile and cool Instant Messenger for Linux. Its lot better and more secure and feature rich than Pidgin. GTalk is based on the open source XMPP Protocol, Jabber compatible.
While entering the new account details, select Jabber:

Enter your full email id.
Go to the connection tab. Check the  Override default [...]]]></description>
			<content:encoded><![CDATA[<p>Kopete is one of the most versatile and cool Instant Messenger for Linux. Its lot better and more secure and feature rich than Pidgin. GTalk is based on the open source XMPP Protocol, Jabber compatible.</p>
<p>While entering the new account details, select Jabber:</p>
<p><a rel="attachment wp-att-293" href="http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/kopete_gtalk_1/" target="_blank"></a><a rel="attachment wp-att-293" href="http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/kopete_gtalk_1/"><img class="aligncenter size-full wp-image-293" title="Select type as &quot;Jabber&quot;" src="http://puretech.paawak.com/wp-content/uploads/2010/08/kopete_gtalk_1.png" alt="Select type as &quot;Jabber&quot;" width="940" height="573" /></a></p>
<p>Enter your full email id.</p>
<p style="margin-bottom: 0in;">Go to the connection tab. Check the  <em><strong>Override default server information</strong></em> check-box and enter the server as t<em><strong>alk.google.com</strong></em>, the port as <em><strong>5223.</strong></em> Also check these check boxes:</p>
<ol>
<li>
<p style="margin-bottom: 0in;">Use protocol encryption</p>
</li>
<li>Allow plain text password authentication</li>
</ol>
<p><a rel="attachment wp-att-294" href="http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/kopete_gtalk_3/"><img class="aligncenter size-full wp-image-294" title="Connection details" src="http://puretech.paawak.com/wp-content/uploads/2010/08/kopete_gtalk_3.png" alt="Connection details" width="938" height="580" /></a></p>
<p>Save this information and you should be done.</p>
<p style="margin-bottom: 0in;">
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/21/how-to-configure-gtalk-on-kopete/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tweaking MySQL on Fedora</title>
		<link>http://puretech.paawak.com/2010/08/21/tweaking-mysql-on-fedora/</link>
		<comments>http://puretech.paawak.com/2010/08/21/tweaking-mysql-on-fedora/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 19:27:36 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[database]]></category>

		<category><![CDATA[linux]]></category>

		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=290</guid>
		<description><![CDATA[MySQL is installed on Fedora and most Linuxes by default. Its just about some tweaking before you can use it. I am detailing some of the rather useful commands.
To Install MySQL and start it
mysql_install_db
mysqld_safe &#38;
Make MySQL case insensitive
This is useful when the DB Script is also expected to run on Windows server.
vi /etc/my.cnf

[mysqld]
lower_case_table_names=1
To change the [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL is installed on Fedora and most Linuxes by default. Its just about some tweaking before you can use it. I am detailing some of the rather useful commands.</p>
<h2>To Install MySQL and start it</h2>
<p><span style="color: #000080;">mysql_install_db<br />
mysqld_safe &amp;</span></p>
<h2>Make MySQL case insensitive</h2>
<p>This is useful when the DB Script is also expected to run on Windows server.</p>
<p>vi /etc/my.cnf<br />
<span style="color: #000080;"><br />
[mysqld]<br />
lower_case_table_names=1</span></p>
<h2>To change the root password</h2>
<p><strong><span style="color: #000080;">mysql&gt;</span></strong></p>
<p>update user set password=password(&#8221;newPassword&#8221;)  where user=&#8217;root&#8217;;<br />
Query OK, 2 rows affected (0.00 sec)<br />
Rows matched: 2  Changed: 2  Warnings: 0</p>
<p>grant all on *.* to &#8216;root&#8217;@'192.168.%&#8217; identified by &#8216;newPassword&#8217;;</p>
<p>FLUSH PRIVILEGES;</p>
<h2>Adding a user</h2>
<p><strong><span style="color: #000080;">mysql&gt;</span></strong></p>
<p>insert into user (host, user, password) values(&#8217;localhost&#8217;,'newUser&#8217;,password(&#8217;xx123&#8242;));</p>
<p>insert into  host(host,db,Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv)  values(&#8217;localhost&#8217;,'dbName&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;,'Y&#8217;);</p>
<p>grant all on dbName.* to &#8216;newUser&#8217;@'localhost&#8217; identified by &#8216;xx123&#8242;;</p>
<p>FLUSH PRIVILEGES;</p>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/21/tweaking-mysql-on-fedora/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[How To] Enable VPN on Linux by PPTP</title>
		<link>http://puretech.paawak.com/2010/08/21/how-to-enable-vpn-on-linux-by-pptp/</link>
		<comments>http://puretech.paawak.com/2010/08/21/how-to-enable-vpn-on-linux-by-pptp/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 19:11:40 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[pptp]]></category>

		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=288</guid>
		<description><![CDATA[PPTP is an wonderful utility to enable VPN on a Linux box. Its secure and compatible with Windows network. I first heard about PPTP from (this wonderful guy called) Nikolaj. I have learnt how to set it up from him.
I am detailing the steps here:
1&#62; Install PPTP

yum install pptp
2&#62; vi /etc/ppp/options.pptp 

###############################################################################
# $Id: options.pptp,v 1.2 [...]]]></description>
			<content:encoded><![CDATA[<p>PPTP is an wonderful utility to enable VPN on a Linux box. Its secure and compatible with Windows network. I first heard about PPTP from (this wonderful guy called) Nikolaj. I have learnt how to set it up from him.</p>
<p>I am detailing the steps here:</p>
<h2>1&gt; Install PPTP</h2>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in; font-style: normal; font-weight: normal;"><span style="font-family: Liberation Serif,Times New Roman,serif;">yum install pptp</span></p>
<h2 style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">2&gt; vi /etc/ppp/options.pptp </span></span></h2>
<p style="margin-bottom: 0in;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">###############################################################################</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># $Id: options.pptp,v 1.2 2005/08/20 13:16:38 quozl Exp $</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">#</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Sample PPTP PPP options file /etc/ppp/options.pptp</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Options used by PPP when a connection is made by a PPTP client.</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># This file can be referred to by an /etc/ppp/peers file for the tunnel.</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Changes are effective on the next connection.  See &#8220;man pppd&#8221;.</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">#</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># You are expected to change this file to suit your system.  As</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># packaged, it requires PPP 2.4.2 or later from http://ppp.samba.org/</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># and the kernel MPPE module available from the CVS repository also on</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># http://ppp.samba.org/, which is packaged for DKMS as kernel_ppp_mppe.</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">###############################################################################</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Lock the port</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">lock</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Authentication</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># We don&#8217;t need the tunnel server to authenticate itself</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">noauth</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">persist </span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">debug</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># We won&#8217;t do EAP, CHAP, or MSCHAP, but we will accept MSCHAP-V2</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">refuse-eap</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">refuse-chap</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">refuse-mschap</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Compression</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Turn off compression protocols we know won&#8217;t be used</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">nobsdcomp</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">nodeflate</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Encryption</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># (There have been multiple versions of PPP with encryption support,</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># choose with of the following sections you will use.  Note that MPPE</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># requires the use of MSCHAP-V2 during authentication)</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># http://ppp.samba.org/ the PPP project version of PPP by Paul Mackarras</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># ppp-2.4.2 or later with MPPE only, kernel module ppp_mppe.o</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># {{{</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Require MPPE 128-bit encryption</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">#require-mppe-128</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># }}}</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># http://polbox.com/h/hs001/ fork from PPP project by Jan Dubiec</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># ppp-2.4.2 or later with MPPE and MPPC, kernel module ppp_mppe_mppc.o</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># {{{</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># Require MPPE 128-bit encryption</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">#mppe required,stateless</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"># }}}</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">lcp-echo-failure 36 </span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">lcp-echo-interval 5</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">lcp-max-failure 0</span></p>
<h2 style="margin-bottom: 0in; font-style: normal; font-weight: normal;"><span style="font-family: Liberation Serif,Times New Roman,serif;">3&gt; vi /etc/ppp/chap-secrets</span></h2>
<p style="margin-bottom: 0in; font-style: normal; font-weight: normal;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><span style="color: #0000ff;"># Secrets for authentication using CHAP</span></p>
<p style="margin-bottom: 0in;"><span style="color: #0000ff;"># client                 	server       	secret                 	     		IP addresses</span></p>
<p style="margin-bottom: 0in;"><span style="color: #0000ff;"><br />
</span></p>
<p style="margin-bottom: 0in;"><span style="color: #0000ff;">VPNUserName      PPTP       VPNPassword         *</span></p>
<h2 style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">4&gt; Create a file called /etc/ppp/peers/my-company-vpn</span></span></h2>
<p style="margin-bottom: 0in;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">#pty &#8220;pptp my-company.com &#8211;nolaunchpppd&#8221;</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">name VPNUserName</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">remotename PPTP</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">require-mppe-128</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">file /etc/ppp/options.pptp</span></p>
<p style="margin-bottom: 0in;"><span style="color: #333399;">ipparam my-company-vpn</span></p>
<h2 style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">5&gt; Then on the prompt:</span></span></h2>
<p style="margin-bottom: 0in;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in; padding-left: 30px;">pptp my-company.com call <span style="color: #4700b8;"><span style="color: #000000;">my-company-vpn</span></span></p>
<h2 style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">6&gt; After 10/15 seconds, on the prompt:</span></span></h2>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #4700b8;"><span style="color: #000000;">route -n</span></span></p>
<p style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">You should see something like:</span></span></p>
<p style="margin-bottom: 0in;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">Kernel IP routing table </span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">Destination     Gateway         Genmask         Flags Metric Ref    Use Iface </span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;"><span style="color: #ff0000;">192.168.1.162</span><strong> </strong></span><span style="color: #333399;"> 0.0.0.0         255.255.255.255 UH    0      0        0 <em><strong>ppp0</strong></em></span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">87.61.21.102    192.168.1.1     255.255.255.255 UGH   0      0        0 eth0 </span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth0 </span></p>
<p style="margin-bottom: 0in;">If you see <em><strong>ppp0</strong></em>, it means you have successfully connected to the VPN.</p>
<h2 style="margin-bottom: 0in;"><span style="color: #4700b8;"><span style="color: #000000;">7&gt;</span></span> Add required routes</h2>
<p style="margin-bottom: 0in;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --></p>
<p style="margin-bottom: 0in; padding-left: 30px;">route add -host 192.168.1.30 gw <span style="color: #ff0000;">192.168.1.162</span></p>
<p>Where <em>192.168.1.30</em> is my internal company IP.</p>
<h2>8&gt;    	 	 	 	 	After that, to resolve the domains by names</h2>
<p>vi /etc/resolv.conf</p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">#to use when connected to the VPN my-company.com</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">domain my-office.my-company.com</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">#this, is the most important line: courtesy: Nikolaj</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">search my-office.my-company.com</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">#nameserver 192.168.1.1</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">nameserver 192.168.1.4</span></p>
<p style="margin-bottom: 0in; padding-left: 30px;"><span style="color: #333399;">nameserver 192.168.1.5</span></p>
<h2 style="margin-bottom: 0in;">Further reading:</h2>
<ul>
<li><a title="Nikolaj's original post on PPTP" href="http://blog.efef.dk/?p=92">Nikolaj&#8217;s original post</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/21/how-to-enable-vpn-on-linux-by-pptp/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[How To] Rip VCD on Linux</title>
		<link>http://puretech.paawak.com/2010/08/21/how-to-rip-vcd-on-linux/</link>
		<comments>http://puretech.paawak.com/2010/08/21/how-to-rip-vcd-on-linux/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 18:33:48 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[vcd]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=286</guid>
		<description><![CDATA[I have always had problems while playing VCDs on my Linux machine. The VCD file system is still not supported by the Linux kernel. But all is not lost. We have an utility called vcdxrip. This is the command:
vcdxrip -i /dev/sr0 -v -p -t 1 &#8211;nofiles &#8211;nosegments
Here i denotes the mount point of the CDROM [...]]]></description>
			<content:encoded><![CDATA[<p>I have always had problems while playing VCDs on my Linux machine. The VCD file system is still not supported by the Linux kernel. But all is not lost. We have an utility called <em>vcdxrip</em>. This is the command:</p>
<p><em>vcdxrip -i /dev/sr0 -v -p -t 1 &#8211;nofiles &#8211;nosegments</em></p>
<p>Here <em><strong>i</strong></em> denotes the mount point of the CDROM drive,  <strong><em>t </em></strong>denotes the Track Number. This way, a VCD can be ripped from a Linux machine. I have tested this on Fedora (10) and it works great.</p>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/08/21/how-to-rip-vcd-on-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Playing mp3 on Fedora</title>
		<link>http://puretech.paawak.com/2010/05/20/playing-mp3-on-fedora/</link>
		<comments>http://puretech.paawak.com/2010/05/20/playing-mp3-on-fedora/#comments</comments>
		<pubDate>Wed, 19 May 2010 18:37:18 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[linux]]></category>

		<category><![CDATA[mp3]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=282</guid>
		<description><![CDATA[By default, the codecs to play mp3/mp4 are not included due to licensing issues. First you need to add the non-standard repositories:
rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm
rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
rpm &#8211;import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-*
That done, if you just double click on a mp3 file (starting Fedora 8 onwards), it will pop-up a dialogue saying that you must install missing codecs.  Click [...]]]></description>
			<content:encoded><![CDATA[<p>By default, the codecs to play mp3/mp4 are not included due to licensing issues. First you need to add the non-standard repositories:</p>
<p><em><span style="color: #000080;">rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm<br />
rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm<br />
rpm &#8211;import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-*</span></em></p>
<p>That done, if you just double click on a mp3 file (starting Fedora 8 onwards), it will pop-up a dialogue saying that you must install missing codecs.  Click on yes and go along.</p>
<p>You can also explicitly install them like this:</p>
<p><em><span style="color: #000080;">yum install gstreamer-plugins-ugly gstreamer-plugins-bad gstreamer-ffmpeg</span></em></p>
<p>Further reading:</p>
<ul>
<li><a href="http://rpmfusion.org/Configuration" target="_blank">http://rpmfusion.org/Configuration</a></li>
<li><a href="http://www.fedorafaq.org/#mp3" target="_blank">http://www.fedorafaq.org/#mp3</a></li>
<li><a href="http://amarok.kde.org/wiki/MP3_on_Fedora_Core" target="_blank">http://amarok.kde.org/wiki/MP3_on_Fedora_Core</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/05/20/playing-mp3-on-fedora/feed/</wfw:commentRss>
		</item>
		<item>
		<title>[JBoss/Maven] org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser</title>
		<link>http://puretech.paawak.com/2010/05/19/jboss-maven-orgjbossxbbindingjbossxbruntimeexception-failed-to-create-a-new-sax-parser/</link>
		<comments>http://puretech.paawak.com/2010/05/19/jboss-maven-orgjbossxbbindingjbossxbruntimeexception-failed-to-create-a-new-sax-parser/#comments</comments>
		<pubDate>Tue, 18 May 2010 19:39:42 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[jboss]]></category>

		<category><![CDATA[maven]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=278</guid>
		<description><![CDATA[Sometimes when using spring framework or apache commons libraries on JBoss server [JBoss - 5.1.0], when it is built by maven, you get the following exception:
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX
parser
at org.jboss.xb.binding.UnmarshallerFactory
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)
at
org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)
at
org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:536)
at
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)
at
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at
org.apache.catalina.core.StandardContext.init(StandardContext.java:5436)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)
at
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)
at
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)
at
org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
at
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)
at
org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)
at $Proxy38.start(Unknown Source)
at
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)
at
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)
at
org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)
at
org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)
at
org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)
at
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at
org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)
at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at
org.jboss.system.ServiceController.doChange(ServiceController.java:688)
at org.jboss.system.ServiceController.start(ServiceController.java:460)
at
org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)
at
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)
at
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)
at
org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)
at
org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)
at
org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
at
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at
org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
at
org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)
at
org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)
at
org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)
at
org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)
at
org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)
at
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
at
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)
at
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)
at
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
at
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
at
org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)
at
org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)
at
org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)
at org.jboss.Main.boot(Main.java:221)
at org.jboss.Main$1.run(Main.java:556)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new
SAX parser
at
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:97)
at
org.jboss.xb.binding.UnmarshallerImpl.(UnmarshallerImpl.java:56)
at [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when using spring framework or apache commons libraries on JBoss server [JBoss - 5.1.0], when it is built by maven, you get the following exception:</p>
<blockquote><p><span style="color: #ff0000;">org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX<br />
parser<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:536)<br />
at<br />
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)<br />
at<br />
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)<br />
at<br />
org.apache.catalina.core.StandardContext.init(StandardContext.java:5436)<br />
at<br />
org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)<br />
at<br />
org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)<br />
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)<br />
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
at<br />
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
at<br />
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
at java.lang.reflect.Method.invoke(Method.java:597)<br />
at<br />
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)<br />
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)<br />
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)<br />
at<br />
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)<br />
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)<br />
at<br />
org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)<br />
at $Proxy38.start(Unknown Source)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)<br />
at<br />
org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)<br />
at<br />
org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.ServiceController.doChange(ServiceController.java:688)<br />
at org.jboss.system.ServiceController.start(ServiceController.java:460)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)<br />
at<br />
org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)<br />
at<br />
org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)<br />
at<br />
org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)<br />
at<br />
org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)<br />
at<br />
org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)<br />
at org.jboss.Main.boot(Main.java:221)<br />
at org.jboss.Main$1.run(Main.java:556)<br />
at java.lang.Thread.run(Thread.java:619)<br />
Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new<br />
SAX parser<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:97)<br />
at<br />
org.jboss.xb.binding.UnmarshallerImpl.(UnmarshallerImpl.java:56)<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)<br />
&#8230; 74 more<br />
Caused by: java.lang.ClassCastException:<br />
org.apache.xerces.parsers.StandardParserConfiguration cannot be cast to<br />
org.apache.xerces.xni.parser.XMLParserConfiguration<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.(Unknown<br />
Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown<br />
Source)<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:92)<br />
&#8230; 76 more<br />
2010-05-18 14:04:41,262 ERROR<br />
[org.jboss.web.tomcat.service.deployers.JBossContextConfig] (main) XML<br />
error parsing: jboss.web/localhost/context.xml.default<br />
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX<br />
parser<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:537)<br />
at<br />
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)<br />
at<br />
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)<br />
at<br />
org.apache.catalina.core.StandardContext.init(StandardContext.java:5436)<br />
at<br />
org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)<br />
at<br />
org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)<br />
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)<br />
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
at<br />
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
at<br />
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
at java.lang.reflect.Method.invoke(Method.java:597)<br />
at<br />
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)<br />
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)<br />
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)<br />
at<br />
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)<br />
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)<br />
at<br />
org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)<br />
at $Proxy38.start(Unknown Source)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)<br />
at<br />
org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)<br />
at<br />
org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.ServiceController.doChange(ServiceController.java:688)<br />
at org.jboss.system.ServiceController.start(ServiceController.java:460)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)<br />
at<br />
org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)<br />
at<br />
org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)<br />
at<br />
org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)<br />
at<br />
org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)<br />
at<br />
org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)<br />
at org.jboss.Main.boot(Main.java:221)<br />
at org.jboss.Main$1.run(Main.java:556)<br />
at java.lang.Thread.run(Thread.java:619)<br />
Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new<br />
SAX parser<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:97)<br />
at<br />
org.jboss.xb.binding.UnmarshallerImpl.(UnmarshallerImpl.java:56)<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)<br />
&#8230; 74 more<br />
Caused by: java.lang.ClassCastException:<br />
org.apache.xerces.parsers.StandardParserConfiguration cannot be cast to<br />
org.apache.xerces.xni.parser.XMLParserConfiguration<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.(Unknown<br />
Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown<br />
Source)<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:92)<br />
&#8230; 76 more<br />
2010-05-18 14:04:41,272 ERROR<br />
[org.jboss.web.tomcat.service.deployers.JBossContextConfig] (main) XML<br />
error parsing: WEB-INF/context.xml<br />
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX<br />
parser<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:100)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.processContextConfig(JBossContextConfig.java:549)<br />
at<br />
org.jboss.web.tomcat.service.deployers.JBossContextConfig.init(JBossContextConfig.java:540)<br />
at<br />
org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:279)<br />
at<br />
org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)<br />
at<br />
org.apache.catalina.core.StandardContext.init(StandardContext.java:5436)<br />
at<br />
org.apache.catalina.core.StandardContext.start(StandardContext.java:4148)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeployInternal(TomcatDeployment.java:310)<br />
at<br />
org.jboss.web.tomcat.service.deployers.TomcatDeployment.performDeploy(TomcatDeployment.java:142)<br />
at<br />
org.jboss.web.deployers.AbstractWarDeployment.start(AbstractWarDeployment.java:461)<br />
at org.jboss.web.deployers.WebModule.startModule(WebModule.java:118)<br />
at org.jboss.web.deployers.WebModule.start(WebModule.java:97)<br />
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br />
at<br />
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br />
at<br />
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br />
at java.lang.reflect.Method.invoke(Method.java:597)<br />
at<br />
org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:157)<br />
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:96)<br />
at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)<br />
at<br />
org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)<br />
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:668)<br />
at<br />
org.jboss.system.microcontainer.ServiceProxy.invoke(ServiceProxy.java:206)<br />
at $Proxy38.start(Unknown Source)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:42)<br />
at<br />
org.jboss.system.microcontainer.StartStopLifecycleAction.installAction(StartStopLifecycleAction.java:37)<br />
at<br />
org.jboss.dependency.plugins.action.SimpleControllerContextAction.simpleInstallAction(SimpleControllerContextAction.java:62)<br />
at<br />
org.jboss.dependency.plugins.action.AccessControllerContextAction.install(AccessControllerContextAction.java:71)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContextActions.install(AbstractControllerContextActions.java:51)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.system.microcontainer.ServiceControllerContext.install(ServiceControllerContext.java:286)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.ServiceController.doChange(ServiceController.java:688)<br />
at org.jboss.system.ServiceController.start(ServiceController.java:460)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.start(ServiceDeployer.java:163)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:99)<br />
at<br />
org.jboss.system.deployers.ServiceDeployer.deploy(ServiceDeployer.java:46)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractSimpleRealDeployer.internalDeploy(AbstractSimpleRealDeployer.java:62)<br />
at<br />
org.jboss.deployers.spi.deployer.helpers.AbstractRealDeployer.deploy(AbstractRealDeployer.java:50)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1178)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1210)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)<br />
at<br />
org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:702)<br />
at<br />
org.jboss.system.server.profileservice.repository.MainDeployerAdapter.process(MainDeployerAdapter.java:117)<br />
at<br />
org.jboss.system.server.profileservice.repository.ProfileDeployAction.install(ProfileDeployAction.java:70)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileAction.install(AbstractProfileAction.java:53)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.install(AbstractProfileService.java:361)<br />
at<br />
org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1631)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1082)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)<br />
at<br />
org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)<br />
at<br />
org.jboss.system.server.profileservice.repository.AbstractProfileService.activateProfile(AbstractProfileService.java:306)<br />
at<br />
org.jboss.system.server.profileservice.ProfileServiceBootstrap.start(ProfileServiceBootstrap.java:271)<br />
at<br />
org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:461)<br />
at org.jboss.Main.boot(Main.java:221)<br />
at org.jboss.Main$1.run(Main.java:556)<br />
at java.lang.Thread.run(Thread.java:619)<br />
Caused by: org.jboss.xb.binding.JBossXBException: Failed to create a new<br />
SAX parser<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:97)<br />
at<br />
org.jboss.xb.binding.UnmarshallerImpl.(UnmarshallerImpl.java:56)<br />
at org.jboss.xb.binding.UnmarshallerFactory<br />
$UnmarshallerFactoryImpl.newUnmarshaller(UnmarshallerFactory.java:96)<br />
&#8230; 74 more<br />
Caused by: java.lang.ClassCastException:<br />
org.apache.xerces.parsers.StandardParserConfiguration cannot be cast to<br />
org.apache.xerces.xni.parser.XMLParserConfiguration<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.parsers.SAXParser.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.(Unknown<br />
Source)<br />
at org.apache.xerces.jaxp.SAXParserImpl.(Unknown Source)<br />
at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown<br />
Source)<br />
at<br />
org.jboss.xb.binding.parser.sax.SaxJBossXBParser.(SaxJBossXBParser.java:92)<br />
&#8230; 76 more</span>
</p></blockquote>
<p>This is caused by the presence of the <em><strong>xml-apis.jar</strong></em> and <em><strong>xerces-impl.jar</strong></em>.</p>
<p>Solution:</p>
<p>In the <em>pom.xml</em>, exclude these two jars in the dependency. Example:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>commons-dbcp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>commons-dbcp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.2.1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>xml-apis<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>xml-apis<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>xerces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>xerces<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactId<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
                <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusion<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exclusions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/05/19/jboss-maven-orgjbossxbbindingjbossxbruntimeexception-failed-to-create-a-new-sax-parser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JAX-WS with JBoss</title>
		<link>http://puretech.paawak.com/2010/05/08/jax-ws-with-jboss/</link>
		<comments>http://puretech.paawak.com/2010/05/08/jax-ws-with-jboss/#comments</comments>
		<pubDate>Sat, 08 May 2010 13:09:01 +0000</pubDate>
		<dc:creator>paawak</dc:creator>
		
		<category><![CDATA[java]]></category>

		<category><![CDATA[jax-ws]]></category>

		<category><![CDATA[jaxws]]></category>

		<category><![CDATA[jboss]]></category>

		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://puretech.paawak.com/?p=272</guid>
		<description><![CDATA[JBoss supports JAX-WS out of the box. There is not much configuration files needed, only a servlet-mapping in the web.xml. This is how the web-service java file looks like:

&#160;
package com.swayam.demo.webservice;
&#160;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;
&#160;
/**
 *
 * @author paawak
 */
@WebService&#40;&#41;
public class UserService &#123;
&#160;
    /**
     * Web service operation
   [...]]]></description>
			<content:encoded><![CDATA[<p>JBoss supports JAX-WS out of the box. There is not much configuration files needed, only a servlet-mapping in the <em>web.xml</em>. This is how the web-service java file looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.swayam.demo.webservice</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebMethod</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebParam</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.jws.WebService</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 *
 * @author paawak
 */</span>
@WebService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserService <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Web service operation
     */</span>
    @WebMethod<span style="color: #009900;">&#40;</span>operationName <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;addUser&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Boolean</span> addUser<span style="color: #009900;">&#40;</span>@WebParam<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;userName&quot;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #003399;">String</span> userName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;add user&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Boolean</span>.<span style="color: #000066; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Its a POJO with a <em>@WebService</em> annotation. All you have to do is map this as a servlet in the desired context. Though this is not a servlet per-se, the JBoss web container does the rest. This is how the <em>web.xml</em> looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;web-app</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;2.5&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/javaee&quot;</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xsi:schemaLocation</span>=<span style="color: #ff0000;">&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UserService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>com.swayam.demo.webservice.UserService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>UserService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/UserService<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;session-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;session-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            30
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/session-timeout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/session-config<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>index.jsp<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/welcome-file-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>After deploying, you can access the webservice by <a href="http://localhost:8080/JBossWebServiceTest/UserService?wsdl">http://localhost:8080/JBossWebServiceTest/UserService?wsdl</a>.</p>
<p>You can find the sources <a href="http://puretech.paawak.com/resources/java/webservice-example/JBossWebServiceTest.zip">here</a> and the war <a href="http://puretech.paawak.com/resources/java/webservice-example/JBossWebServiceTest.war">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://puretech.paawak.com/2010/05/08/jax-ws-with-jboss/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
