<?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>Piotr Nowicki&#039;s Homepage</title>
	<atom:link href="http://piotrnowicki.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://piotrnowicki.com</link>
	<description>&#34;Simplicity is the ultimate sophistication.&#34;</description>
	<lastBuildDate>Sat, 18 Feb 2012 19:29:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding contextual data to EJB method</title>
		<link>http://piotrnowicki.com/2011/11/adding-contextual-data-to-ejb-method/</link>
		<comments>http://piotrnowicki.com/2011/11/adding-contextual-data-to-ejb-method/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 17:52:13 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[context]]></category>
		<category><![CDATA[interceptor]]></category>
		<category><![CDATA[sessioncontext]]></category>

		<guid isPermaLink="false">http://piotrnowicki.com/?p=733</guid>
		<description><![CDATA[Sometimes you need to pass some additional / contextual data to the called EJB method. Because it&#8217;s a contextual data you don&#8217;t want to end in changing signatures of all your EJB methods just to add a single or few such parameters. It is possible to add context data using the SessionContext object. Take a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to pass some additional / contextual data to the called EJB method. Because it&#8217;s a <em>contextual data</em> you don&#8217;t want to end in changing signatures of all your EJB methods just to add a single or few such parameters. It is possible to add context data using the <a href="http://docs.oracle.com/javaee/6/api/javax/ejb/SessionContext.html"><code>SessionContext</code></a> object.</p>

<span id="more-733"></span>

<p>Take a look at the following code example:</p>

<script src="https://gist.github.com/1389318.js"> </script>

<p>The result of this code execution is:</p>

<blockquote>
  <p>INFO: [myMethod] Method parameter: 2<br />
  INFO: [myMethod] Context parameter: <strong>Context hello!</strong></p>
</blockquote>

<p>A request made to <code>MyService#myMethod(-)</code> will be intercepted by <code>MyInterceptor</code> which will add some contextual data (<code>ctx.getContextData().put(ctxParamKey, "Context hello!")</code>) and invoke the actual EJB.</p>

<p>The EJB (just as interceptor did &#8211; with help of <code>SessionContext</code>) will recover the value saved by the interceptor and can use it right away.</p>

<p>If the parameter wasn&#8217;t set, the null value will be returned. So if you&#8217;d comment this code: <code>ctx.getContextData().put(ctxParamKey, "Context hello!")</code> you can expect following results:</p>

<blockquote>
  <p>INFO: [myMethod] Method parameter: 2<br />
  INFO: [myMethod] Context parameter: <strong>null</strong></p>
</blockquote>

<p>In this way you can pass the contextual data to your EJB methods without changing their signature. Just remember not to overdose with this feature, as it makes testing and auditing more difficult.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/11/adding-contextual-data-to-ejb-method/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Am I in the same transaction? Am I using the same PersistenceContext?</title>
		<link>http://piotrnowicki.com/2011/11/am-i-in-the-same-transaction-am-i-using-the-same-persistencecontext/</link>
		<comments>http://piotrnowicki.com/2011/11/am-i-in-the-same-transaction-am-i-using-the-same-persistencecontext/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 16:32:58 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipselink]]></category>
		<category><![CDATA[entitymanager]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[persistencecontext]]></category>
		<category><![CDATA[transactions]]></category>

		<guid isPermaLink="false">http://piotrnowicki.com/?p=693</guid>
		<description><![CDATA[Recently, I&#8217;ve bumped into few posts on StackOverflow where people tend to compare container managed EntityManager instances (so the one injected by the container) by invoking EntityManager#toString() method. I&#8217;ve felt that it&#8217;s fundamentally wrong to compare EntityManager instances without knowing how they&#8217;re managed by the JPA provider or the Server Application. And what if this [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve bumped into few posts on StackOverflow where people tend to compare container managed <code>EntityManager</code> instances (so the one injected by the container) by invoking <code>EntityManager#toString()</code> method. I&#8217;ve felt that it&#8217;s fundamentally wrong to compare <code>EntityManager</code> instances without knowing how they&#8217;re managed by the JPA provider or the Server Application. And what if this behaviour differs between Application Server vendors?</p>

<p>The JPA provider provides an implementation of <code>EntityManager</code> &#8211; that&#8217;s obvious. More interesting is that the Application Server is scanning all <code>@PersistenceContext</code> fields and wrapping these <code>EntityManager</code>s into its own class &#8211; a proxy &#8211; which delegates requests to the JPA provider&#8217;s <code>EntityManager</code>. Therefore, if you&#8217;re comparing results of <code>toString()</code> method of such <code>EntityManager</code>s, you can&#8217;t say about <strong><code>PersistenceContext</code>s equality</strong> but rather about <strong>Server Application EntityManager equality</strong>.
Needless to say, an Application Server could use one proxy as an access point to different <code>EntityManager</code>s. Without knowing the internals, you&#8217;re not able to say how it will work and decide if your results are meaningful.</p>

<span id="more-693"></span>

<p>One of the ways to cope with this problem might be to <strong>unwrap</strong> the container-provided <code>EntityManager</code> proxy to get to the JPA-provided one. You can do that either using:<br />
- <a href="http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#getDelegate%28%29"><code>EntityManager#getDelegate()</code></a> which returns an <code>Object</code> (this is the depreciated way) or,<br />
- <a href="http://docs.oracle.com/javaee/6/api/javax/persistence/EntityManager.html#unwrap%28java.lang.Class%29"><code>EntityManager#unwrap(JPAProviderSpecificClass)</code></a> which returns JPA-provider specific object (encouraged way).<br />
In this way you&#8217;re one step closer to the victory.</p>

<p>On this point, it&#8217;s worth of noticing, that by the JPA specification, given Persistence Context, when used in transactional environment, is bound to exactly one transaction and is accessible from all components which participates in this transaction. So, maybe we could just <strong>compare if the transaction is the same</strong> and it would be enough to confirm that the <code>PersistenceContext</code>s are the same? You could check transactions for equality using <a href="http://docs.oracle.com/javaee/6/api/javax/transaction/TransactionSynchronizationRegistry.html#getTransactionKey%28%29"><code>TransactionSynchronizationRegistry#getTransactionKey()</code></a>.</p>

<p>Both situations: unwrapping of <code>EntityManager</code> and testing transactions for equality, have been presented in following code.</p>

<p>Moreover, this code shows one more, <strong>very important</strong> thing which might be hard to analyse. In order to invoke EJB call, you need to use it&#8217;s business interface. If you don&#8217;t do that, you&#8217;ll end invoking a <strong>local method call</strong> which <strong>doesn&#8217;t have any EJB nature</strong> &#8211; the container is not able to intercept such method invocation. Therefore, for local call, the <code>@TransactionAttribute</code> will have no meaning.</p>

<p>Take a look at the following code. I&#8217;m using <em>EclipseLink</em> and <em>Glassfish 3.1.1</em>. The client invokes <code>method1()</code>.</p>

<script src="https://gist.github.com/1388726.js"> </script>

<p>Lets examine the exemplary results of the invocation:</p>

<blockquote>
  <p>INFO: [method1] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>173d62d</strong></p>
  
  <p>INFO: [method1] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>1f243df</strong></p>
  
  <p>INFO: [method1] Tx key: JavaEETransactionImpl: txId=45 nonXAResource=23 jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@462718, com.sun.enterprise.resource.pool.PoolManagerImpl$SynchronizationListener@1b0d75f]</p>
  
  <p>INFO: [method2] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>10ba812</strong></p>
  
  <p>INFO: [method2] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>475614</strong></p>
  
  <p>INFO: [method2] Tx key: JavaEETransactionImpl: txId=46 nonXAResource=null jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@1644679]</p>
  
  <p>INFO: [method2] Is Tx1 the same as Tx2? <strong>false</strong></p>
</blockquote>

<p>We have 2 separate transactions (result of comparison &#8211; <strong>false</strong>).<br />
Application Server EntityManager wrappers &#8212; in <code>method1()</code> and <code>method2()</code> &#8212; represents <strong>different instances</strong>.<br />
JPA provider EntityManagers also represents <strong>different instances</strong>.</p>

<p>Now let&#8217;s modify the code a bit and remove or comment the <code>@TransactionAttribute</code> fragment, so <code>method2()</code> will have a default Tx attribute &#8211; <code>REQUIRED</code>. In this case, it will <strong>reuse</strong> the transaction of <code>method1()</code>. Let&#8217;s look at the results:</p>

<blockquote>
  <p>INFO: [method1] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>178fd24</strong></p>
  
  <p>INFO: [method1] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>33517f</strong></p>
  
  <p>INFO: [method1] Tx key: JavaEETransactionImpl: txId=48 nonXAResource=95 jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@12b86b2, com.sun.enterprise.resource.pool.PoolManagerImpl$SynchronizationListener@985158]</p>
  
  <p>INFO: [method2] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>469bc</strong></p>
  
  <p>INFO: [method2] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>33517f</strong></p>
  
  <p>INFO: [method2] Tx key: JavaEETransactionImpl: txId=48 nonXAResource=95 jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@12b86b2, com.sun.enterprise.resource.pool.PoolManagerImpl$SynchronizationListener@985158]</p>
  
  <p>INFO: [method2] Is Tx1 the same as Tx2? <strong>true</strong></p>
</blockquote>

<p>We have 1 transaction (result of comparison &#8211; <strong>true</strong>).<br />
Application Server EntityManager wrappers represents <strong>different instances</strong>.<br />
Both JPA provider EntityManagers represents <strong>the same instance</strong>.</p>

<p>So, as you can see &#8211; only after unwrapping the container-provided <code>EntityManager</code> we were able to see that we, in fact, use the same EntityManager.</p>

<p>At the end, let&#8217;s see get back to the original code but change the invocation of <code>method2()</code> from <code>method1()</code> to be a local call, so we&#8217;ll be using <code>myMethod2(txKey)</code> instead of <code>ctx.getBusinessObject(MyEJB.class).myMethod2(txKey)</code>. Exemplary results might be as follows:</p>

<blockquote>
  <p>INFO: [method1] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>110d926</strong></p>
  
  <p>INFO: [method1] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>12062da</strong></p>
  
  <p>INFO: [method1] Tx key: JavaEETransactionImpl: txId=50 nonXAResource=95 jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@139defe, com.sun.enterprise.resource.pool.PoolManagerImpl$SynchronizationListener@5f299d]</p>
  
  <p>INFO: [method2] Server proxy for EntityManager EM: com.sun.enterprise.container.common.impl.EntityManagerWrapper@<strong>110d926</strong></p>
  
  <p>INFO: [method2] EclipseLink EntityManager: org.eclipse.persistence.internal.jpa.EntityManagerImpl@<strong>12062da</strong></p>
  
  <p>INFO: [method2] Tx key: JavaEETransactionImpl: txId=50 nonXAResource=95 jtsTx=null localTxStatus=0 syncs=[com.sun.ejb.containers.ContainerSynchronization@139defe, com.sun.enterprise.resource.pool.PoolManagerImpl$SynchronizationListener@5f299d]</p>
  
  <p>INFO: [method2] Is Tx1 the same as Tx2? <strong>true</strong></p>
</blockquote>

<p>We have 1 transaction (result of comparison &#8211; <strong>true</strong>).<br />
Both Application Server EntityManager wrappers represents <strong>the same instance</strong>.<br />
Both JPA provider EntityManagers represents <strong>the same instance</strong>.</p>

<p>I hope this sum up what are possible situations you might bump into when using transactional, container-managed <code>EntityManager</code>.</p>

<p>The code snippet which I presented here can be found on <a href="https://gist.github.com/1388726">my Gist</a>.</p>

<p>References:<br />
- <a href="http://www.eclipse.org/forums/index.php?t=rview&amp;goto=757806">EclipseLink Forum</a><br />
- <a href="http://www.java.net/forum/topic/glassfish/glassfish/how-does-glassfish-manage-persistence-contexts-equality-test">Glassfish mailing list</a></p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/11/am-i-in-the-same-transaction-am-i-using-the-same-persistencecontext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing git master after cloning</title>
		<link>http://piotrnowicki.com/2011/09/changing-git-master-after-cloning/</link>
		<comments>http://piotrnowicki.com/2011/09/changing-git-master-after-cloning/#comments</comments>
		<pubDate>Wed, 21 Sep 2011 09:56:57 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[master]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=580</guid>
		<description><![CDATA[If you&#8217;ve cloned a GitHub repository from the original one and not from your forked version and you would like to change it, you can just edit the .git/config file in your project and change the URL of the origin remote: [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* url = VALUE_WHICH_SHOULD_BE_ADJUSTED Simple, easy, and most importantly &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve cloned a GitHub repository from the original one and <strong>not</strong> from your forked version and you would like to change it, you can just edit the <span style="font-family: courier new,courier;"><strong>.git/config</strong></span> file in your project and change the URL of the origin remote:</p>
<pre class="brush:shell">[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = VALUE_WHICH_SHOULD_BE_ADJUSTED</pre>
<p>Simple, easy, and most importantly &#8211; <strong>it works</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/09/changing-git-master-after-cloning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get current JTA transaction status from CMT EJB</title>
		<link>http://piotrnowicki.com/2011/09/get-current-jta-transaction-status-from-cmt-ejb/</link>
		<comments>http://piotrnowicki.com/2011/09/get-current-jta-transaction-status-from-cmt-ejb/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 08:42:30 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[EJB]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[bmt]]></category>
		<category><![CDATA[cmt]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jndi]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[transactions]]></category>
		<category><![CDATA[transactionsynchronizationregistry]]></category>
		<category><![CDATA[usertransaction]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=573</guid>
		<description><![CDATA[You probably know that if you use BMT (Bean Managed Transactions) you can get information about current transaction status by using UserTransaction interface (which implementation can be fetched either by JNDI or using dependency injection) and executing it&#8217;s getStatus() method. If you use CMT (Container Managed Transactions) you cannot use UserTransaction interface. Instead, you can [...]]]></description>
			<content:encoded><![CDATA[<p>You probably know that if you use <em>BMT (Bean Managed Transactions)</em> you can get information about current transaction status by using <a href="http://java.sun.com/javaee/6/docs/api/javax/transaction/UserTransaction.html"><span style="font-family: courier new,courier;">UserTransaction</span></a> interface (which implementation can be fetched either by JNDI or using dependency injection) and executing it&#8217;s <a href="http://java.sun.com/javaee/6/docs/api/javax/transaction/UserTransaction.html#getStatus%28%29"><span style="font-family: courier new,courier;">getStatus()</span></a> method.</p>
<p>If you use <em>CMT (Container Managed Transactions)</em> you cannot use <span style="font-family: courier new,courier;">UserTransaction</span> interface. Instead, you can manage your transaction through <a href="http://java.sun.com/javaee/6/docs/api/javax/ejb/SessionContext.html"><span style="font-family: courier new,courier;">SessionContext</span></a> interface. This interface gives you two places that hooks to the current transaction: <a href="http://java.sun.com/javaee/6/docs/api/javax/ejb/EJBContext.html#setRollbackOnly%28%29"><span style="font-family: courier new,courier;">setRollbackOnly(-)</span></a> and <a href="http://java.sun.com/javaee/6/docs/api/javax/ejb/EJBContext.html#getRollbackOnly%28%29"><span style="font-family: courier new,courier;">getRollbackOnly()</span></a>.<br />
But what if you would like to check the current transaction&#8217;s status?</p>
<p>Well, the first answer would be: think twice if you <strong>really</strong> need to do this.</p>
<p>The transaction is container managed, so<span style="font-family: courier new,courier;"> get/setRollbackOnly(-)</span> should be probably the most important methods for you.</p>
<p>However, if you still need to get some more detailed information about your <em>CMT</em> you can use the <strong><span style="font-family: courier new,courier;"><a href="http://java.sun.com/javaee/6/docs/api/javax/transaction/TransactionSynchronizationRegistry.html">TransactionSynchronizationRegistry</a></span></strong> interface which (just like <span style="font-family: courier new,courier;">UserTransaction</span>) can be fetched using JNDI or <span style="font-family: courier new,courier;">@Resource</span> annotation:</p>
<pre class="brush:java">@Resource
TransactionSynchronizationRegistry txReg;

txReg.getTransactionStatus();</pre>
<p><a href="http://java.sun.com/javaee/6/docs/api/constant-values.html#javax.transaction.Status.STATUS_ACTIVE">Here</a> you can find what the integer status returned by this method invocation means.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/09/get-current-jta-transaction-status-from-cmt-ejb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why my hosts file doesn&#8217;t work in Windows?</title>
		<link>http://piotrnowicki.com/2011/08/why-my-hosts-file-doesnt-work-in-windows/</link>
		<comments>http://piotrnowicki.com/2011/08/why-my-hosts-file-doesnt-work-in-windows/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 10:08:55 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[WWW]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[ff]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=554</guid>
		<description><![CDATA[Once again Windows know exactly how to surprise me. I&#8217;ve added entries to the Windows/System32/drivers/etc/hosts on my remote Windows 2008 Server. The entry was resolved properly as it could be tested from the command line (ping, telnet, etc.) but in IE and FF browsers it didn&#8217;t work. DNS flushing, clearing browsers data or restart didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Once again Windows know exactly how to surprise me.</p>
<p>I&#8217;ve added entries to the <span style="font-family: 'courier new', courier;">Windows/System32/drivers/etc/hosts</span> on my remote Windows 2008 Server. The entry was resolved properly as it could be tested from the command line (ping, telnet, etc.) but in IE and FF browsers it didn&#8217;t work.</p>
<p>DNS flushing, clearing browsers data or restart didn&#8217;t help a bit. <a href="http://www.tomshardware.co.uk/forum/196045-36-hosts-file-used" target="_blank">It occurs</a> that the IE had a proxy settings and apparently (when any proxy is set) it refuses to take hosts file under consideration. It affects not only IE but also the FF.</p>
<p>The solution was to remove the proxy setup in IE and from this moment the hosts file entries were resolved properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/08/why-my-hosts-file-doesnt-work-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Screw Eclipse&#8230; and packages&#8230; and IDE&#8230; no, wait &#8211; screw me!</title>
		<link>http://piotrnowicki.com/2011/08/screw-eclipse-and-packages-and-ide-no-wait-screw-myself/</link>
		<comments>http://piotrnowicki.com/2011/08/screw-eclipse-and-packages-and-ide-no-wait-screw-myself/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 08:44:09 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jersey]]></category>
		<category><![CDATA[singleton]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=569</guid>
		<description><![CDATA[Just a note to myself &#8211; always check what classes are you importing in IDE, because if you see @Singleton in your class, it doesn&#8217;t mean it will work as a EJB Singleton. In my case it wasn&#8217;t referencing to javax.ejb.Singleton as I assumed, but com.sun.jersey.spi.resource.Singleton&#8230; Wasted 2 hours of looking for the answer or [...]]]></description>
			<content:encoded><![CDATA[<p>Just a note to myself &#8211; <strong>always</strong> check what classes are you importing in IDE, because if you see <span style="font-family: 'courier new', courier;"><strong>@Singleton</strong></span> in your class, it doesn&#8217;t mean it will work as a EJB Singleton. In my case it wasn&#8217;t referencing to <strong><span style="font-family: 'courier new', courier;">javax.ejb.Singleton</span></strong> as I assumed, but <strong><span style="font-family: 'courier new', courier;">com.sun.jersey.spi.resource.Singleton</span>&#8230;</strong></p>
<p>Wasted 2 hours of looking for the answer or issue in a glassfish-3.1 JIRA.</p>
<p>Did I mention I should <strong>always</strong> check the exact package of the imported class&#8230;?</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/08/screw-eclipse-and-packages-and-ide-no-wait-screw-myself/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Running GUI applications over SSH</title>
		<link>http://piotrnowicki.com/2011/08/running-gui-applications-over-ssh/</link>
		<comments>http://piotrnowicki.com/2011/08/running-gui-applications-over-ssh/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 08:47:12 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[X11]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=542</guid>
		<description><![CDATA[If you want to execute a GUI based application on the remote server through SSH, you can achieve it quite easily using the ssh command. Just type ssh -X username@server The -X flag is used to define the DISPLAY environmental variable on the remote host, so each X11 executed application will be forwarded to your [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to execute a GUI based application on the remote server through SSH, you can achieve it quite easily using the ssh command. Just type</p>
<pre class="brush:shell">ssh -X username@server</pre>
<p>The <span style="font-family: courier new,courier;"><strong>-X</strong></span> flag is used to define the <span style="font-family: courier new,courier;">DISPLAY</span> environmental variable on the remote host, so each X11 executed application will be forwarded to your machine.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/08/running-gui-applications-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to find out what GNU/Linux distribution you&#8217;re using</title>
		<link>http://piotrnowicki.com/2011/08/gnulinux-distribution-info/</link>
		<comments>http://piotrnowicki.com/2011/08/gnulinux-distribution-info/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 08:40:26 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[uname]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=544</guid>
		<description><![CDATA[Recently I needed to find out what GNU/Linux a terminal-only server is using. The most obvious thing I could think of was to use: uname -a Unfortunately, it will return the kernel information only &#8211; no details about the distribution though. The distribution info is located in a different file which is dependent on&#8230; the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I needed to find out what GNU/Linux a terminal-only server is using. The most obvious thing I could think of was to use:</p>
<pre class="brush:shell">uname -a</pre>
<p>Unfortunately, it will return the kernel information only &#8211; <strong>no details about the distribution</strong> though.<br />
The distribution info is located in a different file which is dependent on&#8230; the distribution itself. Check out the list of those filenames <a href="http://linuxmafia.com/faq/Admin/release-files.html" target="_blank">here</a>.</p>
<p>As a majority of those files ends with &#8220;release&#8221; part, in most cases it should be enough to execute the following command:</p>
<pre class="brush:shell">cat /etc/*release</pre>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/08/gnulinux-distribution-info/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ShrinkWrap &#8211; adding classes to non-root location</title>
		<link>http://piotrnowicki.com/2011/06/shrinkwrap-adding-classes-to-non-root-location/</link>
		<comments>http://piotrnowicki.com/2011/06/shrinkwrap-adding-classes-to-non-root-location/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 16:30:46 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[ShrinkWrap]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=527</guid>
		<description><![CDATA[If you want to add your classes (or any other resources) to your ShrinkWrap archive to a non-root location, you can use the following: @Deployment public static JavaArchive deploy() { // This is the classes and resources archive JavaArchive ar; ar = ShrinkWrap.create(JavaArchive.class, "resources.jar") .addPackage(TestClass.class.getPackage()); /*   * The 'ar' archive will be added to [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to add your classes (or any other resources) to your <a href="http://www.jboss.org/shrinkwrap/">ShrinkWrap</a> archive to a non-root location, you can use the following:</p>
<pre class="brush:java">@Deployment
public static JavaArchive deploy() {

   // This is the classes and resources archive
   JavaArchive ar;
   ar = ShrinkWrap.create(JavaArchive.class, "resources.jar")
                  .addPackage(TestClass.class.getPackage());

   /*
    * The 'ar' archive will be added to the 'yourDir', so you'll
    * end with test.jar#/yourDir/TestClassPackage/TestClass.class
    */
   JavaArchive endArch;
   endArch = ShrinkWrap.create(JavaArchive.class, "test.jar")
                       .merge(ar, "yourDir");

   endArch.merge(ar, "yourDir");

   return endArch;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/06/shrinkwrap-adding-classes-to-non-root-location/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arquillian, ShrinkWrap and archive filename</title>
		<link>http://piotrnowicki.com/2011/06/arquillian-shrinkwrap-and-archive-filename/</link>
		<comments>http://piotrnowicki.com/2011/06/arquillian-shrinkwrap-and-archive-filename/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 16:16:54 +0000</pubDate>
		<dc:creator>Piotr</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Arquillian]]></category>
		<category><![CDATA[EJB]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jboss]]></category>
		<category><![CDATA[ShrinkWrap]]></category>
		<category><![CDATA[war]]></category>

		<guid isPermaLink="false">http://nullhaus.com/?p=521</guid>
		<description><![CDATA[When you create a deployment using Arquillian (great test runner for testing your Java EE code in the container of your choice: jBoss, Glassfish, OpenEJB, &#8230; either in embedded, managed or remote mode) remember that the name of the deployment archive file is the exact filename that will be executed in the container. It does [...]]]></description>
			<content:encoded><![CDATA[<p>When you create a deployment using <a href="http://www.jboss.org/arquillian">Arquillian</a> (great test runner for testing your Java EE code in the container of your choice: jBoss, Glassfish, OpenEJB, &#8230; either in embedded, managed or remote mode) remember that the name of the deployment archive file is the <strong>exact</strong> filename that will be executed in the container.</p>
<p>It does make a difference if you use <span style="font-family: courier new,courier;">*.war</span> or <span style="font-family: courier new,courier;">*.jar</span> for your deployment, so beware the following construct if it&#8217;s not exactly <strong>what you intended to do</strong>:</p>
<pre class="brush:java">@Deployment
public static JavaArchive deploy() {
    JavaArchive ar;
    ar = ShrinkWrap.create(JavaArchive.class, "YourTests.war")
                   .addPackage(YourTestClass.class.getPackage());

    return ar;
}</pre>
<p>In this case you can end with <span style="font-family: courier new,courier;">ClassNotFoundException</span> for <span style="font-family: courier new,courier;">YourTestClass</span>.<br />
Just use the archive format you need (in this case I needed a <span style="font-family: courier new,courier;">*.jar</span> and not a <span style="font-family: courier new,courier;">*.war</span>) as this does make a difference for the application server.</p>
]]></content:encoded>
			<wfw:commentRss>http://piotrnowicki.com/2011/06/arquillian-shrinkwrap-and-archive-filename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

