Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within EJB and other Jakarta /Java EE Technologies
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
EJB and other Jakarta /Java EE Technologies
How to use JUnit and EJB3
Georg Joo
Ranch Hand
Posts: 49
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I want to
test
my EJB3 with
JUnit
. But I get allways following error :
javax.persistence.PersistenceException: No Persistence provider for EntityManager named mainService at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) at at.joo.ejb.session.main.TestCaseESLoginBean.setUp(TestCaseESLoginBean.java:29) at junit.framework.TestCase.runBare(TestCase.java:125)
The setup methode looks like :
protected void setUp() throws Exception { super.setUp(); emf = Persistence.createEntityManagerFactory("mainService"); em = emf.createEntityManager(); .... }
My persistence.xml :
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name ="mainService" transaction-type="RESOURCE_LOCAL" > <class>at.joo.ejb.session.main.ESLoginBean</class> <properties> <property name="jdbc.driver" value="org.gjt.mm.mysql.Driver"/> <property name="jdbc.connection.string" value="jdbc:mysql://localhost:3306/test"/> <property name="jdbc.user" value="root"/> <property name="jdbc.password" value=""/> </properties> </persistence-unit> </persistence>
What can I do ? Where is the right place for the persistence.xml file ?
SCJP, SCWCD, SCBCD<br /> <br />Vienna, Austria
Jaikiran Pai
Sheriff
Posts: 10445
227
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I havent worked with EJB3 much, but EJBs are server side components and they cannot be tested with JUnit. You might have to use
Cactus
instead, which is very similar to JUnit but allows you to test server side components.
[
My Blog
] [
JavaRanch Journal
]
Georg Joo
Ranch Hand
Posts: 49
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi
I have the book "Pro
EJB
3" of Apress. There is a description to test EJB3 with JUnit. It schoud be possible.
But I will take a look to Cactus.
Thanks
Georg
SCJP, SCWCD, SCBCD<br /> <br />Vienna, Austria
Whose rules are you playing by? This tiny ad doesn't respect those rules:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Working with DataNucleus: How I solved the "No persistence providers available" problem.
hibernate persistence.xml question
JPA not working with EJB3
problem in pro EJB3 chapter 2 code
I'm trying to build a JPA application , but i am getting an error NoClassFound
More...