Sunday, August 06, 2006


Setting up JBoss 4.0.4.GA for EJB 3.0

I have been able to make EJB 3.0 work before using an old version of JBoss.
Now that JEE5 is officially released, I'm trying to revisit my old work.
Here are my experiences so far.

Hopefully, it will help others who might encounter the same problems.
I would appreciate feedback on how I can improve this.

I'm using Eclipse Webtools for development.
Eclipse version: 3.2.0 Webtools version: 1.5.0

JBoss and MySQL for deployment.
JBoss version: JBoss-4.0.4.GA and EJB 3.0 RC8

Issues encountered:

I got an error:

An EJB module must contain one or more enterprise beans. Intranet-EJB/ejbModule/META-INF ejb-jar.xml line 5

Explanation: Webtools only support up to EJB 2.1. Since EJB 3.0 doesn't need ejb-jar.xml, we can safely delete it. However, the compiler will give a warning like the one below. Just ignore it.

CHKJ2905W: The EJB Validator did not run because ejb-jar.xml could not be loaded. Run the XML validator for more information. Intranet-EJB Unknown

Explanation: Webtools currently support only up to EJB 2.1. We have to add EJB 3.0 support to the core JBoss installation.To do this, install EJB 3.0 RC8And follow instructions in the INSTALL.html.

EJB 3.0 files not compiling, libraries not found.
For ejb classes:



These files need to be added in Eclipse build path.

Note that you can use the JBoss default setup instead of the all setup as mentioned in the INSTALL.html.

Don't include ejb3-clustered-sfsbcache-service.xml and ejb3-entity-cache-service.xml if you're using the default setup because they are for the JBoss all setup only and not for default setup.

To test, run JBoss and you shouldn't encounter any errors. Try to deploy EJB3Trail.ear to deploy folder and it should work. For now, it will not work because there are missing files. See below.


Forum users are complaining about it here:

One of them, Sverker, created an unofficial patch:

Download the zip file and read README.txt. The file contains all the needed files to start the server correctly. However, there are still some missing files, which will be discussed below.

The error message is:

[ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=Intranet-EJB.jarjava.lang.RuntimeException: Field private javax.persistence.EntityManager com.tougher.intranet.impl.service.employee.UnitServiceImpl.em @PersistenceUnit in error: EMPTY STRING unitName but there is no deployments in scope at org.jboss.ejb3.injection.PersistenceContextHandler.loadFieldDependencies(

Explanation: The keyword here is "there is no deployment in scope". It means there is no EntityManager because there's no Persistence Context. We have to add persistence.xml in the EJB file. We need for it to point it to our DataSource.

After adding persistence.xml, the job is not quite done. Make sure your jdbc jar files are added to jboss lib folder, and then add the DataSource file in jboss deploy folder. Set url, username and password. Restart server and the problem should be gone.

Explanation: Client needs these jars found in <jboss>\client.






Now, even the file doesn't have the last two jars. I got it from an older version (jboss-4.0.4.CR2).
Honestly, what's with JBoss these days? They seemed to be doing very well prior to this release...

Using ThreadLocal: falseinvoke called, but our invoker is disconnected, discarding and fetching another fresh invoker for: InvokerLocator [socket://]connect called for: org.jboss.remoting.transport.socket.SocketClientInvoker@50988

Explanation: It's not doing any harm so I just ignore it. I've seen it being asked about in the forums; no answer so far.

After you change something in your EJB or EAR,you can effect the changes by going to Servers->Jboss->Publish. You don't have to restart.

I'm surprised that we now can. Sweet.

It appears as a stub first when it stops at the breakpoint. After I associated it with the source code, I'm able to step through it.

If your persistence class don't implement Serializable, you'll get an exception.


It is usefull. Thanx.

But did you meet this kind of error message?

10:43:46,703 ERROR [UDP]
at org.jgroups.util.List.readExternal(
at org.jgroups.protocols.UDP.handleIncomingUdpPacket(
at org.jgroups.protocols.UDP$

Thank you.
Gabor from Hungary
Hello Gabor,

Sorry. No I haven't.

I'm pasting the javadoc in here, as this might help you.

It looks like it has something to do with Serialization. Perhaps your classes changed locally but you weren't able to update the classes that were deployed?

Exception indicating the failure of an object read operation due to unread primitive data, or the end of data belonging to a serialized object in the stream. This exception may be thrown in two cases:

An attempt was made to read an object when the next element in the stream is primitive data. In this case, the OptionalDataException's length field is set to the number of bytes of primitive data immediately readable from the stream, and the eof field is set to false.
An attempt was made to read past the end of data consumable by a class-defined readObject or readExternal method. In this case, the OptionalDataException's eof field is set to true, and the length field is set to 0.
I had this kind of error when there was running an older version of jboss in my local network. Both jbosses (old and new) used the same cluster udp address and partition name. Set parameters: --udp and --partition


Usefull site, I will be using this site for future references.

I just wanna ask if you encounter my error message below. Im using JBOSS-4.0.4.GA AS and NB 5.5 Beta 2 with JBOSS Bundle.

17:29:06,891 WARN [ServiceController] Problem starting service persistence.units:ear=TestEJB.ear,jar=TestEJB-ejb.jar,unitName=TestEJB-ejbPU
javax.naming.NameNotFoundException: Test not bound
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getBinding(
at org.jnp.server.NamingServer.getObject(

Thankz :)

Christopher Keith from the Philippines.

I have also the same error and I don't know where the problem is...

10:51:26,783 WARN [ServiceController] Problem starting service persistence.units:ear=EAW1.ear,jar=EAW1-ejb.jar,unitName=EAW1-ejbPU
javax.naming.NameNotFoundException: mysql-EAW not bound

--- MBeans waiting for other MBeans ---
ObjectName: persistence.units:ear=EAW1.ear,jar=EAW1-ejb.jar,unitName=EAW1-ejbPU
Reason: javax.naming.NameNotFoundException: mysql-EAW not bound
I Depend On:

The mysql-EAW is the name I gave to the data source when creating the persistence unit in netbeans 5.5.

see here:

Thx for helping me
Hello to imacx, this might help you.

Apologies to Christopher for the late reply,
this might help your problem.
Thx, I found my error, a "java:/" was missing in the persistence.xml created by netbeans:


Have a nice day
Its nice of you to post problems you encountered, so that others may not get stuck there.

I am new to EJB3, can you please email me a simple bare minimal hello world example of EJB3.

I tried making my own, but I keep gettin EJb not bound exception.

my email: mustafa[dot]kachwala[at]

Hi Mustafa,

I'm sorry, I haven't had the chance to work in EJB for a long time now. I had to revert back to Hibernate 2.1.

Anyway, this might help you.

I created a session bean(stateless) with remote interface..I don't know how to package..I exported the whole EJB project as jar file..I started JBoss and it threw an error..

[ServiceController] Problem creating service jboss.j2ee:service=EJB3,module=Calculator.jar
java.lang.ClassNotFoundException: Unexpected error during load of: com.StatelessCalculator, msg=Bad version number in .class file

Please help...
So far your tips have been extremely useful!! Thank you.

i am getting the following error when i start up my JBoss server. There are some tables it does not want to create.

The Error::
16:39:43,014 WARN [ServiceController] Problem starting service jboss.j2ee:service=EjbModule,module=AccountActivationsImages.jar
org.jboss.deployment.DeploymentException: Error while creating table accountactivationsimages; - nested throwable: (java.sql.SQLException: Specified k
ey was too long; max key length is 1024 bytes)

i have tried changing settings in MySQL as well but still get the same error.
Please could you help me??
Hi Kenneth,

this has something to do with MySQL...

This might help...
Hi Anonymous,

Looks like the JVM you're using is earlier than java 5.
Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?