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

<channel>
	<title>Stephen J. Houston &#187; JBoss Portal</title>
	<atom:link href="http://www.stephenhouston.com/category/jboss-portal/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stephenhouston.com</link>
	<description>Just another J2EE developer</description>
	<lastBuildDate>Mon, 09 Mar 2009 08:45:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Spring, Portlets and Annotation Configuration</title>
		<link>http://www.stephenhouston.com/20090309/spring-portlets-and-annotation-configuration/</link>
		<comments>http://www.stephenhouston.com/20090309/spring-portlets-and-annotation-configuration/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 08:45:51 +0000</pubDate>
		<dc:creator>Stephen Houston</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[JBoss Portal]]></category>

		<guid isPermaLink="false">http://www.stephenhouston.com/?p=30</guid>
		<description><![CDATA[There&#8217;s one thing that is easy to miss when setting up a Portlet using Spring MVC and Annotation configuration, and that is the correct placement of the &#60;context:annotation-config /&#62; elements. In the examples that I found, the element is only located in the applicationContext.xml file, unfortunately this doesn&#8217;t always work as you might expect.
In Spring [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s one thing that is easy to miss when setting up a Portlet using Spring MVC and Annotation configuration, and that is the correct placement of the &lt;context:annotation-config /&gt; elements. In the examples that I found, the element is only located in the applicationContext.xml file, unfortunately this doesn&#8217;t always work as you might expect.</p>
<p>In Spring MVC Portlets, the applicationContext file is used to define beans that should be available to all the portlets in that portlet application (or WAR). Similarly it also makes these beans available to any servlets that are defined in the WAR. So far so good, this is working correctly, and is exactly how you would expect it to work.</p>
<p>The problem arises when using Annotation Configuration, and it can be difficult to trace back to exactly what might be causing it. If you define &lt;context:annotation-config /&gt; in just the applicationContext.xml file, then the annotation configuration will appear to work (portlet initialization will work, and they should start up appearing to be fully wired). However when the portlets are used, they will start to throw NullPointerExceptions due to beans not being wired. It appears that @Autowired and @Resource are not being interogated when the portlet is running, but worked fine when it was being initialized.</p>
<p>Attempting to diagnoise this issue will have you looking at classpaths, ensuring that there are no duplicated JARs loaded by parent and child classloaders, tracing the spring logs for wiring errors, validating the presence of spring-aspects.jar, etc, etc, etc. While these are all valid approachs, and can be a good way to clean up an application, in all likelyhood what is wrong is that the &lt;context:annotation-config /&gt; element is missing from the individual portlet&#8217;s configuration file. Leaving this element out means that the spring autowiring won&#8217;t be enabled when the portlet is using the portal server&#8217;s classloader, but was enabled when the portlet was initialially loaded by the application server&#8217;s classloader. At least, this appears to be what&#8217;s happening in JBoss Portal Server, your miliage may vary with other servers.</p>
<p>How do you ensure that your annotated portlet will be wired correctly? Simple, add these to both your applicationContext.xml and xxx-Portlet.xml files:</p>
<p>&lt;context:annotation-config /&gt;<br />
&lt;context:spring-configured /&gt;<br />
&lt;aop:aspectj-autoproxy/&gt;</p>
<p>Note: In the case of the xxx-Portlet.xml files, its a good idea to create a common.xml file, then import that in each of the individual portlet files. This allows for commonality between all the portlets, even though they will get their own instance of any beans defined in it.<br />
&lt;import resource=&#8221;classpath:/com/foo/bar/context/common.xml&#8221;/&gt;</p>
<hr /><small>Copyright &copy; 2009<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> c1c694ecf7b1a1f6c941688692febd22)</small>]]></content:encoded>
			<wfw:commentRss>http://www.stephenhouston.com/20090309/spring-portlets-and-annotation-configuration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Log at the correct level</title>
		<link>http://www.stephenhouston.com/20090303/log-at-the-correct-level/</link>
		<comments>http://www.stephenhouston.com/20090303/log-at-the-correct-level/#comments</comments>
		<pubDate>Tue, 03 Mar 2009 18:31:47 +0000</pubDate>
		<dc:creator>Stephen Houston</dc:creator>
				<category><![CDATA[JBoss Portal]]></category>

		<guid isPermaLink="false">http://www.stephenhouston.com/20090303/log-at-the-correct-level/</guid>
		<description><![CDATA[We all know the importance of having good, clear, and useful log messages in our applications (if not then I suggest you read &#34;Release It&#34; from the Pragmatic bookshelf). However it is not always apparent that log messages are written at the correct level.
For example, Log4J has a number of log levels; trace, debug, info, [...]]]></description>
			<content:encoded><![CDATA[<p>We all know the importance of having good, clear, and useful log messages in our applications (if not then I suggest you read &quot;<a href="http://www.pragprog.com/titles/mnee/release-it">Release It</a>&quot; from the Pragmatic bookshelf). However it is not always apparent that log messages are written at the correct level.</p>
<p>For example, Log4J has a number of log levels; trace, debug, info, warn, error and fatal. While it looks like its clear what you should log at each level, some major players get it wrong.</p>
<p>I&#8217;ve spent the last day looking into issues in JBoss Portal where my custom login module wasn&#8217;t working correctly. There was nothing unusual in the log, nor were any errors written to the screen, no indication as to what the problem might have been. After much staring at the config files, it turned out that the package name was wrong, resulting in a ClassNotFoundException. 2 seconds to fix and a few minutes to start the portal and we&#8217;re elected.</p>
<p>However, all of this could have been avoided if JBoss was logging something as important as a ClassNotFoundException at a level other than TRACE (see JIRA, TWITTER). At least ERROR, and probably even FATAL (given the severity of not having a login module) would have been appropriate.</p>
<p>The same issue can be seen with exceptions from the portlets themselves. JBoss logs these at INFO level, which is inappropriate as an exception emitting from the portlet&#8217;s execution stack will have resulted in the user experiencing an error.</p>
<p>So what are appropriate uses of the log levels?</p>
<p><strong>TRACE</strong> &#8211; method entry/exit points, logging of method parameters, any other information that is only useful when tracing why something has gone wrong. This level will generate orders of magnitude more data than the other levels, so should only be enabled selectively on classes when diagnosing issues. Of course, that is not to say that it should only be written selectively, it should be everywhere (introduced using Aspects for the majority of cases), and it must be wrapped by if (logger.isTraceEnabled() when using string concatenation for performance reasons).</p>
<p><strong>DEBUG</strong> &#8211; information relevant for the majority of debug cases, where we aim to get to the bottom of the problem without resorting to TRACE logging. E.g. database access information, generated SQL statements, etc. As with TRACE, these messages must be wrapped in if (logger.isDebugEnabled()).</p>
<p><strong>INFO</strong> &#8211; informative messages from the application. e.g. Database insert took 500 ms, or HTTP POST received containing 600 bytes. These messages should be wrapped in if (logger.isInfoEnabled()).</p>
<p><strong>WARN</strong> &#8211; something MAY be going wrong, but we&#8217;ve managed to recover from it for now. e.g. HTTP connection dropped, retrying.</p>
<p><strong>ERROR</strong> &#8211; something HAS gone wrong, but its limited to the scope of a single user, or single operation. e.g. Database constraint violation, key already exists.</p>
<p><strong>FATAL</strong> &#8211; something HAS SERIOUSLY went wrong. These errors affect multiple users, or multiple operations on the system. They usually need immediate action as the system may no longer be in operation. e.g. Database error: Database has gone away.</p>
<p>Using these simple rules, its not difficult to choose the correct level to log at. By doing so you&#8217;ll make life easier for the next guy.</p>
<hr /><small>Copyright &copy; 2009<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> c1c694ecf7b1a1f6c941688692febd22)</small>]]></content:encoded>
			<wfw:commentRss>http://www.stephenhouston.com/20090303/log-at-the-correct-level/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JBoss Portal and overwrite-workflow</title>
		<link>http://www.stephenhouston.com/20081006/jboss-portal-and-overwrite-workflow/</link>
		<comments>http://www.stephenhouston.com/20081006/jboss-portal-and-overwrite-workflow/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 07:22:14 +0000</pubDate>
		<dc:creator>Stephen Houston</dc:creator>
				<category><![CDATA[JBPM]]></category>
		<category><![CDATA[JBoss Portal]]></category>

		<guid isPermaLink="false">http://www.stephenhouston.com/?p=4</guid>
		<description><![CDATA[The importance of overwrite-workflow in deploying new process definition versions to JBPM in JBoss Portal]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been working on a custom workflow for user registration in JBoss Portal server. This is an area that is lacking in the otherwise adequate JBoss documentation, and has some quirks that confused me and lead to quite a bit of time researching how its implemented to better understand how to make it work. I hope to cover more of the particulars of the jbpm integration in Portal, culminating in a tutorial on how to create a custom user registration process.</p>
<p>But back to the importance of the <span class="code">overwrite-worfklow</span> element in <span class="code">identity-ui-configuration.xml</span>. By default when you first add a new process xml file to the <span class="code">/jboss-portal-ha.sar/portal-identity.sar/con/processes</span> directory, it will be picked up by the portal server on its next restart and loaded into its jbpm database. This can lead you to believe that if the portal server is smart enough to recognize a new process has been deployed then it will be smart enough to recognize that the process has been updated too. Therefore simply overwriting the process definition file will upload a new definition to the database right?</p>
<p>Wrong. Unfortunately the server can only detect new process definition files in that directory, and won&#8217;t examine existing ones to look for changes. To have the portal server update existing processes that have already been deployed you must set <span class="code">overwrite-workflow</span> to <span class="code">true</span>. However as described in the documentation overwrite-workflow does not function just quite how you might like.</p>
<div class="code">overwrite-workflow: overwrites existing process definitions</div>
<p>As it states, it overwrites existing process definitions, but that means that it will deploy new versions of all the process definitions that exist rather than examining them and determining which of them really need to be updated. So even if your process definition has not changed, it will deploy a new version.</p>
<p>Of course this may not matter as jbpm versions all the process definitions in the database, and any suspended or inflight process instances continue to run using the version of the process definition that they started with. Production instances of portal are (hopefully) rarely restarted and therefore will rarely deploy new process instances. But there are a couple of gotchas to watch out for.</p>
<p>Portal is frequently restarted during the development phase, often several times a day. This can lead to the jbpm database quickly having many versions of all the process definitions, which in turn can lead to some interesting problems trying to debug issues as it may not be possible to easily relate a process instance to a process definition xml file. This problem will be worsened if the portal database is shared between several developers.</p>
<p>In production, Portal is often clustered. If <span class="code">overwrite-workflow</span> is set to <span class="code">true</span> on all the portal instances then new definition versions will be deployed when each of the portal instances are restarted. This could quickly become a problem if there are many instances or if the portal server needs to be restarted outside of planned maintenance windows. In production there could well be a large number of running process instances that may need to be related back to a particular version for diagnostic purposes.</p>
<h3>What can be done?</h3>
<p>The simplest solution is to set <span class="code">overwrite-workflow</span> to <span class="code">true</span> only when you actually have new versions of the process definition files to deploy. The downsides of this approach are that it will deploy new versions of all the processes found in the directory, regardless of whether or not they have changed, and that you must remember to keep toggling the switch on and off.</p>
<p>For clustered production nodes, I recommend that during an upgrade process one instance is taken down and used to update the process definitions. After which the setting is immediately set to <span class="code">false</span> again. The same configuration file can be used on all the instances, as its only ever modified briefly during the upgrade of one portal server instance. It should be noted though that if your new definition requires some updated code that you are also deploying, you may well need to take down all of the instances.</p>
<h3>Summary</h3>
<p>In brief, the original problem was that JBoss portal does not pick up updated instances of jbpm process definitions in the <span class="code">/jboss-portal-ha.sar/portal-identity.sar/conf/processes</span> directory. It will only detect process definition files there the first time they are copied there. Subsequent updates to those files will not be deployed.</p>
<p>A workaround/correction to this issue is to set <span class="code">overwrite-workflow</span> to <span class="code">true</span> in <span class="code">identity-ui-configuration.xml</span>. However this has the side-effects of redeploying all the process definitions in the directory, and continuing to redeploy them each time the portal is restarted, potentially leading to a large number of process definition versions in the database.</p>
<hr /><small>Copyright &copy; 2009<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. (Digital Fingerprint:<br /> c1c694ecf7b1a1f6c941688692febd22)</small>]]></content:encoded>
			<wfw:commentRss>http://www.stephenhouston.com/20081006/jboss-portal-and-overwrite-workflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
