strange behaviour [message #524782] |
Fri, 02 April 2010 13:20 |
G Messages: 6 Registered: April 2010 |
Junior Member |
|
|
Hi !
I am running this code:
public class Test {
public static void main(String[] args) {
Persistence.createEntityManagerFactory("MyPersistenceUnit");
}
}
Then the environemnt outputs (near exactly):
run-single:
2010-4-2 0:35:05 javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log�
WARNING: javax.persistence.spi::No valid providers found using:�
2010-4-2 0:35:05 javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log�
WARNING: javax.persistence.spi::潲朮散汩灳攮灥牳楳瑥湣攮橰愮健牳楳瑥湣敐牯癩摥�
- jar:file:/D:/NetBeans/java3/modules/ext/eclipselink/eclipselink-2.0.0.jar!/META-INF/services/javax.persistence.spi.PersistenceProvider�
2010-4-2 0:35:05 javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log�
WARNING: javax.persistence.spi::潲朮散汩灳攮灥牳楳瑥湣攮橰愮健牳楳瑥湣敐牯癩摥�
- jar:file:/D:/Java/project%20workspace/Identity/dist/lib/eclipselink-2.0.0.jar!/META-INF/services/javax.persistence.spi.PersistenceProvider�
2010-4-2 0:35:05 javax.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log�
WARNING: javax.persistence.spi::潲朮散汩灳攮灥牳楳瑥湣攮橰愮健牳楳瑥湣敐牯癩摥�
- jar:file:/D:/Java/project%20workspace/Utilities/dist/lib/eclipselink-2.0.0.jar!/META-INF/services/javax.persistence.spi.PersistenceProvider�
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named MyPersistenceUnit�
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Whats going on ?
I am using Netbeans 6.8.
Thanks !
[Updated on: Fri, 02 April 2010 13:22] Report message to a moderator
|
|
|
Re: strange behaviour [message #524797 is a reply to message #524782] |
Fri, 02 April 2010 14:40 |
|
Hi,
how looks your persistence.xml?
IMO a minimum version of a persistence.xml is needed, e.g.:
<?xml version="1.0" encoding="utf-8"?>
<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_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="MyPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
</persistence-unit>
</persistence>
From now you can configure all in your java code or using the xml feature.
Hope this helps.
Best regards
Christian
[Updated on: Fri, 02 April 2010 14:40] Report message to a moderator
|
|
|
Re: strange behaviour [message #524851 is a reply to message #524797] |
Fri, 02 April 2010 23:29 |
G Messages: 6 Registered: April 2010 |
Junior Member |
|
|
Yes, the "error" appears provided the persistence.xml is present.
An interesting fact is that my code runs when in testcase and not in the main source code place.
E.g.
(in test case code)
void test(){
MainClass.main(null);
}
Note that the MainClass here corresponds to Test in the code from my last post.
[Updated on: Fri, 02 April 2010 23:30] Report message to a moderator
|
|
|
Re: strange behaviour [message #525326 is a reply to message #524851] |
Tue, 06 April 2010 09:01 |
|
Are your tests and main sources in different jar files? If so, maybe the persistence.xml is present in the "test.jar" but not in the "main-src.jar".
all the best,
Christian
|
|
|
|
Powered by
FUDForum. Page generated in 0.04237 seconds