JavaEE & EJB3

You are currently browsing the archive for the JavaEE & EJB3 category.

This time I want to introduce a book I just read from the Internet. It is free of charge to download and the contents are mainly focused on questions that we will face during an interview.

The author has eight years of JAVA experience, even he was graduated as a Mechanical Engineer. He has experience on different fields of JAVA, from JavaSE to JavaEE to other related technologies that companies usually want, from concept, theory to the programming language. It benefits not only to the job seekers, but also the interviewers.

Most questions are composed of Q&A style, divided into parts of different topics, with an index for you to locate several subsets of the questions. You can also take it as a quiz on your JAVA knowledges, e.g. before you go for certification. I didn’t actually start reading it, but there are already many reviews on the book.

Page about the book:

http://stores.lulu.com/java-success

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

Just found a book introduction from TheServerSide.com

This book explains the concept of JPA, with some useful knowledge on the persistence standard, JPA Annotations, Entity Manager and JPA Query Language (also known as EJB-QL), etc. There are examples, and a simple Maven 2 application with MySQL Database, and Hibernate as the persistence provider will be build after reading through the book. I hope this will be useful for my development using JPA.

Post on TheServerSide
JPA101 Chapter
Author: Chris Maki’s Blog
http://jroller.com/page/cmaki

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

One of the major change for this 2.4 version of web.xml is the ordering of tags. As the use of XML Schema provides the flexibility on the ordering of tags, you can put the tag in any ordering as you like.

Besides this, one another change is the use of tag library. Starting from 2.4, we have to surround all <taglib> with a new tag <jsp-config>, as required by the mechanism of XML Schema, like the following:

<web-app xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”
version=”2.4″>

<description>StrutsTest</description>

<jsp-config>

<taglib>
<taglib-uri>http://jakarta.apache.org/tomcat/debug-taglib</taglib-uri>
<taglib-location>/WEB-INF/jsp/debug-taglib.tld</taglib-location>
</taglib>

</jsp-config>

</web-app>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

Learning EJB-QL

Seems that there is still not much resource on Java Persistence, which is included in EJB3. If I want to learn more about EJB-QL, the only way is to look at the resources of EJB2.1. The articles may not be updated, but most of the contents still apply.

However, I found one EJB-QL that is in the spec. seems not supported by most of the vendors, which is OFFSET and LIMIT. I found some articles on people asking Sun about the issue, but no one answers. Then I do a search on Google, and only found Resin which supports it.

These keywords are used together to limit the number of entity instances returned in a list, especially useful for entity storing up to ten thousand records. Your memory size must be a main issue by then. Actually, it is just similar to the ROWNUM functions provided by Oracle, but don’t know why so few vendors implement such a useful function.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

When I am thinking using autoReconnect will resolve the disconnection problem, a new error comes to me.

java.net.SocketException
MESSAGE: Software caused connection abort: recv failed

This error appears in occasional case, but also after a long hours of idle. I used Java Persistence to connect mysql. Today morning, when I was back to office. My application seems fine when doing the querying functionalities. However, when I used persist() and merge() operations which updated the DB, this error occurred.

Someone said this also the same problem as previous, which MySQL disconnects the connections after idle for 8 hours, but I am amazing that the error only throw for updating operations. Is it mechanism for Java Persistence, since it can store part of DB details in memory, so it didn’t actually query the database?

Reference:
http://forums.mysql.com/read.php?39,55337,95721#msg-95721

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

These days, this exception always occur in my new developing application using persistence, especially on the morning when I came back to office. At the beginning, I think it may be due to the use of Java Persistence. However, when I do a search on Google, at the top of the list, I got this post:

http://www.yannicafe.info/wp/2006/11/25/53.html

This post describes the case in detail. It is due to the mechanism of MySQL, where this DB will disconnect all the active connections after 8 hours if there is no activity. After that, if your application try to work on some activities, the above exception is caused.

Normally, the exception should be caught in the application, and direct to a reconnect logic. However, the persistence provider (Oracle TopLink) that I am using does not provide auto reconnect function. So, I need to change the connection URL to the following:

jdbc:mysql://localhost:3306/test?autoReconnect=true

This allow the application to auto reconnect in case MySQL disconnects all the connections. Nevertheless, the bad thing is that  this is not recommended by MySQL community and this parameter may even be removed from future versions of MySQL.

Reference:
http://forums.java.net/jive/thread.jspa?messageID=189962

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

As JPA is providing the interface to connect your Java application to the database, it is supposed to be just an interface doing so. In the other words, you have freedom in managing your database, by changing the DB-specific parameters and tuning the database.

In MySQL, as most people should know, there provides a choice of storage engine on each table. By using JPA, you can let the persistence provider to generate the table for you. It is easy and let the persistence provider determine the suitable configuration for you, both on table and on each field.

The default storage engine for table is InnoDB, as it supports transaction, row-locking and foreign keys where are needed by JPA. However, if you have a table that needs performance rather than data accuracy, you can manually change the storage engine to MyISAM before or after the persistence provider’s decision.

You can stop the persistence provider from generating the table, which you build your own table first, and just simply mapped all the things to the Entity.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

I’m just starting the development of applications using Java Persistence API (JPA). In fact, the most challenging thing comes up to me at my start, the compatibility of IDE.

JPA is co-developed by the team of JavaEE 5 Specification Group, as a replacement to the heavy-weighted Entity bean. Until now, there are limited IDE that supports the development of JavaEE, especially EJB 3.0. Two of them are Sun Netbeans and Oracle JDeveloper. Both of them are free, but not open-sourced IDEs.

I personally use Eclipse as my primary development tool, thus quite familiar with the functionalities within. However, Eclipse for now just provides a plugin project named “Dali” for the development of Java Persistence. However, Dali have lots of bugs and seems suspended from Aug, 2006. That’s why it’s not a good choice to use.

Instead, in order to develop JPA easily and still use Eclipse as my major platform, I have the following methods.

  1. Develop JPA related things in Netbeans, including the Entity itself and the configuration of persistence.xml file
  2. Export those Entities and required settings to JAR file using Ant Script
  3. Import the JAR file and other required libraries into Eclipse
  4. In Eclipse, just like developing usual applications, and for the persistence part, call the methods of Entity.

This is not a very good method, since there are so many troubles in between. But at least, it helps me to do more with JPA easily

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

There is a book named “Mastering EJB 3.0″

In Chapter 13 of the book, it introduces their ideas for desigining “When to Use EJB” in the following design situations.

- Remoting is required
- Distributed transactions are required
- Component-security is required
- Persistence is required
- Integration with legacy applications is required
- Scalability is required

Reference:
Free Book: Mastering Enterprise JavaBeans 3.0
http://www.theserverside.com/tt/books/wiley/masteringEJB3/index.tss

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Live
  • Technorati
  • YahooMyWeb

« Older entries

 

September 2008
S M T W T F S
« May    
 123456
78910111213
14151617181920
21222324252627
282930  

Categories