<?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>Ryan&#039;s Blog</title>
	<atom:link href="http://cuprak.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cuprak.wordpress.com</link>
	<description>A technical Blog devoted to Java and Mac OS X/Linux development with a touch of robotics from time to time.</description>
	<lastBuildDate>Fri, 10 Feb 2012 01:18:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cuprak.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Ryan&#039;s Blog</title>
		<link>http://cuprak.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cuprak.wordpress.com/osd.xml" title="Ryan&#039;s Blog" />
	<atom:link rel='hub' href='http://cuprak.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Glassfish, XA Transactions, and PostgreSQL</title>
		<link>http://cuprak.wordpress.com/2012/02/09/glassfish-xa-transactions-and-postgresql/</link>
		<comments>http://cuprak.wordpress.com/2012/02/09/glassfish-xa-transactions-and-postgresql/#comments</comments>
		<pubDate>Fri, 10 Feb 2012 01:18:51 +0000</pubDate>
		<dc:creator>rcuprak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cuprak.wordpress.com/?p=74</guid>
		<description><![CDATA[The other night I was working on the source for ActionBazaar (EJB 3.2 in Action) when I ran into a new problem. In the code that I was writing I was both submitting a message to a JMS queue and &#8230; <a href="http://cuprak.wordpress.com/2012/02/09/glassfish-xa-transactions-and-postgresql/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=74&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The other night I was working on the source for ActionBazaar (EJB 3.2 in Action) when I ran into a new problem. In the code that I was writing I was both submitting a message to a JMS queue and also creating a user in a database within stateless session bean. This obviously would use a two-phase commit. When I had setup the JDBC connection pool in Glassfish, I had created it as an XADataSource. Apparently my PostgreSQL setup wasn&#8217;t quite setup to handle this as I immediately got this exception:<br />
<pre class="brush: java; wrap-lines: false;">
Exception [java.lang.RuntimeException: org.postgresql.xa.PGXAException: Error preparing transaction] on Resource [prepare] operation.|#]

[#|2012-02-08T23:37:21.962-0500|WARNING|glassfish3.1.1|javax.enterprise.system.core.transaction.com.sun.jts.jtsxa|_ThreadID=22;_ThreadName=Thread-4;|JTS5068: Unexpected error occurred in rollback
org.postgresql.xa.PGXAException: Error rolling back prepared transaction
	at org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:406)
	at com.sun.gjc.spi.XAResourceImpl.rollback(XAResourceImpl.java:195)
	at com.sun.jts.jta.TransactionState.rollback(TransactionState.java:193)
	at com.sun.jts.jtsxa.OTSResourceImpl.rollback(OTSResourceImpl.java:333)
	at com.sun.jts.CosTransactions.RegisteredResources.distributeRollback(RegisteredResources.java:1038)
	at com.sun.jts.CosTransactions.TopCoordinator.rollback(TopCoordinator.java:2290)
	at com.sun.jts.CosTransactions.CoordinatorTerm.commit(CoordinatorTerm.java:420)
	at com.sun.jts.CosTransactions.TerminatorImpl.commit(TerminatorImpl.java:250)
	at com.sun.jts.CosTransactions.CurrentImpl.commit(CurrentImpl.java:623)
	at com.sun.jts.jta.TransactionManagerImpl.commit(TransactionManagerImpl.java:323)
	at com.sun.enterprise.transaction.jts.JavaEETransactionManagerJTSDelegate.commitDistributedTransaction(JavaEETransactionManagerJTSDelegate.java:186)
	at com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.commit(JavaEETransactionManagerSimplified.java:858)
	at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5114)
	at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
	at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
	at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
	at $Proxy310.createUser(Unknown Source)
	at com.actionbazaar.controller.BidderAccountController.create(BidderAccountController.java:396)
	at com.actionbazaar.controller.org$jboss$weld$bean-actionbazaar-ManagedBean-class_com$actionbazaar$controller$BidderAccountController_$$_WeldClientProxy.create(org$jboss$weld$bean-actionbazaar-ManagedBean-class_com$actionbazaar$controller$BidderAccountController_$$_WeldClientProxy.java)
	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 com.sun.el.parser.AstValue.invoke(AstValue.java:234)
	at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
	at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
	at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
	at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
	at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
	at javax.faces.component.UICommand.broadcast(UICommand.java:315)
	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
	at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
	at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
	at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
	at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
	at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
	at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
	at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
	at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
	at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
	at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
	at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
	at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
	at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
	at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
	at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
	at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
	at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
	at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
	at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
	at java.lang.Thread.run(Thread.java:680)
Caused by: org.postgresql.util.PSQLException: ERROR: prepared transaction with identifier &quot;4871251_CwAAAMWkX2BCZWFnbGUsc2VydmVyLFAzNzAw_QmVhZ2xlLHNlcnZlcixQMzcwMCwA&quot; does not exist
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
	at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:302)
	at org.postgresql.xa.PGXAConnection.rollback(PGXAConnection.java:396)
	... 68 more
|#]
</pre></p>
<p> Digging into it, I discovered that I had to set set <em>max_prepared_transactions</em> and also lower the <em>shared_buffers</em>. The value set the value for <em>max_prepared_transaction</em> to 20 which is the same as <em>max_connections</em>. These changes were made to postgresql.conf. Changing this file of course required a restart of PostgreSQL &#8211; no restart of Glassfish was required. Obviously my database isn&#8217;t optimized and this was just a hack to get things operational. In a real production environment a little more tuning would be required. </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuprak.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuprak.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuprak.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=74&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuprak.wordpress.com/2012/02/09/glassfish-xa-transactions-and-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/79a980940a8a11a4c03f0fd8610d1fe9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcuprak</media:title>
		</media:content>
	</item>
		<item>
		<title>JavaOne Presentations Accepted!</title>
		<link>http://cuprak.wordpress.com/2011/07/12/javaone-presentations-accepted/</link>
		<comments>http://cuprak.wordpress.com/2011/07/12/javaone-presentations-accepted/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 13:55:30 +0000</pubDate>
		<dc:creator>rcuprak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cuprak.wordpress.com/?p=53</guid>
		<description><![CDATA[I am happy to announce that several of my presentations for JavaOne have been accepted: Building a Home Security System with Java NetBeans Project Management I will also be co-presenting with Reza Rahman: Patterns and Best Practices for CDI The &#8230; <a href="http://cuprak.wordpress.com/2011/07/12/javaone-presentations-accepted/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=53&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I am happy to announce that several of my presentations for JavaOne have been accepted:</p>
<ul>
<li>Building a Home Security System with Java</li>
<li>NetBeans Project Management</li>
</ul>
<p>I will also be co-presenting with Reza Rahman:</p>
<ul>
<li>Patterns and Best Practices for CDI</li>
</ul>
<p>The following presentation has been accepted as alternate presentations:</p>
<ul>
<li>Building Sophisticated Text Components </li>
</ul>
<p>I&#8217;ll post links to the abstracts shortly!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuprak.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuprak.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuprak.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=53&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuprak.wordpress.com/2011/07/12/javaone-presentations-accepted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/79a980940a8a11a4c03f0fd8610d1fe9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcuprak</media:title>
		</media:content>
	</item>
		<item>
		<title>Profiling Windows Services</title>
		<link>http://cuprak.wordpress.com/2011/03/21/profiling-windows-services/</link>
		<comments>http://cuprak.wordpress.com/2011/03/21/profiling-windows-services/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 19:42:18 +0000</pubDate>
		<dc:creator>rcuprak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cuprak.wordpress.com/?p=33</guid>
		<description><![CDATA[Netbeans ships with a robust profiler which is easy to use and minimally invasive. You don’t even have to be using Netbeans as your development environment (I use IntelliJ) or even be on the same machine running the VM you &#8230; <a href="http://cuprak.wordpress.com/2011/03/21/profiling-windows-services/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=33&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Netbeans ships with a robust profiler which is easy to use and minimally invasive. You don’t even have to be using Netbeans as your development environment (I use IntelliJ) or even be on the same machine running the VM you want to profile. Thus you can troubleshoot a production environment from afar. Yesterday I figured out how to profile a java process running as a Windows’ service via The Java Service Wrapper. The instructions below assume Java 5 on both Mac and the windows machine as well as Netbeans 6.5+. </p>
<p>To get started, launch Netbeans and select Attach Profiler from the Profile menu.</p>
<div id="attachment_34" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile1.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile1.png?w=300&#038;h=120" alt="" title="profile1" width="300" height="120" class="size-medium wp-image-34" /></a><p class="wp-caption-text">Launching NetBeans Profiler</p></div>
<p>This will bring up the Attach Wizard. Pick the target type as an Application and the attach method as being remote.<br />
<a href="http://cuprak.files.wordpress.com/2011/03/profile2.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile2.png?w=300&#038;h=232" alt="" title="profile2" width="300" height="232" class="aligncenter size-medium wp-image-35" /></a></p>
<p>The next screen will prompt you for the remote host name as well as operating system.<br />
<div id="attachment_36" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile3.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile3.png?w=300&#038;h=232" alt="" title="profile3" width="300" height="232" class="size-medium wp-image-36" /></a><p class="wp-caption-text">Remote Machine</p></div></p>
<p>The next screen just confirms your settings.<br />
<div id="attachment_37" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile4.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile4.png?w=300&#038;h=232" alt="" title="profile4" width="300" height="232" class="size-medium wp-image-37" /></a><p class="wp-caption-text">Confirm Settings</p></div></p>
<p>On this screen you will want to Generate Remote Pack before clicking finish. Clicking the remote pack button will generate a zip file that you will deploy on your windows box. It contains two jar files and a platform specific DLL. By default Netbeans saves the remote pack to an obscure directory under /tmp. I recommend picking a location that is easier to find.<br />
<div id="attachment_38" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile5.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile5.png?w=300&#038;h=232" alt="" title="profile5" width="300" height="232" class="size-medium wp-image-38" /></a><p class="wp-caption-text">Generating Remote Pack</p></div></p>
<p>If you expand the pack you will see the files below. Running the bat files on windows assumes that java.exe is in your path and that JAVA_HOME is set. To profile an application with a 1.5 JVM you would use the profile-15.bat. To profile with 1.6 you would obviously use the profile-16.bat file. You use the bat files as a replacement for typing java at the command line. So to profile foo in bar.jar you would type profile-15.bat -classpath bar.jar foo.<br />
<div id="attachment_39" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile6.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile6.png?w=500" alt="" title="profile6"   class="size-full wp-image-39" /></a><p class="wp-caption-text">File Structure</p></div></p>
<p>On Windows I expanded the zip file at the root of the C volume and changed the name of the directory from <em>profiler-server-win</em> to <em>profiler</em>. Then add the following snippet to your wrapper.conf file:<br />
<code><br />
wrapper.java.additional.1=-agentpath:"C:\profiler\lib\deployed\jdk15\windows\profilerinterface.dll"="C:\profiler\lib",5140<br />
# Disable the pings so wrapper doesn’t kill the JVM while waiting for the profiler.<br />
wrapper.startup.timeout=0<br />
wrapper.ping.timeout=0<br />
</code></p>
<p>When you start the service, the service will pause waiting for the profiler to connect.<br />
<div id="attachment_40" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile7.jpg"><img src="http://cuprak.files.wordpress.com/2011/03/profile7.jpg?w=300&#038;h=47" alt="" title="profile7" width="300" height="47" class="size-medium wp-image-40" /></a><p class="wp-caption-text">Wrapper Waiting</p></div></p>
<p>Click attach in Netbeans &#8211; now you can start digging through the VM!<br />
Note: With remote profiling you cannot generate heap dumps.<br />
<div id="attachment_41" class="wp-caption aligncenter" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/profile8.png"><img src="http://cuprak.files.wordpress.com/2011/03/profile8.png?w=300&#038;h=247" alt="" title="profile8" width="300" height="247" class="size-medium wp-image-41" /></a><p class="wp-caption-text">Profiler in Action</p></div></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuprak.wordpress.com/33/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuprak.wordpress.com/33/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuprak.wordpress.com/33/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=33&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuprak.wordpress.com/2011/03/21/profiling-windows-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/79a980940a8a11a4c03f0fd8610d1fe9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcuprak</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile1.png?w=300" medium="image">
			<media:title type="html">profile1</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile2.png?w=300" medium="image">
			<media:title type="html">profile2</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile3.png?w=300" medium="image">
			<media:title type="html">profile3</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile4.png?w=300" medium="image">
			<media:title type="html">profile4</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile5.png?w=300" medium="image">
			<media:title type="html">profile5</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile6.png" medium="image">
			<media:title type="html">profile6</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile7.jpg?w=300" medium="image">
			<media:title type="html">profile7</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/profile8.png?w=300" medium="image">
			<media:title type="html">profile8</media:title>
		</media:content>
	</item>
		<item>
		<title>Detecting Memory Leaks</title>
		<link>http://cuprak.wordpress.com/2011/03/21/detecting-memory-leaks/</link>
		<comments>http://cuprak.wordpress.com/2011/03/21/detecting-memory-leaks/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 19:31:13 +0000</pubDate>
		<dc:creator>rcuprak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cuprak.wordpress.com/?p=24</guid>
		<description><![CDATA[Troubleshooting a problem over last weekend I ran into a classic memory leak. Yes, you can have memory leaks in Java! If you hold onto references to objects than the Java virtual machine cannot reclaim those objects. In my case, &#8230; <a href="http://cuprak.wordpress.com/2011/03/21/detecting-memory-leaks/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=24&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Troubleshooting a problem over last weekend I ran into a classic memory leak. Yes, you can have memory leaks in Java! If you hold onto references to objects than the Java virtual machine cannot reclaim those objects. In my case, I was processing millions of records but not giving yielding and allowing an object cache to purge itself (my fault &#8211; IDE evidently didn’t copy over an updated config file because I didn’t make a code change). This problem led me to dig into Netbeans and profiling Java processes running as Windows’ services. While Netbeans is a great tool, it does a negative impact upon performance. Obviously a less intrusive tool is needed initially. Java 5 ships with jconsole which drills into a JVM and reports back on heap utilization, thread activity etc. JConsole connects to either local JVM or one on a remote machine. I have also used JConsole to track down a renegade thread that was caught in an IO loop as a result of security software checking for a buffer overrun. </p>
<p>To enable jconsole connectivity for an application simply adding the following VM parameters:<br />
<code><br />
-Dcom.sun.management.jmxremote.port=8999<br />
-Dcom.sun.management.jmxremote.ssl=false<br />
-Dcom.sun.management.jmxremote.authenticate=false<br />
</code></p>
<p>Launch your application and then launch jconsole (jconsole should be in your path).<br />
Below you can see screenshots from my ‘classic’ leak:<br />
<div id="attachment_28" class="wp-caption alignnone" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/memory-leak1.png"><img src="http://cuprak.files.wordpress.com/2011/03/memory-leak1.png?w=300&#038;h=247" alt="" title="memory-leak1" width="300" height="247" class="size-medium wp-image-28" /></a><p class="wp-caption-text">Classic Memory Leak</p></div><br />
<div id="attachment_29" class="wp-caption alignnone" style="width: 310px"><a href="http://cuprak.files.wordpress.com/2011/03/memory-leak2.png"><img src="http://cuprak.files.wordpress.com/2011/03/memory-leak2.png?w=300&#038;h=243" alt="" title="memory-leak2" width="300" height="243" class="size-medium wp-image-29" /></a><p class="wp-caption-text">Classic Memory Leak</p></div></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuprak.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuprak.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuprak.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=24&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuprak.wordpress.com/2011/03/21/detecting-memory-leaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/79a980940a8a11a4c03f0fd8610d1fe9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcuprak</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/memory-leak1.png?w=300" medium="image">
			<media:title type="html">memory-leak1</media:title>
		</media:content>

		<media:content url="http://cuprak.files.wordpress.com/2011/03/memory-leak2.png?w=300" medium="image">
			<media:title type="html">memory-leak2</media:title>
		</media:content>
	</item>
		<item>
		<title>Launching Tomcat with Launchd</title>
		<link>http://cuprak.wordpress.com/2011/03/21/launching-tomcat-with-launchd/</link>
		<comments>http://cuprak.wordpress.com/2011/03/21/launching-tomcat-with-launchd/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 16:04:46 +0000</pubDate>
		<dc:creator>rcuprak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cuprak.wordpress.com/?p=4</guid>
		<description><![CDATA[With the release of MacOS 10.4 (aka Tiger) Apple rolled out launchd which is a system startup program that replaces cron, xinetd, init, etc. It also replaces /Library/StartupItems which I have typically used in the last for launching Tomcat and &#8230; <a href="http://cuprak.wordpress.com/2011/03/21/launching-tomcat-with-launchd/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=4&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With the release of MacOS 10.4 (aka Tiger) Apple rolled out launchd which is a system startup program that replaces cron, xinetd, init, etc. It also replaces /Library/StartupItems which I have typically used in the last for launching Tomcat and Postgresql. To run Tomcat on my Mac Mini I decided to finally figure out launchd. Below is my launchd script file.<br />
Save the following file as org.apache.tomcat.plist in your home directory</p>
<p><pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
  &lt;dict&gt;
  &lt;key&gt;Debug&lt;/key&gt;
   &lt;true/&gt;
    &lt;key&gt;GroupName&lt;/key&gt;
    &lt;string&gt;staff&lt;/string&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;org.apache.tomcat&lt;/string&gt;
    &lt;key&gt;UserName&lt;/key&gt;
    &lt;string&gt;rcuprak&lt;/string&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;Program&lt;/key&gt;
    &lt;string&gt;/usr/bin/java&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
     &lt;string&gt;-Djava.endorsed.dirs=/Applications/apache-tomcat-6.0.14/endorsed&lt;/string&gt;
     &lt;string&gt;-Dcatalina.base=/Applications/apache-tomcat-6.0.14&lt;/string&gt;
     &lt;string&gt;-Dcatalina.home=/Applications/apache-tomcat-6.0.14&lt;/string&gt;
     &lt;string&gt;-Djava.io.tmpdir=/Applications/apache-tomcat-6.0.14/tmp&lt;/string&gt;
     &lt;string&gt;-classpath&lt;/string&gt;
     &lt;string&gt;/Applications/apache-tomcat-6.0.14/bin/tomcat-juli.jar:/Applications/apache-tomcat-6.0.14/bin/commons-daemon.jar:/Applications/apache-tomcat-6.0.14/bin/commons-logging-api.jar:/Applications/apache-tomcat-6.0.14/bin/bootstrap.jar&lt;/string&gt;
     &lt;string&gt;org.apache.catalina.startup.Bootstrap&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;WorkingDirectory&lt;/key&gt;
    &lt;string&gt;/Applications/apache-tomcat-6.0.14&lt;/string&gt;
   &lt;/dict&gt;
&lt;/plist&gt;
</pre></p>
<p>You made need to adjust the paths to reflect the version of Tomcat that you are using as well as the username under which to run tomcat.<br />
Perform the following operations from the command line:</p>
<p><pre class="brush: xml;">
sudo bash
cd /Library/LaunchDaemons
cp /Users/&lt;your username&gt;/org.apache.tomcat.plist .
launchctl load org.apache.tomcat.plist
launchctl start org.apache.tomcat
</pre></p>
<p>Tomcat should startup and will auto start next time the machine is restarted. Any errors will be recorded to syslog and visible if you run the Console application.</p>
<p>The paths to tomcat may need to be adjusted depending upon your version of tomcat.</p>
<p>Save this file to /Library/LaunchDaemons. You must first authenticate as root (sudo bash) before saving the file.</p>
<p>When the machine shuts down I believe launchd sends a kill signal at the process. There aren’t any hooks for invoking a shutdown logic from what I’ve seen thus far.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cuprak.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cuprak.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cuprak.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cuprak.wordpress.com&amp;blog=18227283&amp;post=4&amp;subd=cuprak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cuprak.wordpress.com/2011/03/21/launching-tomcat-with-launchd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/79a980940a8a11a4c03f0fd8610d1fe9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">rcuprak</media:title>
		</media:content>
	</item>
	</channel>
</rss>
