-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Netbeans+Hibernate+JBoss TreeCache+Sun Apllication Server
PostPosted: Tue May 06, 2008 10:25 am 
Newbie

Joined: Tue May 06, 2008 8:20 am
Posts: 3
This is intended towards somewhat new programmers or programmers relatively new to ejb and transactional caching (like me). The information is current as of May 2008.

Getting this combo to work off the ground was rather challenging. My goal was to develop an ejb enterprise application through Netbeans, that would allow transactional caching, running on Sun's App Server. Hibernate's jboss cache release is a severely outdated 1.3 pre-alpha with weird dependencies on log4j (please don't take this the wrong way, I like using log4j but using more than one logging file is mind bogging and rather inefficient during early development) and numerous issues concerning jndi registrations (Specifically jboss cache in said release re-registers modules in jndi thus havoc ensues).

The Releases I have used are:

Netbeans 6.1
Hibernate-3.2.6.GA
Hibernate-entitymanager-3.3.2.GA
Hibernate-annotations-3.3.1.GA
javassist-3.7.GA
JBoss-cache-1.4.1.SP9 ( the 2.x.x releases are incompatible with the current (3.2.6) hibernate GA release)
Sun Application Server 9.1 Update 2

I cannot guaranty proper functionality with other release versions.
When all is set and done what you will get is an ejb enterprise application running smoothly with all the logs output in the domain server log and the output window in netbeans.

Netbeans 6.1 and SAS9.1 are considered to be already installed.
At least one proper jdbc resource is supposed to be available in netbeans.
For clarity's sake let SAS be installed in c:\sun\SDK.

Do not install anything in the c:\sun\SDK\lib directory.

Create a directory (if you haven't one already) named for instance C:\lib.
Create a directory named e.g. C:\lib\hibernate
Create a directory named e.g. C:\lib\jbosscache

-------------------------------------------------------------------
Extract to c:\lib\hibernate:

From Hibernate-3.2.6.GA

antlr-2.7.6.jar
asm-attrs.jar
asm.jar
c3p0-0.9.1.jar
cglib-2.1.3.jar
commons-collections-2.1.1.jar
commons-logging-1.0.4.jar
concurrent-1.3.2.jar
dom4j-1.6.1.jar
ehcache-1.2.3.jar (optional, should you need it in other projects instead of treecache)
ejb3-persistence.jar
hibernate3.jar
jta.jar


From Hibernate-annotations-3.3.1.GA

hibernate-annotations.jar
hibernate-commons-annotations.jar


From Hibernate-entitymanager-3.3.2.GA

hibernate-entitymanager.jar


From javassist-3.7.GA

javassist.jar

In netbeans select tools\libraries\new library...
Name it hibernate or whatever you like.
Select Add jar/folder and add all the files in c:\lib\hibernate

----------------------------------------------------------
Extract to c:\lib\jbosscache:

From jboss-cache-1.4.1.SP9

jgroups.jar
jboss-cache-jdk50.jar or jboss-cache.jar
jboss-common.jar
jboss-jmx.jar
jboss-system.jar

In netbeans select tools\libraries\new library...
Name it jbosscache or whatever you like.
Select Add jar/folder and add all the files in c:\lib\jbosscache

-----------------------------------------------------------

It is time to create an ejb enterprise application in netbeans.

Select New Project/Enterprise/Enterprise Application
Go through steps 1,2.
In step 3 check that the server is SAS, and that the EE Version is Java EE 5. Check "Create EJB Module" and "Create Application Client Module".
Click Finish.

A new Enterprise Application is created. let's call it enterprise1.
Locate the enterprise1-ejb node. Add the hibernate and jbosscache libraries ONLY to enterprise1-ejb.

On the enterprise1 node right click/New/New Persistence Unit.
Select hibernate as a persistence provider.
Make sure Use Java Transaction APIs is elected. Select the table generation strategy of choice. Click Finish.

On the enterprise1-ejb node right click/New/Entity Classes From Database...
Select the desired data source and tables. In step3 select a convenient Package name. Click Finish.

Expand enterprise1-ejb/Configuration Files. Double click persistence.xml. In Design View make sure that the persistence provider is hibernate and Use Java Transaction APIs and Include All Entity Classes are selected. Use the same data source as earlier. In XML View remove <properties/> and replace with:
<properties>
<property name="hibernate.cache.provider_class" value="org.hibernate.cache.TreeCacheProvider"/>
<property name="hibernate.cache.provider_configuration_file_resource_path" value ="./META-INF/treecache.xml"/>
</properties>

From the hibernate 3.2.6 distribution archive extract treecache.xml from the etc directory.
Place it in the <netbeansprojects>\enterprise1\enterprise1-ejb\src\conf folder.
Alternatively, create a well formed xml document by right clicking the enterprise1-ejb node and selecting new/other/xml/xml document. Name it treecache.xml and copy the contents of the treecache.xml file from inside the hibernate archive.
Discard the classpath and depends lines. They are not needed outside a JBoss Server. You shouldn't set the transaction manager attribute either. Also if you 're running windows set loopback to true.

That's it. You can proceed to develop the application either as a hybrid JPA/Hibernate instance (as in this example) or switch to hibernate exclusively. There are no explicit (or worse, absolute path) classpath entries either in the domain or the application and no redundant libraries installed all over the place.

If all goes well, when you deploy the application and test it, transactional caching should be working properly (for the entities/collections you have opted to cache). You should be registering logging output in the server log and if you have netbeans active in the netbeans output window.

Feel free to point errors or omissions.

Cheers,
Andreas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.