<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6210509318596208287</id><updated>2012-02-16T11:11:22.409-08:00</updated><title type='text'>J Tech Tips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jeewesley.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jeewesley.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Wesley Liu</name><uri>http://www.blogger.com/profile/03442834873174078209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6210509318596208287.post-161960932814347950</id><published>2008-12-14T05:56:00.000-08:00</published><updated>2008-12-14T06:11:41.843-08:00</updated><title type='text'>Glassfish EJB3 remote interface on Linux problem</title><content type='html'>It's a problem struggles me for more than a year.   Once I call a EJB Remote at Linux glassfish from any other machines, an strange exception will be thrown. The problem will only occur on Linux glassfish deployment. It was believed to be a bug as many other guys in glassfish forum). Here's the error messages:&lt;br /&gt;&lt;br /&gt;"IOP00410201: (COMM_FAILURE) Connection failure: socketType: IIOP_CLEAR_TEXT; hostname: 127.0.0.1; port: 3700"&lt;br /&gt;org.omg.CORBA.COMM_FAILURE:   vmcid: SUN  minor code: 201  completed: No&lt;br /&gt;       at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2690)&lt;br /&gt;       at com.sun.corba.ee.impl.logging.ORBUtilSystemException.connectFailure(ORBUtilSystemException.java:2711)&lt;br /&gt;       at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.&lt;init&gt;(SocketOrChannelConnectionImpl.java:261)&lt;br /&gt;       at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.&lt;init&gt;(SocketOrChannelConnectionImpl.java:274)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I come across this problem recently. After detail investigation, the problem is due of the Croba Connection on Linux Server resolve it's own ip address using the DNS name "localhost". The default Linux installation , /etc/host has the following line:&lt;br /&gt;127.0.0.1 localhost&lt;br /&gt;&lt;br /&gt;Then the client try to connect the server again using 127.0.0.1. The problem could be fixed by just modify the /etc/hosts file&lt;br /&gt;{real ip address}  localhost&lt;/init&gt;&lt;/init&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6210509318596208287-161960932814347950?l=jeewesley.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jeewesley.blogspot.com/feeds/161960932814347950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6210509318596208287&amp;postID=161960932814347950' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/161960932814347950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/161960932814347950'/><link rel='alternate' type='text/html' href='http://jeewesley.blogspot.com/2008/12/glassfish-ejb3-remote-interface-on.html' title='Glassfish EJB3 remote interface on Linux problem'/><author><name>Wesley Liu</name><uri>http://www.blogger.com/profile/03442834873174078209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6210509318596208287.post-4908077263079745780</id><published>2008-11-13T07:54:00.000-08:00</published><updated>2008-11-13T08:00:41.874-08:00</updated><title type='text'>New Hiberinate Library Update on Glassfish</title><content type='html'>The Glassfish server has an update tool which could  install updated application library. However, When I install the new hibernate 3.4 using the tool, the server fails to load up the application with the following error:&lt;br /&gt;java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.&lt;init&gt;(Z)V&lt;br /&gt;&lt;br /&gt;After some investigation, it placed a asm-3.1.jar in glassfish\lib which duplicated the original asm.jar.  It encounters some class loading problem.  It works fine after deleting the original asm.jar.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6210509318596208287-4908077263079745780?l=jeewesley.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jeewesley.blogspot.com/feeds/4908077263079745780/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6210509318596208287&amp;postID=4908077263079745780' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/4908077263079745780'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/4908077263079745780'/><link rel='alternate' type='text/html' href='http://jeewesley.blogspot.com/2008/11/new-hiberinate-library-update-on.html' title='New Hiberinate Library Update on Glassfish'/><author><name>Wesley Liu</name><uri>http://www.blogger.com/profile/03442834873174078209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6210509318596208287.post-8859357188495231371</id><published>2008-11-04T02:02:00.001-08:00</published><updated>2008-11-06T05:46:04.434-08:00</updated><title type='text'>Using OpenEJB for unit testing with Hibernate on Netbeans</title><content type='html'>EJB3 has simplified EJB development a lot. However, it imposed new difficulties on out-of-container testing with the use of dependency injection. OpenEJB provides a way of to do EJB testing within J2Se environment in a lightweight container.&lt;br /&gt;&lt;br /&gt;I am using Hibernate as the JPA implementation in current development, I would like to demonstrate how to test EJB under Netbeans 6.1 using OpenEJB.&lt;br /&gt;&lt;br /&gt;Here are the steps:&lt;br /&gt;&lt;br /&gt;1. Download OpenEJB from http://openejb.apache.org/, the current version is 3.1. Unzip the file, you may find all the required jar file under {somewhere to put the unzipped files}:\openejb-3.1\lib.&lt;br /&gt;&lt;br /&gt;2. In Netbeans, under Tools --&gt; Library --&gt; new Library, create a library called openejb.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_hhcodr77fEI/SRAj7c2huzI/AAAAAAAAAEw/TBnWrJQI7mU/s1600-h/lib.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 235px;" src="http://1.bp.blogspot.com/_hhcodr77fEI/SRAj7c2huzI/AAAAAAAAAEw/TBnWrJQI7mU/s320/lib.jpg" alt="" id="BLOGGER_PHOTO_ID_5264747468660259634" border="0" /&gt;&lt;/a&gt;3. Assume that you have an existing EJB project with a test Stateless Session Bean as following:&lt;br /&gt;&lt;br /&gt;@Stateless&lt;br /&gt;public class MyTestBean implements MyTestLocal {&lt;br /&gt;&lt;br /&gt;  public String sayHello() {&lt;br /&gt;      System.out.println("hahahah");&lt;br /&gt;   &lt;br /&gt;      return "haha";&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Here's the persistence configuration:&lt;br /&gt;&lt;persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;&lt;persistence-unit name="my-ejbPU" type="JTA"&gt;&lt;provider&gt;&lt;/provider&gt;&amp;lt;persistence-unit name=&amp;quot;my-ejbPU&amp;quot; transaction-type=&amp;quot;JTA&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;provider&amp;gt;org.hibernate.ejb.HibernatePersistence&amp;lt;/provider&amp;gt;&lt;br /&gt;&amp;lt;jta-data-source&amp;gt;myds&amp;lt;/jta-data-source&amp;gt;&lt;br /&gt;&amp;lt;/persistence-unit&amp;gt;&lt;persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;&lt;persistence-unit name="hyg-ejbPU" type="JTA"&gt;&lt;properties&gt;&lt;br /&gt;     &lt;property name="hibernate.max_fetch_depth" value="0"&gt;&lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.EhCacheProvider"&gt;&lt;property name="hibernate.cache.use_second_level_cache" value="true"&gt;&lt;property name="hibernate.cache.use_query_cache" value="true"&gt;&lt;/property&gt;&lt;/property&gt;&lt;properties&gt;&lt;property name="hibernate.max_fetch_depth" value="0"&gt;&lt;br /&gt;&lt;br /&gt;4. Add ejb-jar.xml into configuration files of the EJB project as the followings:&lt;br /&gt;&lt;ejb-jar&gt;&lt;br /&gt;&amp;lt;ejb-jar/&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The above declaration is used for telling the OpenEJB container to scan the jar file containing the EJBs and deploy it along with any annotated beans it may contain. http://openejb.apache.org/3.0/application-discovery-via-the-classpath.html&lt;br /&gt;&lt;br /&gt;5. Create a J2SE project named testapp. Add the openejb and the EJB project as Library. If you use MySQL as the database, please add the mysql connectorJ library as well.&lt;br /&gt;&lt;br /&gt;6. Create a unit test in the J2SE project.&lt;br /&gt;&lt;br /&gt;public class NewJUnitTest extends TestCase {&lt;br /&gt;&lt;br /&gt;    private InitialContext initialContext;&lt;br /&gt;&lt;br /&gt;  public NewJUnitTest() {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @BeforeClass&lt;br /&gt;  public static void setUpClass() throws Exception {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @AfterClass&lt;br /&gt;  public static void tearDownClass() throws Exception {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @Before&lt;br /&gt;  public void setUp() {&lt;br /&gt;    &lt;br /&gt;    //Init the OpenEJB Container&lt;br /&gt;      try {&lt;br /&gt;          Properties p = new Properties();&lt;br /&gt;          p.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.LocalInitialContextFactory");&lt;br /&gt;  //Config the DataSource with MySQL&lt;br /&gt;          p.put("myds", "new://Resource?type=DataSource");&lt;br /&gt;          p.put("myds.JdbcDriver", "com.mysql.jdbc.Driver");&lt;br /&gt;          p.put("myds.JdbcUrl", "jdbc:mysql://localhost:3306/mydb");&lt;br /&gt;          p.setProperty("myds.UserName", "test");&lt;br /&gt;          p.setProperty("myds.Password", "test");&lt;br /&gt;       &lt;br /&gt;           //It's specially for MySQL where hibernate.dialect must be explicitly set&lt;br /&gt;          p.put("my-ejbPU.hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");&lt;br /&gt;        &lt;br /&gt;          initialContext = new InitialContext(p);&lt;br /&gt;      } catch (NamingException ex) {&lt;br /&gt;      &lt;br /&gt;          System.err.println(ex.getMessage());&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//Here's the testing Code&lt;br /&gt;  @Test&lt;br /&gt;  public void testSayHello(){&lt;br /&gt;      try {&lt;br /&gt;&lt;br /&gt;          Object object = initialContext.lookup("MyTestBeanLocal");&lt;br /&gt;          assertNotNull(object);&lt;br /&gt;          assertTrue(object instanceof MyTestLocal);&lt;br /&gt;          MyTestLocal mt = (MyTestLocal) object;&lt;br /&gt;          assertEquals("haha",mt.sayHello());&lt;br /&gt;&lt;br /&gt;} catch (NamingException ex) {&lt;br /&gt;          assertFalse(true);&lt;br /&gt;          System.err.println(ex.getMessage());&lt;br /&gt;      }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  @After&lt;br /&gt;  public void tearDown() {&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;After all, you can test any Entity or SessionBeans in a J2SE environment. When you start the OpenEJB container in SetUp(), the Persistence Provider Implementation  will check the entitiy mappings with Database.  DBUnit could also be introduced if you would like to test Entity Beans.&lt;/ejb-jar&gt;&lt;/property&gt;&lt;/properties&gt;&lt;/property&gt;&lt;/property&gt;&lt;/properties&gt;&lt;/persistence-unit&gt;&lt;/persistence&gt;&lt;/persistence-unit&gt;&lt;/persistence&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6210509318596208287-8859357188495231371?l=jeewesley.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jeewesley.blogspot.com/feeds/8859357188495231371/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=6210509318596208287&amp;postID=8859357188495231371' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/8859357188495231371'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6210509318596208287/posts/default/8859357188495231371'/><link rel='alternate' type='text/html' href='http://jeewesley.blogspot.com/2008/11/using-openejb-for-unit-testing-with.html' title='Using OpenEJB for unit testing with Hibernate on Netbeans'/><author><name>Wesley Liu</name><uri>http://www.blogger.com/profile/03442834873174078209</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_hhcodr77fEI/SRAj7c2huzI/AAAAAAAAAEw/TBnWrJQI7mU/s72-c/lib.jpg' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
