views:

45

answers:

3

I have been struggling trying to test a super simple EJB project in netbeans. i have tried several examples form my java book, and an even simpler example i found online (http://javadude.wordpress.com/2010/02/22/tutorial-most-simple-test-application-for-embedded-glassfish-netbeans-hudson/). this is a super basic EJB that only just adds two numbers.. that's it!! it runs fine, but no matter how i try to test it, nothing works. even more puzzling, i get two different errors on the two different laptops i test it on. obviously i am doing something very wrong... any advice would be so appreciated.

one error i get is:

Testcase: testAddNumbers(bean.MyBeanTest): Caused an ERROR No EJBContainer provider available: no provider names had been found.

javax.ejb.EJBException: No EJBContainer provider available: no provider names had been found.

and the other is:


SEVERE: Exception while deploying the app java.lang.IllegalArgumentException: Invalid ejb jar [WebTestEmb.jar]: it contains zero ejb. Note: 1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.


clearly, i do have an ejb in my project. it is built exactly as in the directions at the url i posted above.

thanks!

A: 

I have been struggling trying to test a super simple EJB project in netbeans. i have tried several examples form my java book, and an even simpler example i found online

Using the EJBContainer API (to start an Embedded EJB container in your testes) is the way to go in Java EE 6 (Adam Bien blogged about this in Embedding EJB 3.1 Container Into Your Unit Tests - Boot Time: 5 Seconds).

That being said, you might be interested by the following links:

What version of GlassFish are you using? If you're not using the latest 3.0.1, I'd suggest giving it a try.

Pascal Thivent
Pascal, thanks for the advice. The example i mentioned above does use the EJBContainer API and it doesnt seem to work. I also tried the example you mention as well, and that didnt work either. i still get the same errors. i'm using Glassfish 3.0.1 build 22 which i think is the latest.any other ideas?thanks!
@user210881: Yes, I noticed the example is using the EJBContainer API. My goal was actually to confirm that this is the way to go. And I already used this API successfully but I'll re-check later.
Pascal Thivent
A: 

Never mind, looks like i finally got it working. i cant believe this took a week to figure out!

adding:

Map properties = new HashMap(); properties.put(EJBContainer.MODULES, new File("C:\Documents and Settings\tiv\My Documents\NetBeansProjects\WebTestEmb\build\web\WEB-INF\classes"));

and then using those properties in the createEJBContainer() call fixes the error.

A: 

No matter what I write in for the property for EJBContainer.MODULES, it just does not want to work. Also this module workaround is just hacking. I don't think it is supposed to work this way. For the time untill this will be fixed in glassfish, i'll try OpenEJB.

I am a bit disappointed though with glassfish right now. They say everyting works out of the box, and it is just not the case. There are no options to set, and the error messages saying nothing...

Szobi