-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: incompatibility between Core 3.2.CR2 and Annotations3.1.0b10
PostPosted: Thu May 11, 2006 3:58 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
I get the following exception while creating EntityManagerFactory. This looks like a incompatibility between annotations and hibernate libs.

I use:
Hibernate Core 3.2.CR2
Hibernate Annotations 3.1.0 beta 10
Hibernate EntityManager 3.1.0 beta 8

java.lang.NoSuchMethodError: org.hibernate.cfg.NamingStrategy.foreignKeyColumnName(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
at org.hibernate.cfg.Ejb3JoinColumn.linkValueUsingDefaultColumnNaming(Ejb3JoinColumn.java:266)
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:198)
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:45)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641)
at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134)
at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at com.siemens.smarthome.AquireEntityManager.setUp(AquireEntityManager.java:13)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


The code disassabled from annotations jar.
Code:
if(ownerSide)
/* 266*/            columnName = getMappings().getNamingStrategy().foreignKeyColumnName(getPropertyName(), getMappings().getLogicalTableName(referencedTable), logicalReferencedColumn);


foreignKeyColumnName takes 4 parameters. I chacked that in version 3.1 it takes 3 parameters.

I tried to run the application with hibernate core 3.1 but there were other errors.

I don't understand. This error should break compilation!

Please give me some advice how to workaround this.

PS. I used the same persistence unit with jboss 4.0.4CR2. I will try to use libs shiped with jboss.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 4:05 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
When using jboss libs I get:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named smarthome
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at com.siemens.smarthome.AquireEntityManager.setUp(AquireEntityManager.java:13)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 4:27 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Add
Code:
        <provider>org.hibernate.ejb.HibernatePersistence</provider>


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 4:41 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
Code:
<provider>org.hibernate.ejb.HibernatePersistence</provider>


didn't help.

According to documentation it's only needed when having more than on implementation of JPA.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 4:48 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
I got it working *with jboss 4.0.4CR2* libs (at previoud try I missed some libs, because I thought I need to include only the libs I included in jboss project).


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 4:59 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Hmmm ...

If it helps
Code:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packfields(3) packimports(7) deadcode fieldsfirst splitstr(64) nonlb lnc radix(10) lradix(10)
// Source File Name:   Persistence.java

package javax.persistence;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.persistence.spi.PersistenceProvider;

// Referenced classes of package javax.persistence:
//            PersistenceException, EntityManagerFactory

public class Persistence {

            public static String PERSISTENCE_PROVIDER = javax/persistence/spi/PersistenceProvider.getName();
            protected static Set providers = new HashSet();
            private static final Pattern nonCommentPattern = Pattern.compile("^([^#]+)");

            public Persistence() {
            }

            public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName) {
/*  27*/        return createEntityManagerFactory(persistenceUnitName, null);
            }

            public static EntityManagerFactory createEntityManagerFactory(String persistenceUnitName, Map properties) {
/*  31*/        EntityManagerFactory emf = null;
/*  33*/        if(providers.size() == 0)
/*  34*/            findAllProviders();
/*  36*/        Iterator i$ = providers.iterator();
/*  36*/        do {
/*  36*/            if(!i$.hasNext())
/*  36*/                break;
/*  36*/            PersistenceProvider provider = (PersistenceProvider)i$.next();
/*  37*/            emf = provider.createEntityManagerFactory(persistenceUnitName, properties);
                } while(emf == null);
/*  40*/        if(emf == null)
/*  41*/            throw new PersistenceException((new StringBuilder()).append("No Persistence provider for EntityManager named ").append(persistenceUnitName).toString());
/*  43*/        else
/*  43*/            return emf;
            }

            private static void findAllProviders() {
                ClassLoader loader;
                Enumeration resources;
                Set names;
/*  50*/        loader = Thread.currentThread().getContextClassLoader();
/*  51*/        resources = loader.getResources((new StringBuilder()).append("META-INF/services/").append(javax/persistence/spi/PersistenceProvider.getName()).toString());
/*  52*/        names = new HashSet();
_L2:
                InputStream is;
/*  53*/        if(!resources.hasMoreElements())
/*  54*/            break; /* Loop/switch isn't completed */
/*  54*/        URL url = (URL)resources.nextElement();
/*  55*/        is = url.openStream();
/*  57*/        names.addAll(providerNamesFromReader(new BufferedReader(new InputStreamReader(is))));
/*  60*/        is.close();
/*  61*/        if(true) goto _L2; else goto _L1
                Exception exception;
/*  60*/        exception;
/*  60*/        is.close();
/*  61*/        throw exception;
_L1:
                Class providerClass;
/*  63*/        for(Iterator i$ = names.iterator(); i$.hasNext(); providers.add((PersistenceProvider)providerClass.newInstance())) {
/*  63*/            String s = (String)i$.next();
/*  64*/            providerClass = loader.loadClass(s);
                }

/*  66*/        break MISSING_BLOCK_LABEL_214;
                IOException e;
/*  68*/        e;
/*  69*/        throw new PersistenceException(e);
/*  71*/        e;
/*  72*/        throw new PersistenceException(e);
/*  74*/        e;
/*  75*/        throw new PersistenceException(e);
/*  77*/        e;
/*  78*/        throw new PersistenceException(e);
            }

            private static Set providerNamesFromReader(BufferedReader reader) throws IOException {
/*  85*/        Set names = new HashSet();
/*  87*/        do {
                    String line;
/*  87*/            if((line = reader.readLine()) == null)
/*  88*/                break;
/*  88*/            line = line.trim();
/*  89*/            Matcher m = nonCommentPattern.matcher(line);
/*  90*/            if(m.find())
/*  91*/                names.add(m.group().trim());
                } while(true);
/*  94*/        return names;
            }

}


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 11, 2006 5:15 am 
Newbie

Joined: Wed May 10, 2006 12:48 pm
Posts: 7
Location: Munich
So javax.persistence.PersistenceException: No Persistence provider for EntityManager named smarthome had nothing to do with anyhitng inside persistence.xml. I had no hibernate lib so the findAllProviders could not find any provider.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.