Hibernate tutorial: How to install hibernate/jboss tool for eclipse

Hibernate tool is a useful tool for hibernate developer to generate hibernate relate file such as xml mapping file, hibernate config files… Further more it has reverse engineering feature that allow you to generate Hibernate model class from existed database tables.
In this post i will guide you how to install that tool into eclipse to increase your productivity in hibernate application development.

1. Requirement

To install Hibernate tool you need to know what version of eclipse that you using. You can achive that by go to Help->About in Eclipse IDE

ecipse version
eclipse version

2. Install Jboss tool

In eclipse IDE go to Help->Eclipse Marketplace and navigate to Find field,
enter search text “Jboss tool”. Choose the Jboss tool match with your ecipse version and install.

install jboss tool
install jboss tool

Eclipse and Tomcat:java.lang.OutOfMemoryError: PermGen space

When run web application in eclipse with tomcat server you maybe get this issue:

java.lang.OutOfMemoryError: PermGen space

 

Solution

Increase JVM parameters

-XX:PermSize=<size>
-XX:MaxPermSize=<size>

You do as follow step to do that:

  • Open server on eclipse server tab
  • Choose Open launch configuration
  • Open Agurment-> add above parameters with increase to VM agurment session

For example i usually use

-XX:PermSize=256m
-XX:MaxPermSize=256m

deploy jax-ws or metro web services on tomcat server

When deploy jax-ws application on tomcat you maybe get this issue

SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: javax.xml.ws.soap.Addressing.responses()Ljavax/xml/ws/soap/AddressingFeature$Responses;
java.lang.NoSuchMethodError: javax.xml.ws.soap.Addressing.responses()Ljavax/xml/ws/soap/AddressingFeature$Responses;

This error occur cause the version JAXWS we use difference with the version JAX-WS ship with java. We can check version ship with java by run wsimport

in $JAVA_HOME/bin by follow command:

wsimport -version

So solution you can using wsimport or wsgen ship with java version to build web service or web service client.
But what happend if you still want using new version JAX-WS?
Well let me show you solution. The answer for that is using the endorsed overriding mechanism.
This guide will help you on Tomcat 6 and 7.

  • Create folder endorsed in $CATALINA_HOME
  • Copy following file in $JAXWS_HOME/lib jax-ws.api.jar,jaxb-api.jar,webservices-api.jar into endorsed

With above change your tomcat will work well with version JAX-WS that you want.
If it still not work so that must has problem on tomcat’s startup script(linux/unix). In that case you must add following parameter into startup script(linux/unix) in JAVA_OPTS parameters

 export JAVA_OPTS="$JAVA_OPTS" -Djava.endorsed.dirs="path of endoresed folder"

how to create jar from classes

This tutorial i show you how to create jar file from classes folder. To begin with this guide, i have some assumption

  • Your OS is Windows
  • Your classes folder: E:\classes
  • Your OS Environment JAVA_HOME variable already set and $JAVA_HOME\bin already in $PATH

Step1: open command line tool, move to directory E\classes

Step2: Using follow command to create your jar file

jar -cf file_name_jar.jar *

In my case now it will be:

jar -cf cyclos.jar *

Create jar file for deploy has many benefit. In web we can just copy jar file if want to change some minor code without deploy or copy all libs so can make decrease the down time of your application.

How to create web service client using Metro JAX-WS

In this tutorial i demo how to create web service client from wsdl using JAX-WS
Let’s start

1.  Prepare JAX-WS

Go to this https://jax-ws.java.net/ and choose version you want to download that suite for your environment. I’m using tomcat 7 and JDK 7 so i using latest one now JAX-WS 2.2.8

Unzip to any folder in my for example: E:\JAXWS-RI

2. Setup environment

– create OS enviroment JAVA_HOME point to your java sdk

– create JAXWS_HOME point to your unzip folder

3. Generate code client

We will using wsimport tool in $JAXWS_HOME\bin to create web service client from wsdl resource. We can using wsdl file or http url point that wsdl resource.
Following command will generate class runtime and source code( –keep parameter tell tool keep source code for us)

E:\JAXWS-RI\bin>wsimport -keep IpnWebRetrieval.xml

After that you can copy code to any IDE tool to write your own project or create lib to import to your project.