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!
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.