Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » strange behaviour(JavaSE app)
strange behaviour [message #524782] Fri, 02 April 2010 13:20 Go to next message
G  is currently offline G Friend
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 Go to previous messageGo to next message
Christian is currently offline ChristianFriend
Messages: 8
Registered: March 2010
Junior Member
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 Go to previous messageGo to next message
G  is currently offline G Friend
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 Go to previous messageGo to next message
Christian is currently offline ChristianFriend
Messages: 8
Registered: March 2010
Junior Member
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
Re: strange behaviour [message #525704 is a reply to message #524782] Wed, 07 April 2010 13:58 Go to previous message
G  is currently offline G Friend
Messages: 6
Registered: April 2010
Junior Member
It is.

I am using spring framework, is this a factor anyway?
Previous Topic:Cannot merge entity when there is other entity extends
Next Topic:New with JPA
Goto Forum:
  


Current Time: Thu Apr 25 23:21:32 GMT 2024

Powered by FUDForum. Page generated in 0.03400 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top