<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Oleg's Weblog</title>
	<atom:link href="http://olegz.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://olegz.wordpress.com</link>
	<description>My Tech Rant</description>
	<lastBuildDate>Mon, 23 Mar 2009 12:35:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='olegz.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Oleg's Weblog</title>
		<link>http://olegz.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://olegz.wordpress.com/osd.xml" title="Oleg&#039;s Weblog" />
	<atom:link rel='hub' href='http://olegz.wordpress.com/?pushpress=hub'/>
		<item>
		<title>JMX connectivity through the firewall</title>
		<link>http://olegz.wordpress.com/2009/03/23/jmx-connectivity-through-the-firewall/</link>
		<comments>http://olegz.wordpress.com/2009/03/23/jmx-connectivity-through-the-firewall/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 12:25:41 +0000</pubDate>
		<dc:creator>Oleg Zhurakousky</dc:creator>
				<category><![CDATA[JMX]]></category>
		<category><![CDATA[osgi]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://olegz.wordpress.com/?p=148</guid>
		<description><![CDATA[Recently I&#8217;ve been asked to help out a customer who was having issues with JMX connectivity to Spring Source dmServer through the firewall. However, one thing I want to point out right up front is that the issue is rather generic and has nothing to do with dmServer. It is really about understanding JMX, RMI [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=148&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been asked to help out a customer who was having issues with JMX connectivity to Spring Source dmServer through the firewall. However, one thing I want to point out right up front is that the issue is rather generic and has nothing to do with dmServer. It is really about understanding JMX, RMI and proper configuration. But I will use dmServer and its configuration as an example.<br />
Here is the sample JMX configuration options provided in the dmServer startup script:<br />
<span style="color:#808080;"> -Dcom.sun.management.jmxremote.port=${jmxPort} \<br />
-Dcom.sun.management.jmxremote.authenticate \<br />
-Dcom.sun.management.jmxremote.password.file=${jmxUsersPath} \<br />
-Djavax.net.ssl.keyStore=${keystorePath} \<br />
-Djavax.net.ssl.keyStorePassword=${keystorePassword} \<br />
-Dcom.sun.management.jmxremote.ssl=true \<br />
-Dcom.sun.management.jmxremote.ssl.need.client.auth=false&#8221;</span><br />
This will enable JMX agent (MBean Server) when you start dmServer. Once started you can now monitor your process via JMX-compliant tool such as <strong>jconsole</strong>. Connectivity could be local or remote.<br />
The above configuration seem to provide everything we need to access this process through the firewall, since <strong><em>com.sun.management.jmxremote.port</em></strong> is obviously the port that we need to open in the firewall. However there is a caveat.<br />
Once connected to JMXRegistry running on the port specified by <em><strong>com.sun.management.jmxremote.port</strong></em> property, the actual objects are served by RMIServer which is running on different port. Unfortunately this port is chosen randomly by default instance of JMX Agent and there is no <strong>–D</strong> option to specify it. Obviously going through the firewall would require opening up two ports and with random port it presents a delicate issue.<br />
Fortunately it is easily solvable by writing a custom Java Agent where you can programmatically specify each port and externalize it through custom properties (I am attaching sample code).<br />
More info here:<a href="http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html"> http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html</a><br />
In the nutshell, the custom agent will take the port value provided by the <strong><em>com.sun.management.jmxremote.port </em></strong> property and will create a second port (RMIServer port) by incrementing it by 1. (in our case the port specified is 44444 which makes RMIServer port 44445)<br />
Once such agent is in place (JAR) and the appropriate ports are open in the firewall all you need is modify the startup script to include <em>–javaagent </em>option providing the JAR.<br />
<span style="color:#808080;">. . . . .<br />
$JAVA_HOME/bin/java \<br />
<strong> -javaagent:/Users/olegzhurakousky/../../../dmserver.jmx-0.0.1-SNAPSHOT.jar </strong><br />
$JAVA_OPTS \<br />
. . . . .</span><br />
Well, that really only solved one half of the problem, since by default RMI stubs sent to the client contain the server&#8217;s private address instead of the public</p>
<p>Just look at this <em>tcpdump</em> fragment while monitoring the client’s access (<em>jconsole</em> running on the local network):<br />
<span style="color:#808080;">. . . . . . .<br />
09:41:23.778663 IP 72.234.14.89.44444 &gt; 192.168.1.156.52926: . ack 71 win 65535 &lt;nop,nop,timestamp 919359579 313492&gt;<br />
09:41:23.779958 IP 192.168.1.152.44444 &gt; 72.234.14.89.52926: P 20:251(231) ack 71 win 65535 &lt;nop,nop,timestamp 919359579 313492&gt;<br />
09:41:23.780456 IP 72.234.14.89.44444 &gt; 192.168.1.156.52926: P 20:251(231) ack 71 win 65535 &lt;nop,nop,timestamp 919359579 313492&gt;<br />
<strong>09:41:23.796075 IP 192.168.1.156.37861 &gt; 192.168.1.152.44445: S 1334070579:1334070579(0) win 5840 &lt;mss 1460,sackOK,timestamp 313496 0,nop,wscale 6&gt;<br />
09:41:23.796328 IP 192.168.1.152.44445 &gt; 192.168.1.156.37861: S 1760846938:1760846938(0) ack 1334070580 win 65535 &lt;mss 1460,nop,wscale 3,nop,nop,timestamp 919359579 313496,sackOK,eol&gt;</strong><br />
. . . . . . .</span><br />
You can clearly see that 192.168.1.156 (client i.e., <em>jconsole</em>) is attempting to connect directly to 192.168.1.152 (server) instead of 72.234.14.89 which is a public IP, although the JMX URL is:<br />
<strong>service:jmx:rmi://72.234.14.89:44445/jndi/rmi://72.234.14.89:44444/jmxrmi<br />
</strong><br />
If I was behind the firewall I would obviously had problems connecting to 192.168.1.152<br />
Fortunately, this one is easy to fix. All you need is to provide additional option on the server side (<em><strong>java.rmi.server.hostname</strong></em>) and add it to the script This option represents the host name string that should be associated with remote stubs for locally created remote objects, in order to allow clients to invoke methods on the remote object:<br />
<span style="color:#808080;">. . . . . . .<br />
JMX_OPTS=&#8221; \<br />
$JMX_OPTS \<br />
-Dcom.sun.management.jmxremote.port=${jmxPort} \<br />
<strong> -Djava.rmi.server.hostname=72.234.14.89 \</strong><br />
. . . . . . . </span><br />
That is all .<br />
Start<strong> jconsole: ./jconsole.sh service:jmx:rmi://&lt;pub-ip&gt;:&lt;rmi-port&gt;/jndi/rmi://&lt;pub-ip&gt;:&lt;registry-port&gt;/jmxrmi</strong><br />
Once you modify the script and start the dmServer you should see output similar to this:<br />
<span style="color:#808080;">. . . . . .<br />
oleg-2:bin olegzhurakousky$ ./startup.sh<br />
com.springsource.rmiregistry.port:44444<br />
com.springsource.rmiserver.port:44445<br />
Getting the platform&#8217;s MBean Server<br />
Local Connection URL: service:jmx:rmi://oleg-2.local:44445/jndi/rmi://oleg-2.local:44444/jmxrmi<br />
Public Connection URL: service:jmx:rmi://72.234.14.89:44445/jndi/rmi://72.234.14.89:44444/jmxrmi<br />
Creating RMI connector server<br />
[2009-02-26 18:53:34.031] main                     &lt;SPKB0001I&gt; Server starting.<br />
[2009-02-26 18:53:35.943] main                     &lt;SPOF0001I&gt; OSGi telnet console available on port 2401.<br />
[2009-02-26 18:53:41.558] main                     &lt;SPKE0000I&gt; Boot subsystems installed.<br />
. . . . .</span></p>
<p><span style="color:#808080;">The sample code could be downloaded from here: <a href="http://springosgi.googlepages.com/JMXAgent.java">JMXAgent.java</a><br />
</span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/olegz.wordpress.com/148/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/olegz.wordpress.com/148/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/olegz.wordpress.com/148/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=148&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://olegz.wordpress.com/2009/03/23/jmx-connectivity-through-the-firewall/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d32cee48943b91e719134cd9cc6cc752?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Oleg Zhurakousky</media:title>
		</media:content>
	</item>
		<item>
		<title>OSGi and &#8220;uses&#8221; directive</title>
		<link>http://olegz.wordpress.com/2008/12/09/osgi-and-uses-directive/</link>
		<comments>http://olegz.wordpress.com/2008/12/09/osgi-and-uses-directive/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 21:23:46 +0000</pubDate>
		<dc:creator>Oleg Zhurakousky</dc:creator>
				<category><![CDATA[osgi]]></category>

		<guid isPermaLink="false">http://olegz.wordpress.com/?p=123</guid>
		<description><![CDATA[In current Java model, uniqueness of the class is defined by fully qualified name of the class plus the defining class loader. This mechanism actually creates a problem, where it is quite easy to have multiple versions of the same class loaded in a single JVM space. This happens quite a lot, giving Java’s ability [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=123&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In current Java model, uniqueness of the class is defined by fully qualified name of the class plus the defining class loader. This mechanism actually creates a problem, where it is quite easy to have multiple versions of the same class loaded in a single JVM space. This happens quite a lot, giving Java’s ability to load classes dynamically. Modern framework such as Spring, Hibernate and others utilize this feature quite a bit. However if not used properly, having multiple instances of class loaded often results in memory leaks and various class type exceptions such as CCE, NCDF, Linkage etc. . .</p>
<p>OSGi approaches this problem rather differently and it does so by bringing the concept of class/packages version into the runtime environment, thus allowing you to still have multiple versions of the same class loaded without creating conflicts.  But it comes with the price. OSGi defines a very strict visibility and class sharing rules that must be explicitly declared, while at the same time moving us a way from the legacy mentality of the linear class path we are all so used to.</p>
<p>The <a href="http://olegz.wordpress.com/documents-and-articles/osgi-uses/">following article</a> article concentrates on one area of OSGi dependency resolution mechanism and that is “uses” directive. . .<a href="http://olegz.wordpress.com/documents-and-articles/osgi-uses/"></a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/olegz.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/olegz.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/olegz.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=123&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://olegz.wordpress.com/2008/12/09/osgi-and-uses-directive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d32cee48943b91e719134cd9cc6cc752?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Oleg Zhurakousky</media:title>
		</media:content>
	</item>
		<item>
		<title>To Spring or not to Spring. . .</title>
		<link>http://olegz.wordpress.com/2008/12/08/spring-or-not-spring/</link>
		<comments>http://olegz.wordpress.com/2008/12/08/spring-or-not-spring/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 20:29:30 +0000</pubDate>
		<dc:creator>Oleg Zhurakousky</dc:creator>
				<category><![CDATA[Spring]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[specifications]]></category>

		<guid isPermaLink="false">http://olegz.wordpress.com/?p=67</guid>
		<description><![CDATA[Just another rant on the whole JEE vs. Spring and specifications in general . . . Here is how I see it: JEE(J2EE) is a specification which addresses some areas of concerns derived from the concepts of Enterprise Java. Spring is an open source framework which also addresses some areas of concerns derived from the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=67&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just another rant on the whole JEE vs. Spring and specifications in general . . .<br />
Here is how I see it:<br />
JEE(J2EE) is a <em>specification</em> which addresses some areas of concerns derived from the concepts of Enterprise Java.<br />
Spring is an <em>open source framework</em> which also addresses some areas of concerns derived from the concepts of Enterprise Java.<br />
One is managed by a large group of people and vendors, each with their own egos and potentially contradicting agendas, while the other one is managed by a smaller like-minded group of people with two common interests and that is to <em>&#8220;make it better then other guy&#8221;</em> and<em> &#8220;make it quicker then other guy&#8221;</em>.</p>
<p>So the real sticking point here is the <strong>speed and quality of innovation</strong>. In the privately managed framework such as Spring a good idea could be turned into concrete implementation in days (some times hours), while it takes years to accomplish anything in any managed specification (not only JEE). Take Hibernate&#8217;s capabilities of today vs. its derived specification such as JPA for example. Or take capabilities of Spring vs. various JEE implementations? You can clearly see how far behind JEE really is.<br />
One might argue that specification gives you portability across platforms. . . well not true!<br />
JEE, although meant to be portable, never has been. JEE application on JBoss is not portable to another platform such as WAS unless you spend some time making it portable. I spent two years of my career migrating apps from WAS and WebLogic to JBoss and it was anything but trivial due to all kinds of proprietary extensions and APIs on either platforms which resulted in a typical vendor lock-in.<br />
Spring on the other hand, is giving you the same functionality as JEE plus much more, but in the detached non-JEE container called Application Context, while providing basic integration of Application Context with <strong>standard</strong> JEE services (e.g., JTA, DataSources, Messaging etc&#8230;), thus making your Spring based application completely portable across all JEE containers (You don&#8217;t have WAS version of Spring vs. the same of BEA). Yes that raises another question; If Spring can do all of what JEE does, why do I need JEE in the first place? Well, you don&#8217;t. . ., but that is a different discussion <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Going back to the question of portability and innovation; If I can&#8217;t achieve portability and innovation, what is the value in following any specification? The way I see it I will always be behind the &#8220;other guy&#8221;.<br />
Spring and other privately managed frameworks (open source and not) are evolving into conventions that developers understand and feel comfortable with.  And good conventions are just as good if not better then any specification. . .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/olegz.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/olegz.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/olegz.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=67&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://olegz.wordpress.com/2008/12/08/spring-or-not-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d32cee48943b91e719134cd9cc6cc752?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Oleg Zhurakousky</media:title>
		</media:content>
	</item>
		<item>
		<title>OSGi and Class.forName(..)</title>
		<link>http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/</link>
		<comments>http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 19:21:23 +0000</pubDate>
		<dc:creator>Oleg Zhurakousky</dc:creator>
				<category><![CDATA[osgi]]></category>
		<category><![CDATA[class.forName]]></category>

		<guid isPermaLink="false">http://olegz.wordpress.com/?p=54</guid>
		<description><![CDATA[While I was presenting &#8220;Intro to OSGi&#8221; at the recent Philadelphia JUG, I&#8217;ve been asked several questions about java class loader dynamics in OSGI environment.  The following post discusses the implication of using Class.forName(..) in OSGi environment. Let&#8217;s say we have the following code: Class.forName(&#8221;org.bar.Foo&#8221;); Usually the same class loader that loaded the class which [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=54&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I was presenting &#8220;<a href="http://phillyjug.jsync.com/meetings/osgi-introduction-by-oleg-zhurakousky">Intro to OSGi</a>&#8221; at the recent Philadelphia JUG, I&#8217;ve been asked several questions about java class loader dynamics in OSGI environment.  The following post discusses the implication of using <strong>Class.forName(..)</strong> in OSGi environment.</p>
<p>Let&#8217;s say we have the following code:</p>
<p><em>Class.forName(&#8221;org.bar.Foo&#8221;);</em></p>
<p>Usually the same class loader that loaded the class which contains this code will be used. This class loader will follow standard java class loading delegation mechanism to discover and load the class.</p>
<p>However. . .</p>
<p>In the case of the OSGi, each bundle will have its own class loader and outside of<em> java.*</em> packages, this class loader doesn&#8217;t follow standard java class loading delegation mechanism and strictly relies on visibility rules and constraint resolution mechanism defined by OSGi &#8211; such as providing<em> Import/Export-Package</em>, <em>Required-Bundle</em> and other manifest headers.</p>
<p>This class loader has two responsibilities</p>
<ol>
<li>Load classes available to the Bundle Space, where <em>Bundle Space = Bundle JAR itself + attached Fragment Bundles</em></li>
<li>Collaborate with class loaders of other bundles to reach all classes that are visible to a bundle based on OSGi visibility rules and contsraint resolution mechanism. In other words it must colaborate with Bundle&#8217;s Class Space, where <em>Bundle&#8217;s Class Space = Bundle-Space + Import-Pckage + Import-Bundle etc&#8230;</em></li>
</ol>
<p>The issue with using <strong>Class.forName(..)</strong> in the OSGi environment starts when an attempt is made to resolve such Bundle&#8217;s Class Space. To do that we have to make sure that the target class is in the Bundle&#8217;s Class Space, which means that advertising bundle with proper <em>Export-Package: org.bar.Foo </em>declaration must be available and appropriate dependency strategy is provided in the bundle that relies on such dependency (e.g., <em>Import-Package: org.bar.foo</em> or <em>Require-Bundle: Foo</em>).</p>
<p>The work of discovering dependencies and providing appropriate manifest headers is not a difficult task (after all in the conventional application model all dependent JARs are in the class path) and could be performed manually or using automated tools such as <a href="http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html">maven-bundle-plugin</a>, by recursively evaluating dependencies of your JAR</p>
<p>However, giving dynamic nature of <strong>Class.forName(..) </strong>and lack of compile time validation, the target class might not be available or even known at the time of manifest creation, thus making such determination impossible. The result are missing <em>Import/Export-Package, Require-Bundle</em> etc&#8230;, headers which creates a nasty problem, when target Class is not available to the Bundle&#8217;s Class Space resulting in ClassNotFoundException being thrown.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/olegz.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/olegz.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/olegz.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=54&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://olegz.wordpress.com/2008/11/05/osgi-and-classforname/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d32cee48943b91e719134cd9cc6cc752?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Oleg Zhurakousky</media:title>
		</media:content>
	</item>
		<item>
		<title>Trip to Japan</title>
		<link>http://olegz.wordpress.com/2008/03/03/trip-to-japan/</link>
		<comments>http://olegz.wordpress.com/2008/03/03/trip-to-japan/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 04:11:46 +0000</pubDate>
		<dc:creator>Oleg Zhurakousky</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[japan]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://olegz.wordpress.com/?p=47</guid>
		<description><![CDATA[Next week (March 13th) I&#8217;ll be flying to Japan, to help yet another very large client to migrate from BEA to JBoss and being strong supporter of Open Source I love every chance I get to do something like that. But besides the fact that I&#8217;ve never been to Japan and feel rather excited to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=47&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Next week (March 13th) I&#8217;ll be flying to Japan, to help yet another very large client to migrate from BEA to JBoss and being  strong supporter of Open Source I love every chance I get to do something like that. But besides the fact that I&#8217;ve never been to Japan and feel rather excited to actually go there, I am starting to think more and more about the fact that what I am actually going to be doing is migrating from proprietary implementation of legacy technology (J2EE) to its open source counterpart.  Yes, in the past few years J2EE has become legacy technology especially with products and  frameworks led by <a href="http://www.springframework.org/" target="_blank">Spring </a>(full stack), <a href="http://www.terracotta.org/" target="_blank">Terracotta</a>, <a href="http://www.apache.org/" target="_blank">ASF</a> and technologies such as <a href="http://www.osgi.org/Main/HomePage">OSGi </a>as well as  many others. J2EE (with all its variations) has become outdated and can no longer support demands of the current enterprise. . . And of course I&#8217;ll be pitching these thoughts and all my other IT passions while I am in Tokyo, but for now I am simply looking forward to lots of Sushi and whatever else that is cool to do or see while I am there.  .  .</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/olegz.wordpress.com/47/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/olegz.wordpress.com/47/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/olegz.wordpress.com/47/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/olegz.wordpress.com/47/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/olegz.wordpress.com/47/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=olegz.wordpress.com&amp;blog=2491507&amp;post=47&amp;subd=olegz&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://olegz.wordpress.com/2008/03/03/trip-to-japan/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d32cee48943b91e719134cd9cc6cc752?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Oleg Zhurakousky</media:title>
		</media:content>
	</item>
	</channel>
</rss>
