<?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>Tony Yan</title>
	<atom:link href="http://tonyyan.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tonyyan.wordpress.com</link>
	<description>Passion and Imagination at Work</description>
	<lastBuildDate>Sat, 21 Jan 2012 04:49:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='tonyyan.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Tony Yan</title>
		<link>http://tonyyan.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://tonyyan.wordpress.com/osd.xml" title="Tony Yan" />
	<atom:link rel='hub' href='http://tonyyan.wordpress.com/?pushpress=hub'/>
		<item>
		<title>SSL issues by Soap Client from within Weblogic Server</title>
		<link>http://tonyyan.wordpress.com/2012/01/20/ssl-issues-by-soap-client-from-within-weblogic-server/</link>
		<comments>http://tonyyan.wordpress.com/2012/01/20/ssl-issues-by-soap-client-from-within-weblogic-server/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 04:38:38 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[SOAP]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[WEBLOGIC]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=61</guid>
		<description><![CDATA[Hi, Happy Chinese New Year! Every problem that took me more than 2 days to find the solution deserves a writeup! This time it was a known issue when starts a SOAP request from a Webservice client from within Weblogic server, over HTTPS.  The problem I had was that we use a wildcard certificate for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=61&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Happy Chinese New Year!</p>
<p>Every problem that took me more than 2 days to find the solution deserves a writeup! This time it was a known issue when starts a SOAP request from a Webservice client from within Weblogic server, over HTTPS.  The problem I had was that we use a wildcard certificate for the receiving host, something like *.tonyyan.com, but the hostname is something like server1.tonyyan.com. WLS by default will fail the hostname verification process, hence fails the SSL handshake. There is a very nice link  <a href="http://jandrewthompson.blogspot.com/2010/04/weblogic-and-wildcard-ssl-certificates.html">http://jandrewthompson.blogspot.com/2010/04/weblogic-and-wildcard-ssl-certificates.html</a> where it is described how to impl. and use a custom hostname verifier. However, I liked to use it just for my own client instead of changing verifier at the WLS server level. Thus, I used this code to by pass hostname verification all together (warning, this should not be used in PROD env, where some better and strict logic should be used to control wild card certificate against its hostname. Or, you could be vulnerable to man-in-middle attack).</p>
<p>//BindingProvider<br />
BindingProvider bp = (BindingProvider)port;</p>
<p>// hostname issue &#8211; allow any hostname vs. its certificate<br />
Map&lt;String, Object&gt; ctxt = bp.getRequestContext();</p>
<p>HostnameVerifier hv = new HostnameVerifier() {<br />
public boolean verify(String urlHostName,SSLSession session) {<br />
logger.info(&#8220;HostnameVerifier without validation.  urlHostName is &#8221; + urlHostName);<br />
return true;<br />
}<br />
};<br />
ctxt.put(&#8220;com.sun.xml.ws.transport.http.client.hostname.verifier&#8221;, hv);<br />
ctxt.put(&#8220;com.sun.xml.ws.transport.https.client.hostname.verifier&#8221;, hv);<br />
ctxt.put(&#8220;com.sun.xml.internal.ws.client.hostname.verifier&#8221;, hv);</p>
<p>With this code, it still didn&#8217;t work for me. It turns out that I forgot to put the server certificate in WLS&#8217; truststore, based on this order of usage of certificates.</p>
<p><a href="http://docs.oracle.com/cd/E11035_01/wls100/secmanage/identity_trust.html#wp1183754">http://docs.oracle.com/cd/E11035_01/wls100/secmanage/identity_trust.html#wp1183754</a></p>
<p>After I put in the server certificate in DemoTrust.jks, things start to work great.</p>
<p>-TY</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/61/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/61/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/61/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=61&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2012/01/20/ssl-issues-by-soap-client-from-within-weblogic-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>JSF Error when download file</title>
		<link>http://tonyyan.wordpress.com/2011/12/22/jsf-error-when-download-file/</link>
		<comments>http://tonyyan.wordpress.com/2011/12/22/jsf-error-when-download-file/#comments</comments>
		<pubDate>Thu, 22 Dec 2011 21:03:49 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[JSF]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=56</guid>
		<description><![CDATA[Hi, When I try to download some file off JSF. It gets &#8220;Cannot forward a response that is already committed&#8221;. It is obvious that the response is already committed but JSF still tries to do something to the response. The easiest way to fix this is to make sure after the download, do this to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=56&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>When I try to download some file off JSF. It gets &#8220;Cannot forward a response that is already committed&#8221;. It is obvious that the response is already committed but JSF still tries to do something to the response. The easiest way to fix this is to make sure after the download, do this to tell JSF stop adding stuff to the Response:</p>
<p>context = FacesContext.getCurrentInstance();</p>
<p>if (context != null) context.responseComplete();</p>
<p>This works like a charm.</p>
<p>Happy Holidays!</p>
<p>&#8211;T</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=56&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2011/12/22/jsf-error-when-download-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>JSF inputFileUpload with myfaces extensions</title>
		<link>http://tonyyan.wordpress.com/2011/08/08/jsf-inputfileupload-with-myfaces-extensions/</link>
		<comments>http://tonyyan.wordpress.com/2011/08/08/jsf-inputfileupload-with-myfaces-extensions/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 18:44:44 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=52</guid>
		<description><![CDATA[I did a quick file upload routine with &#60;t:inputFileUpload. It failed to send the upload file. It turns out I didn&#8217;t pay attention to the fact the extension filter is needed.When this is configured, all is good. &#60;filter&#62; &#60;filter-name&#62;MyFacesExtensionsFilter&#60;/filter-name&#62; &#60;filter-class&#62; org.apache.myfaces.webapp.filter.ExtensionsFilter &#60;/filter-class&#62; &#60;init-param&#62; &#60;param-name&#62;uploadMaxFileSize&#60;/param-name&#62; &#60;param-value&#62;25m&#60;/param-value&#62; &#60;/init-param&#62; &#60;/filter&#62;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=52&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I did a quick file upload routine with &lt;t:inputFileUpload. It failed to send the upload file. It turns out I didn&#8217;t pay attention to the fact the extension filter is needed.When this is configured, all is good.</p>
<p>&lt;filter&gt;<br />
&lt;filter-name&gt;MyFacesExtensionsFilter&lt;/filter-name&gt;<br />
&lt;filter-class&gt;<br />
org.apache.myfaces.webapp.filter.ExtensionsFilter<br />
&lt;/filter-class&gt;<br />
&lt;init-param&gt;<br />
&lt;param-name&gt;uploadMaxFileSize&lt;/param-name&gt;<br />
&lt;param-value&gt;25m&lt;/param-value&gt;<br />
&lt;/init-param&gt;<br />
&lt;/filter&gt;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/52/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/52/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/52/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=52&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2011/08/08/jsf-inputfileupload-with-myfaces-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>Log4j again &#8211; Asyn Log Appender to datasource</title>
		<link>http://tonyyan.wordpress.com/2009/08/27/log4j-again-asyn-log-appender-to-datasource/</link>
		<comments>http://tonyyan.wordpress.com/2009/08/27/log4j-again-asyn-log-appender-to-datasource/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 03:07:45 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=44</guid>
		<description><![CDATA[Hi, had some interesting use with the log4j. I think it should help some people, with similar situations with log4j. We need to do log4j with these needs: (1) asynchronously (2) append to a database (3) use a datasource in a JNDI tree. (1) is obviously advantageous, nobody wants to cost delay to processes that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=44&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi, had some interesting use with the log4j. I think it should help some people, with similar situations with log4j. We need to do log4j with these needs:</p>
<p>(1) asynchronously (2) append to a database (3) use a datasource in a JNDI tree.</p>
<p>(1) is obviously advantageous, nobody wants to cost delay to processes that being logged.</p>
<p>(2) and (3) are common requirements &#8211; use dynamic connection pooling without having clear text password in log4j.xml or property files.</p>
<p>Here are the steps to do:</p>
<p>(a) Setup config in log4j.xml</p>
<p>&lt;appender name=&#8221;DatabaseAppender&#8221;<br />
class=&#8221;DatabaseAppender&#8221;&gt;<br />
&lt;param name=&#8221;Threshold&#8221; value=&#8221;DEBUG&#8221; /&gt;<br />
&lt;layout&gt;<br />
&lt;param name=&#8221;ConversionPattern&#8221; value=&#8221;%m&#8221; /&gt;<br />
&lt;/layout&gt;<br />
&lt;/appender&gt;</p>
<p>&lt;appender name=&#8221;AsynAppenderToDatabaseAppender&#8221;<br />
class=&#8221;org.apache.log4j.AsyncAppender&#8221;&gt;<br />
&lt;appender-ref ref=&#8221;DatabaseAppender&#8221; /&gt;<br />
&lt;/appender&gt;</p>
<p>&lt;root&gt;<br />
&lt;appender-ref ref=&#8221;AsynAppenderToDatabaseAppender&#8221; /&gt;<br />
&lt;/root&gt;</p>
<p>DatabaseAppender is the custom appender which will eventually do the underhood logging.  The AsynAppenderToDatabaseAppender is simply a log4j AsyncAppender that will pipe the logger to the DatabaseAppender.  The root logger is my lazy mapping of all to the DatabaseAppender.  One can add many other loggers to it as desired.</p>
<p>(b) Implement the Custom DatabaseAppender.java</p>
<p>public class DatabaseAppender extends AppenderSkeleton {</p>
<p>public boolean requiresLayout(){<br />
return true;<br />
}</p>
<p>/**<br />
* actual place to save to DB with LOG object for hibernate<br />
*/<br />
public synchronized void append( LoggingEvent event ) {</p>
<p>LogDatabaseDelegate del = new LogDatabaseDelegate();<br />
LogTable log = new LogTable();<br />
log.setLOGLEVEL_INT(event.getLevel().toInt());<br />
log.setLOGLEVEL(event.getLevel().toString());<br />
log.setLOGTIME(new Date(event.getTimeStamp()));<br />
LocationInfo li = event.getLocationInformation();<br />
log.setLOGGER(event.getLoggerName() + &#8221; [" + li.getFileName() + ":" + li.getMethodName() + ":" + li.getLineNumber() + "]&#8220;);<br />
log.setAPPID(SitePropertyConstants.getAPP_ID());<br />
String msg = this.layout.format(event);<br />
if (msg.length() &gt; SitePropertyConstants.getMAX_CHAR_IN_LOG_MSG())<br />
msg = msg.substring(0, SitePropertyConstants.getMAX_CHAR_IN_LOG_MSG());<br />
log.setLOGMESSAGE(msg);<br />
del.saveLog(log);</p>
<p>}</p>
<p>public synchronized void close(){</p>
<p>}<br />
}</p>
<p>Here is pure java stuff with Hibernate.  The LogDatabaseDelegate will save LogTable object with information such as Log level, log time, logger name (class), log message, etc, etc. In the hibernate end, I simply mount the datasource to a JNDI tree using:</p>
<p>&lt;property name=&#8221;connection.datasource&#8221;&gt;myDataSource&lt;/property&gt;</p>
<p>Definitely, hibernate is not relevant here, you can use any DAO layer to persist the log4j information to Database.</p>
<p>That&#8217;s all &#8211; Happy Logging4J to Database, asynchronously!</p>
<p>-T</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/44/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/44/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/44/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=44&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/08/27/log4j-again-asyn-log-appender-to-datasource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>NoClassDefFoundError, Xerces package in Weblogic Managed Server</title>
		<link>http://tonyyan.wordpress.com/2009/08/03/classdefnotfounderror-weblogic-managed-server/</link>
		<comments>http://tonyyan.wordpress.com/2009/08/03/classdefnotfounderror-weblogic-managed-server/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 01:23:59 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Weblogic]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=39</guid>
		<description><![CDATA[I have spent 4-5 days including probably 10 hours this weekend to this tailspinning problem. We have this ear file deployed to WLS adminsevers w/o any problem. As soon as it is deployed to a managed server, we have this ClassDefNotFoundError each time we do an unmarshall from an XML soap msg to an object. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=39&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have spent 4-5 days including probably 10 hours this weekend to this tailspinning problem. We have this ear file deployed to WLS adminsevers w/o any problem. As soon as it is deployed to a managed server, we have this ClassDefNotFoundError each time we do an unmarshall from an XML soap msg to an object. This Object has a data type impl of Duration. To make long story short, the xerces always complained about unable to load this DurationImpl class in xerces. I use the latest xerces 2.9.1 and the class is obviously in APP-INF/lib. When all said and done, we semi-incidentally found by deploying to another instance of managed server. This worked on that instance. It turns out the problematic instance has this WILY management system in system classpath. So we think that must have some spoiler xerces packages which maybe of 2.6 or earlier for xerces. It is almost impossible to fix it by tuning CP config. in our ear file (with all those prefered CP options in weblogic or weblogic-application descriptors).</p>
<p>Not saying Wily is bad, but any package (JMX etc) that in the systm classpath is potentially a CP hell for us developers. WLS tends to include lots of open source packs or other 3rd party stuff, all could be sources of wasting precious times of ours.</p>
<p>&lt;T/&gt;</p>
<p><span> </span></p>
<ol>
<li><span><span>java.lang.NoClassDefFoundError: Could not initialize </span><span>class</span><span> org.apache.xerces.jaxp.datatype.DurationImpl </span></span></li>
<li><span> at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newDuration(Unknown Source) </span></li>
<li><span> at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$<span>25</span><span>.parse(RuntimeBuiltinLeafInfoImpl.java:</span><span>787</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$<span>25</span><span>.parse(RuntimeBuiltinLeafInfoImpl.java:</span><span>780</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.parse(TransducedAccessor.java:<span>241</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.LeafPropertyLoader.text(LeafPropertyLoader.java:<span>61</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallingContext.text(UnmarshallingContext.java:<span>462</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.processText(SAXConnector.java:<span>168</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.SAXConnector.endElement(SAXConnector.java:<span>141</span><span>) </span></span></li>
<li><span> at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) </span></li>
<li><span> at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source) </span></li>
<li><span> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) </span></li>
<li><span> at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) </span></li>
<li><span> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) </span></li>
<li><span> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) </span></li>
<li><span> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) </span></li>
<li><span> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) </span></li>
<li><span> at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) </span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:<span>211</span><span>) </span></span></li>
<li><span> at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:<span>184</span><span>) </span></span></li>
<li><span> at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:<span>137</span><span>) </span></span></li>
<li><span> at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:<span>194</span><span>)<br />
</span></span></li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=39&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/08/03/classdefnotfounderror-weblogic-managed-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>Open oracle cursor reaching limit after session.close()</title>
		<link>http://tonyyan.wordpress.com/2009/02/24/opened-oracle-cursor-after-sessionclose/</link>
		<comments>http://tonyyan.wordpress.com/2009/02/24/opened-oracle-cursor-after-sessionclose/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 00:39:00 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Hiberate]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Oracle]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=35</guid>
		<description><![CDATA[By default, oracle 10 has the cursor counts set at 1000 if not changed by DBA. and Hibernate will not close them if you simply do session.close(). Can you believe that? !  you would think if a &#8220;session&#8221; closes, its resources should all be closed. That&#8217;s why session in hibernate can&#8217;t be regarded literally, such [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=35&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>By default, oracle 10 has the cursor counts set at 1000 if not changed by DBA. and Hibernate will not close them if you simply do session.close(). Can you believe that? !  you would think if a &#8220;session&#8221; closes, its resources should all be closed. That&#8217;s why session in hibernate can&#8217;t be regarded literally, such as a SQL*Plus session. In this case, the session behaves more like connection.</p>
<p>Any how, we had to insert more than 5000 rows to a single table and we got ORA error 1000, cursor reached the limit. Following this nice advice, http://javacolors.blogspot.com/2006/10/hibernate-3-and-oracle-9i-cursors-how.html</p>
<p>We had to change code so that we will close sessionFactory after certain amount of inserts. That way, we will ensure cursors will be closed before reaching the 1000 mark.</p>
<p>Another way is to set zero for the prep stmt cache, but that will be at system level to disable this nice feature.</p>
<p>Thanks for reading.</p>
<p>-Tony</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/35/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/35/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/35/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=35&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/02/24/opened-oracle-cursor-after-sessionclose/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>Axis2 on Weblogic 9.2 and 10</title>
		<link>http://tonyyan.wordpress.com/2009/02/24/axis2-on-weblogic-92-and-10/</link>
		<comments>http://tonyyan.wordpress.com/2009/02/24/axis2-on-weblogic-92-and-10/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 00:30:52 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[AXIS]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=32</guid>
		<description><![CDATA[Axis2 is great! Open source and easy to use. The canned samples work easily in Tomcat, hey they are from the same family, aren&#8217;t they! When I used the same thing to Weblogic (Oracle now) 10.3. I got problems when ruuning Client to the WS (Axis2UserGuide Example). It gave me  NULL Pointers when client tried [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=32&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Axis2 is great! Open source and easy to use. The canned samples work easily in Tomcat, hey they are from the same family, aren&#8217;t they!<br />
When I used the same thing to Weblogic (Oracle now) 10.3. I got problems when ruuning Client to the WS (Axis2UserGuide Example). It gave me  NULL Pointers when client tried to parse the response from WS. I googled a lot and found very vague answers.</p>
<p>Then I went back to Apache site and read carefully, walla, it is right there at this link http://ws.apache.org/axis2/1_2/app_server.html</p>
<p>Basically, I had to make an ear instead of war file. And put weblogic-application.xml like this in the Meta-inf folder.</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;UTF-8&#8243;?&gt;<br />
&lt;weblogic-application xmlns=&#8221;http://www.bea.com/ns/weblogic/90&#8243;&gt;<br />
&lt;prefer-application-packages&gt;<br />
&lt;package-name&gt;com.ctc.wstx.*&lt;/package-name&gt;<br />
&lt;package-name&gt;javax.xml.*&lt;/package-name&gt;<br />
&lt;package-name&gt;org.apache.*&lt;/package-name&gt;<br />
&lt;/prefer-application-packages&gt;<br />
&lt;/weblogic-application&gt;</p>
<p>Also, add Weblogic.xml in the WEB-INF folder the following:</p>
<p>&lt;?xml version=&#8221;1.0&#8243;?&gt;</p>
<p>&lt;weblogic-web-app xmlns=&#8221;http://www.bea.com/ns/weblogic/90&#8243; xmlns:xsi=&#8221;http://www.w3.org/2001/XMLSchema-instance&#8221;&gt;</p>
<p>&lt;container-descriptor&gt;<br />
&lt;prefer-web-inf-classes&gt;true&lt;/prefer-web-inf-classes&gt;<br />
&lt;/container-descriptor&gt;</p>
<p>&lt;/weblogic-web-app&gt;</p>
<p>Client.java ran great after these additions/mods. All these changes basically ensures weblogic&#8217;s classes don&#8217;t contaminate classes from Axis2.</p>
<p>so the moral of this story is &#8211; After all failed, read the manual. (sorry for the cliche)</p>
<p>-T</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=32&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/02/24/axis2-on-weblogic-92-and-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>How about some four level cascade one-to-many tables?</title>
		<link>http://tonyyan.wordpress.com/2009/01/25/how-about-some-four-level-cascade-one-to-many-tables/</link>
		<comments>http://tonyyan.wordpress.com/2009/01/25/how-about-some-four-level-cascade-one-to-many-tables/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 04:29:18 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=23</guid>
		<description><![CDATA[Hibernate is your friend when you know more about it. It is not if you don&#8217;t &#8230; I have a four level one-many tables. Say A-&#62;B-&#62;C-&#62;D. In A, B, C, there are one-to-many associations. Like this (in A for Set of B objects.) &#60;set name=&#8221;Bs&#8221; cascade=&#8221;all&#8221;&#62; &#60;key column=&#8221;A_id&#8221; not-null=&#8221;true&#8221;/&#62; &#60;one-to-many class=&#8221;B&#8221;/&#62; &#60;/set&#62; For insert data [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=23&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hibernate is your friend when you know more about it. It is not if you don&#8217;t &#8230;</p>
<p>I have a four level one-many tables. Say A-&gt;B-&gt;C-&gt;D. In A, B, C, there are one-to-many associations. Like this (in A for Set of B objects.)</p>
<p>&lt;set name=&#8221;Bs&#8221; cascade=&#8221;all&#8221;&gt;<br />
&lt;key column=&#8221;A_id&#8221; not-null=&#8221;true&#8221;/&gt;<br />
&lt;one-to-many class=&#8221;B&#8221;/&gt;<br />
&lt;/set&gt;</p>
<p>For insert data in A,B,C,D tables, Fill the object of A with set of B&#8217;s, after filling B with set of C&#8217;s, after filling C with Set of D&#8217;s. Then simply do hibernate session.save(A). All cascading objects will be saved. Great!</p>
<p>Now, how to delete them? Delete from Object A is quite easy, simply do session.delete(a). But I had some trouble deleting from say, B down. It always complains about:</p>
<p>&#8220;deleted object would be re-saved by cascade (remove deleted object from associations)&#8230;&#8221;</p>
<p>It turns out that the message in parens are quite important. You will know if you see the following code:</p>
<p>A a = new A();</p>
<p>session.load(a, 10);<br />
Set Bs= a.getBs();<br />
Iterator iter = Bs.iterator();<br />
while (iter.hasNext()){<br />
B b= (B) iter.next();<br />
iter.remove();<br />
session.delete(b);<br />
}</p>
<p>session.saveOrUpdate(a);<br />
session.flush();</p>
<p>The line iter.remove() is critical to avoid the error message. It actually remove the Child object B from Parent Object A&#8217;s B set. So Hibernate will not resave the object B when update Object A&#8217;s Set. Well, in this code, all B in Set of B in Object A will be gone. And magically, all Cs in B and Ds in all those Cs are all gone. Thanks, Hibernate!</p>
<p>Happy Chinese New Year!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=23&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/01/25/how-about-some-four-level-cascade-one-to-many-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>bytecode editor saved the day</title>
		<link>http://tonyyan.wordpress.com/2009/01/19/bytecode-editor-saved-the-day/</link>
		<comments>http://tonyyan.wordpress.com/2009/01/19/bytecode-editor-saved-the-day/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 17:52:15 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[bytecode]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=20</guid>
		<description><![CDATA[Happy new year! I had a tough simple problem that requires me to change a string in java class. Of course, I don&#8217;t have the source code for it. Normally, I would just use decompiler to get the java source and change and recompile. Easy right? this time, the class is so strange in some [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=20&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Happy new year!</p>
<p>I had a tough simple problem that requires me to change a string in java class. Of course, I don&#8217;t have the source code for it. Normally, I would just use decompiler to get the java source and change and recompile. Easy right? this time, the class is so strange in some way that none of the decompilers I used got me a good java code. This is a first time for me. Usually, frontend plus or DJ or Java decompiler do the job really nicely. This time, the java code always had strange codes and lots of labels (remember those Java labels?) anyway, I googled to find those might be related to the fact the original class has a lot of try-catch blocks either stacked or enclosed.  I didn&#8217;t want to mess up the java code since I am afraid to introduce bugs into the class. All I wanted to do is to change a string constant which prevented the program from running correctly during network connection (it is a http call class).</p>
<p>So for the first time, I resorted to bytecode editor, which I had only heard of before. After spending a few hours and good size of frustrations, I found cafebabe allowed me to edit that string and save the class file. Hurray! problem solved right away after I injected the new doped class to the original jar file.</p>
<p>Thanks, Cafebabe &#8211; http://sourceforge.net/projects/cafebabe</p>
<p>Tony</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/20/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/20/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/20/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=20&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2009/01/19/bytecode-editor-saved-the-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
		<item>
		<title>Hibernate Object states in web app</title>
		<link>http://tonyyan.wordpress.com/2008/11/10/hibernate-object-states-in-web-app/</link>
		<comments>http://tonyyan.wordpress.com/2008/11/10/hibernate-object-states-in-web-app/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 18:13:59 +0000</pubDate>
		<dc:creator>tonyyan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tonyyan.wordpress.com/?p=17</guid>
		<description><![CDATA[I will write a very short note about the state problems I have with hibernate today. There are three states for hibernate objects:Transient, Persistent, Detached. I am not going to describe each of them in full here, googling would give a lot to read about. My problem was that I chose to use Detached to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=17&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I will write a very short note about the state problems I have with hibernate today. There are three states for hibernate objects:Transient, Persistent, Detached. I am not going to describe each of them in full here, googling would give a lot to read about.</p>
<p>My problem was that I chose to use Detached to get the object from DB and then to modify it in the web layer. I thought since it is detached, session has been closed. The object will be modified and later put back to hibernate with a new session. Sounds correct, right? But it always gave me a lot of problems such as complaining about session already closed, etc etc. Briefly, the state of the object is just not right or not retrievable when user modified the object and tried to save it.  I used this code:</p>
<p>Foo foo = (Foo) session.load(Foo.class, new Long(1));</p>
<p>this object got in this way is in detached mode. Later, I used this way:</p>
<p>Foo foo = new Foo();</p>
<p>session.load(foo, new Long(1));</p>
<p>this works much nicer since the foo is in transient state. This works great with Web layer since you don&#8217;t want to have anything hanging around with hibernate when waiting for web users to get the object info back to the server.</p>
<p>I am not at the bottom of the problem with the detached state, I will explain it more when I find out more. Now I am just happy the transient state object works well.</p>
<p>Hope it helps.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tonyyan.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tonyyan.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tonyyan.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=tonyyan.wordpress.com&amp;blog=4913876&amp;post=17&amp;subd=tonyyan&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://tonyyan.wordpress.com/2008/11/10/hibernate-object-states-in-web-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/9a663d6c1c37e90387d050e010920f64?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">tonyyan</media:title>
		</media:content>
	</item>
	</channel>
</rss>
