Posted by: Venugopal S on: February 2, 2009
Hi,
Our application runs on Jboss4.0.5 for almost 2.5 years now. One thing that was appealing me the most with Jboss5 was its proved performance wrt JBoss Messaging. We have been using JBossMQ for long.
The day wasn’t pleasant when i started exploring Jboss5. It threw all strange errors and Exceptions to a newbie like me at the outset. Ok.. After about 3/4th of a week was spent, i was gaining grip on the new beast Jboss5 (finally).
You should not be bewildered initially. I would like to mention few things i learnt the very hard way.
Migrating to Jboss5:
In application.xml we have to replace
<application xmlns=”http://java.sun.com/xml/ns/j2ee” version=”1.4″
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/application_1_4.xsd”>
<display-name>ss</display-name>
WITH
<?xml version=”1.0″ encoding=”UTF-8″?>
<application xmlns=”http://java.sun.com/xml/ns/javaee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd”
version=”5″>
And the <description> tag should be removed.
In persistence.xml:
The root element was simple and plain. We need to update it to
<persistence
xmlns=”http://java.sun.com/xml/ns/persistence”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=”http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd”
version=”1.0″>
web.xml : Mixing <servlet> and <servlet-mapping> is not allowed in Jboss 5 and the dtd has to be updated to
<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
“http://java.sun.com/dtd/web-app_2_3.dtd”>
And in all the occurrences of
this.queueConnectionFactory = (QueueConnectionFactory) this.ctx
.lookup(“QueueConnectionFactory”);
we need to replace with
this.queueConnectionFactory = (QueueConnectionFactory) this.ctx
.lookup(“ConnectionFactory”);
jboss-app.xml which contains
<!DOCTYPE jboss-app
PUBLIC “-//JBoss//DTD J2EE Application 1.4//EN”
“http://www.jboss.org/j2ee/dtd/jboss-app_4_0.dtd”>
has to be updated with the latest dtd as
<!DOCTYPE jboss-app
PUBLIC “-//JBoss//DTD Java EE Application 5.0//EN”
“http://www.jboss.org/j2ee/dtd/jboss-app_5_0.dtd”>.
The annotations are a bit different in Jboss 5.
In a POJO class, we were using the JoinColumn annotations like
@ManyToOne
@JoinColumn(name = “orderid”, insertable = false)
which has to be modified to
@ManyToOne
@JoinColumns({@JoinColumn(name = “orderId”,referencedColumnName=”orderId”,insertable = false)})
referencedColumnName is a must in JBoss 5 for this annotation.
For JMS :
In case of Jboss4, all the JMS related stuff had to go in jbossmq-destinations-service.xml.
Sample element :
<mbean code=”org.jboss.mq.server.jmx.Queue”
name=”jboss.mq.destination:service=Queue,name=TotalOrderQueue”>
<attribute name=”JNDIName”>queue/TotalOrderQueue</attribute>
<attribute name=”RedeliveryDelay”>10000</attribute>
<attribute name=”RedeliveryLimit”>3</attribute>
<depends optional-attribute-name=”DestinationManager”>jboss.mq:service=DestinationManager</depends>
</mbean>
But in Jboss 5, Jboss messaging has replaced JbossMQ. Jboss messaging is significantly faster than JbossMQ(Ref : http://www.jboss.org/file-access/default/members/jbossmessaging/freezone/docs/userguide-2.0.0.alpha1/html/performance.html).
The configurations need to be tweaked a bit to be read as follows (also the configuration filename has changed to destinations-service.xml):
<mbean code=”org.jboss.jms.server.destination.QueueService”
name=”jboss.messaging.destination:service=Queue,name=TotalOrderQueue”
xmbean-dd=”xmdesc/Queue-xmbean.xml”>
<depends optional-attribute-name=”ServerPeer”>jboss.messaging:service=ServerPeer</depends>
<depends>jboss.messaging:service=PostOffice</depends>
</mbean>
Hope this helps!