Topic
  • 21 replies
  • Latest Post - ‏2010-03-19T16:04:53Z by ishakteyran
ishakteyran
ishakteyran
24 Posts

Pinned topic JPA application noclassdeffound error

‏2010-03-10T23:33:40Z |
hello to all,

i am developing my first JPA application on RAD 7.5.5 windows vista business, and using websphere application server 7.0 .

using RAD , i created a JPA application and i created my entities and entity managers as well successfully, then for trying to actually manipulate my data, i created a Deneme.java which has the code



package source;   

import entities.controller.*; 

import entities.*;   

import javax.persistence.*;   

public 

class Deneme 
{   

public 

static 

void main(String[] args) 
{ EntityManager em = Persistence.createEntityManagerFactory(
"Dene").createEntityManager(); System.out.print(
"success");   
}   
}


and i made the application run as java application but it gave the following error :

Exception in thread "main" java.lang.NoClassDefFoundError: org.apache.commons.collections.set.MapBackedSet
at org.apache.openjpa.lib.util.concurrent.ConcurrentReferenceHashSet.<init>(ConcurrentReferenceHashSet.java:68)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBrokerSet(AbstractBrokerFactory.java:486)
at org.apache.openjpa.kernel.AbstractBrokerFactory.<init>(AbstractBrokerFactory.java:148)
at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.<init>(JDBCBrokerFactory.java:87)
at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCBrokerFactory.<init>(WsJpaJDBCBrokerFactory.java:77)
at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCBrokerFactory.newInstance(WsJpaJDBCBrokerFactory.java:122)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.apache.openjpa.kernel.Bootstrap.invokeFactory(Bootstrap.java:124)
at org.apache.openjpa.kernel.Bootstrap.newBrokerFactory(Bootstrap.java:62)
at org.apache.openjpa.persistence.PersistenceProviderImpl.getBrokerFactory(PersistenceProviderImpl.java:102)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:81)
at com.ibm.websphere.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:71)
at com.ibm.websphere.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:41)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:109)
at org.apache.openjpa.persistence.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:53)
at javax.persistence.Persistence.createFactory(Persistence.java:172)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:112)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:66)
at source.Deneme.main(Deneme.java:20)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.set.MapBackedSet
at java.net.URLClassLoader.findClass(URLClassLoader.java:421)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:346)
at java.lang.ClassLoader.loadClass(ClassLoader.java:609)
... 22 more


using the first line of the exception i made asearch on google and i found the suggestion on http://www.javaworld.com/javaforums/showflat.php?Cat=2&Board=xmljava&Number=8296&page=2&view=collapsed&sb=5&o=&fpart=1 and copied commons collectins, beanutils, digester, logging and openjpa latest zip file to the build path of my application.

and i made the aplication run. but still i get the very same error :(

if it will make any help here is also the persistence.xml contents

<?xml version=
"1.0" encoding=
"UTF-8"?> <persistence version=
"1.0" xmlns=
"http://java.sun.com/xml/ns/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_1_0.xsd"> <persistence-unit name=
"Dene"> <jta-data-source>jdbc/DeneJPA</jta-data-source> <class>entities.Child</class> <class>entities.Parent</class> <properties> <property name=
"openjpa.jdbc.Schema" value=
"Schema"/> </properties> </persistence-unit> </persistence>


can anyone please suggest me how to come over of this problem ?

thank you
Updated on 2010-03-19T16:04:53Z at 2010-03-19T16:04:53Z by ishakteyran
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T03:37:00Z  
    I also had trouble trying to get OpenJPA from websphere to work in a standalone java application. I got around that problem by using the OpenJPA from Apache. Here's the list of jars you need to use OpenJPA in a java application (version numbers may be different):

    commons-collections-3.2.jar
    commons-lang-2.1.jar
    commons-pool-1.3.jar
    derbyclient.jar
    geronimo-jpa_3.0_spec-1.0.jar
    geronimo-jta_1.1_spec-1.1.jar
    openjpa-1.2.1.jar
    serp-1.13.1.jar

    In addition, another problem looking at your persistent.xml: you can't use data source here. Switch to driver manager. RAD can help with setting the necessary OpenJPA properties, go to "JPA Tools -> Configure project for JDBC Deployment". In the dialog select "Set connection directly via properties".
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T03:38:46Z  
    • jim_zhang
    • ‏2010-03-11T03:37:00Z
    I also had trouble trying to get OpenJPA from websphere to work in a standalone java application. I got around that problem by using the OpenJPA from Apache. Here's the list of jars you need to use OpenJPA in a java application (version numbers may be different):

    commons-collections-3.2.jar
    commons-lang-2.1.jar
    commons-pool-1.3.jar
    derbyclient.jar
    geronimo-jpa_3.0_spec-1.0.jar
    geronimo-jta_1.1_spec-1.1.jar
    openjpa-1.2.1.jar
    serp-1.13.1.jar

    In addition, another problem looking at your persistent.xml: you can't use data source here. Switch to driver manager. RAD can help with setting the necessary OpenJPA properties, go to "JPA Tools -> Configure project for JDBC Deployment". In the dialog select "Set connection directly via properties".
    ... forgot to mention, "derbyclient.jar" is of course only necessary if you are going against Derby, you will need the correct JDBC client jar here for your specific database type.
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T03:41:43Z  
    • jim_zhang
    • ‏2010-03-11T03:38:46Z
    ... forgot to mention, "derbyclient.jar" is of course only necessary if you are going against Derby, you will need the correct JDBC client jar here for your specific database type.
    Or, if your goal is to deploy JPA to WebSphere, not run it in a standalone java application, a better way to test the entity beans is using the Universal Test Client.
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T12:57:28Z  
    hello jim_zhang, thank you for your reply, however i can say that i created teh application as a Java Application but at the end i intend to use JPA with JSF in another web application, the purpose for creating only a JPA application is to see how JPA will work, and not to be inetrested in other web or JSF problems. So , if in web appliations i will need to make some different configurations , can you please let me know what they are ?
    after my post here, i used to add the collections-jar, and other jars you listed in your reply, to my classpath and somehow it worked. and then i got an error saying noclassdeffound for com.ibm.ffdc.manager , and i found it also as described in http://www-01.ibm.com/support/docview.wss?uid=swg21358301 , and fixed that problem, but after all that, i have another error which is

    
    92  Dene  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 261  Dene  INFO   [main] openjpa.jdbc.JDBC - Using dictionary 
    
    class 
    "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 1055  Dene  WARN   [main] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at 
    
    class load time with a javaagent: 
    "[class entities.Parent, class entities.Child]". success success2 Exception in thread 
    "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred 
    
    while parsing the query filter 
    "SELECT p FROM Parent p". Error message: The name 
    "Parent" is not a recognized entity or identifier. Known entity names: [] at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:574) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:105) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:37) at source.Deneme.main(Deneme.java:26)
    


    and the new persistence.xml is here :
    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <persistence version=
    "1.0" xmlns=
    "http://java.sun.com/xml/ns/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_1_0.xsd"> <persistence-unit name=
    "Dene"> <class>entities.Child</class> <class>entities.Parent</class> <properties> <property name=
    "openjpa.jdbc.Schema" value=
    "Schema"/> <property name=
    "openjpa.ConnectionDriverName" value=
    "com.ibm.db2.jcc.DB2Driver"/> <property name=
    "openjpa.ConnectionURL" value=
    "jdbc:db2://localhost:50000/DENE:retrieveMessagesFromServerOnGetMessage=true;"/> <property name=
    "openjpa.ConnectionUserName" value=
    "db2"/> <property name=
    "openjpa.ConnectionPassword" value=
    "db2"/> </properties> </persistence-unit> </persistence>
    


    and the Deneme.java class which gives the error :

    
    
    
    import entities.controller.*; 
    
    import entities.*;   
    
    import java.util.List; 
    
    import java.util.Set;       
    
    import javax.persistence.*;   
    
    public 
    
    class Deneme 
    {   @SuppressWarnings(
    "unchecked") 
    
    public 
    
    static 
    
    void main(String[] args) 
    { EntityManager em = Persistence.createEntityManagerFactory(
    "Dene").createEntityManager(); System.out.println(
    "success"); 
    //ParentManager pm =  (ParentManager) Persistence.createEntityManagerFactory("Dene").createEntityManager(); 
    //ChildManager cm =  (ChildManager) Persistence.createEntityManagerFactory("Dene").createEntityManager(); em.getTransaction().begin(); System.out.println(
    "success2"); List<Parent> p =  em.createNamedQuery(
    "getParent").getResultList(); System.out.println(
    "success3"); em.getTransaction().commit(); Parent pl= em.find(Parent.class, 
    "1");  
    //pm.getParent(); Set<Child> sc=pl.getChildCollection(); System.out.println(
    "success4"); 
    }   
    }
    


    in the atachment is the list of jar files included..
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T13:18:22Z  
    and what is Universal Test Client , and how can i use it ?
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T14:02:29Z  
    well, as suggested in openjpa's Enhancement page, for just to see if it is a problem of enhencament, i added the
    
    <property name=
    "openjpa.RuntimeUnenhancedClasses" value=
    "supported"/>
    


    to my persistence.xml

    and now, here is the error i look for a solution, if anyone has experienced these same errors, any help that will end my challenge will be appreciated so much.

    here is the output of the console.. :

    
    82  Dene  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 175  Dene  INFO   [main] openjpa.jdbc.JDBC - Using dictionary 
    
    class 
    "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 2421  Dene  INFO   [main] openjpa.Enhance - Creating subclass 
    
    for 
    "[class entities.Parent, class entities.Child]". This means that your application will be less efficient and will consume more memory than it would 
    
    if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available 
    
    for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead. success success2 Exception in thread 
    "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: 
    "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 
    {prepstmnt 329126814 SELECT t0.id, t0.name FROM Schema.Parent t0 
    } [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC, Errd=-2145779603, 0, 0, 0, -10, 0] 
    "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 2;-204;42704;SCHEMA.PARENT 2;-204;42704;SCHEMA.PARENT at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4245) at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4210) at org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:504) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.handleCheckedException(SelectResultObjectProvider.java:155) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:40) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: 
    "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 
    {prepstmnt 329126814 SELECT t0.id, t0.name FROM Schema.Parent t0 
    } [code=-204, state=42704] at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:852) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) ... 9 more NestedThrowables: com.ibm.db2.jcc.am.ro: 
    "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 at com.ibm.db2.jcc.am.ed.a(ed.java:676) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.d(tm.java:2511) at com.ibm.db2.jcc.am.tm.a(tm.java:1991) at com.ibm.db2.jcc.t4.fb.g(fb.java:140) at com.ibm.db2.jcc.t4.fb.a(fb.java:40) at com.ibm.db2.jcc.t4.t.a(t.java:32) at com.ibm.db2.jcc.t4.ub.i(ub.java:135) at com.ibm.db2.jcc.am.tm.fb(tm.java:1962) at com.ibm.db2.jcc.am.um.nc(um.java:2989) at com.ibm.db2.jcc.am.um.b(um.java:3760) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) com.ibm.db2.jcc.am.SqlException: 2;-204;42704;SCHEMA.PARENT at com.ibm.db2.jcc.am.ed.a(ed.java:679) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.d(tm.java:2511) at com.ibm.db2.jcc.am.um.a(um.java:2893) at com.ibm.db2.jcc.t4.fb.a(fb.java:189) at com.ibm.db2.jcc.t4.fb.b(fb.java:83) at com.ibm.db2.jcc.t4.t.b(t.java:69) at com.ibm.db2.jcc.t4.vb.c(vb.java:242) at com.ibm.db2.jcc.am.um.kc(um.java:2884) at com.ibm.db2.jcc.am.um.nc(um.java:2990) at com.ibm.db2.jcc.am.um.b(um.java:3760) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) com.ibm.db2.jcc.am.SqlException: 2;-204;42704;SCHEMA.PARENT at com.ibm.db2.jcc.am.ed.a(ed.java:679) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.a(tm.java:2018) at com.ibm.db2.jcc.t4.fb.n(fb.java:802) at com.ibm.db2.jcc.t4.fb.i(fb.java:259) at com.ibm.db2.jcc.t4.fb.c(fb.java:54) at com.ibm.db2.jcc.t4.t.c(t.java:44) at com.ibm.db2.jcc.t4.ub.j(ub.java:147) at com.ibm.db2.jcc.am.tm.hb(tm.java:2013) at com.ibm.db2.jcc.am.um.b(um.java:3819) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26)
    
  • SystemAdmin
    SystemAdmin
    14225 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T15:35:31Z  
    well, as suggested in openjpa's Enhancement page, for just to see if it is a problem of enhencament, i added the <pre class="jive-pre"> <property name= "openjpa.RuntimeUnenhancedClasses" value= "supported"/> </pre>

    to my persistence.xml

    and now, here is the error i look for a solution, if anyone has experienced these same errors, any help that will end my challenge will be appreciated so much.

    here is the output of the console.. :

    <pre class="jive-pre"> 82 Dene INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 175 Dene INFO [main] openjpa.jdbc.JDBC - Using dictionary class "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 2421 Dene INFO [main] openjpa.Enhance - Creating subclass for "[class entities.Parent, class entities.Child]". This means that your application will be less efficient and will consume more memory than it would if you ran the OpenJPA enhancer. Additionally, lazy loading will not be available for one-to-one and many-to-one persistent attributes in types using field access; they will be loaded eagerly instead. success success2 Exception in thread "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 {prepstmnt 329126814 SELECT t0.id, t0.name FROM Schema.Parent t0 } [code=-204, state=42704]SQLCA OUTPUT[Errp=SQLNQ1FC, Errd=-2145779603, 0, 0, 0, -10, 0] "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 2;-204;42704;SCHEMA.PARENT 2;-204;42704;SCHEMA.PARENT at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4245) at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4210) at org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:504) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:102) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:88) at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:64) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.handleCheckedException(SelectResultObjectProvider.java:155) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:40) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 {prepstmnt 329126814 SELECT t0.id, t0.name FROM Schema.Parent t0 } [code=-204, state=42704] at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:192) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:57) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:852) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) ... 9 more NestedThrowables: com.ibm.db2.jcc.am.ro: "SCHEMA.PARENT" is an undefined name.. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.58.82 at com.ibm.db2.jcc.am.ed.a(ed.java:676) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.d(tm.java:2511) at com.ibm.db2.jcc.am.tm.a(tm.java:1991) at com.ibm.db2.jcc.t4.fb.g(fb.java:140) at com.ibm.db2.jcc.t4.fb.a(fb.java:40) at com.ibm.db2.jcc.t4.t.a(t.java:32) at com.ibm.db2.jcc.t4.ub.i(ub.java:135) at com.ibm.db2.jcc.am.tm.fb(tm.java:1962) at com.ibm.db2.jcc.am.um.nc(um.java:2989) at com.ibm.db2.jcc.am.um.b(um.java:3760) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) com.ibm.db2.jcc.am.SqlException: 2;-204;42704;SCHEMA.PARENT at com.ibm.db2.jcc.am.ed.a(ed.java:679) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.d(tm.java:2511) at com.ibm.db2.jcc.am.um.a(um.java:2893) at com.ibm.db2.jcc.t4.fb.a(fb.java:189) at com.ibm.db2.jcc.t4.fb.b(fb.java:83) at com.ibm.db2.jcc.t4.t.b(t.java:69) at com.ibm.db2.jcc.t4.vb.c(vb.java:242) at com.ibm.db2.jcc.am.um.kc(um.java:2884) at com.ibm.db2.jcc.am.um.nc(um.java:2990) at com.ibm.db2.jcc.am.um.b(um.java:3760) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) com.ibm.db2.jcc.am.SqlException: 2;-204;42704;SCHEMA.PARENT at com.ibm.db2.jcc.am.ed.a(ed.java:679) at com.ibm.db2.jcc.am.ed.a(ed.java:60) at com.ibm.db2.jcc.am.ed.a(ed.java:127) at com.ibm.db2.jcc.am.tm.c(tm.java:2523) at com.ibm.db2.jcc.am.tm.a(tm.java:2018) at com.ibm.db2.jcc.t4.fb.n(fb.java:802) at com.ibm.db2.jcc.t4.fb.i(fb.java:259) at com.ibm.db2.jcc.t4.fb.c(fb.java:54) at com.ibm.db2.jcc.t4.t.c(t.java:44) at com.ibm.db2.jcc.t4.ub.j(ub.java:147) at com.ibm.db2.jcc.am.tm.hb(tm.java:2013) at com.ibm.db2.jcc.am.um.b(um.java:3819) at com.ibm.db2.jcc.am.um.Zb(um.java:673) at com.ibm.db2.jcc.am.um.executeQuery(um.java:647) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:264) at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:850) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:262) at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1595) at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:252) at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:509) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:384) at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:339) at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:420) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220) at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:206) at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94) at org.apache.openjpa.lib.rop.EagerResultList.<init>(EagerResultList.java:34) at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1228) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:990) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:805) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:775) at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:771) at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:517) at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:255) at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:294) at source.Deneme.main(Deneme.java:26) </pre>
    It appears that Schema.Parent is not being recognized. Do you have a schema named Schema that has a table Parent inside of it? You can check this out easily using the Database perspective. Also, does the username you are using have rights to view this schema?
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T16:26:05Z  
    It appears that Schema.Parent is not being recognized. Do you have a schema named Schema that has a table Parent inside of it? You can check this out easily using the Database perspective. Also, does the username you are using have rights to view this schema?
    like knkn4 said, you have likely specified a non-existing schema, or one that your user account doesn't have access to. Here's where the "Schema" value is picked up by OpenJPA from your persistence.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
    <persistence-unit name="Dene">
    <jta-data-source>jdbc/DeneJPA</jta-data-source>
    <class>entities.Child</class>
    <class>entities.Parent</class>
    <properties>
    <property name="openjpa.jdbc.Schema" value="Schema"/> // you specified default schema to be "Schema"
    </properties>
    </persistence-unit>
    </persistence>
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T16:53:53Z  
    well, i have the schema Schema , and the dataconnections explorer view is in the attachment, however about privilidges , i am not sure.. because when i open the control center of db2 and go to my database DENE , and find the table Parent, and double click on it, it says user ISAAC -is my operating system username- doesnt have access to make select from schema.parent table

    the messages that db2 produces are in the attachemnt picture, the red line is just for seperating different views.
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T18:04:14Z  
    well, i did log on with the db2 user which has administrative role , and under the DENE database,i expanded the users and groups and under users i gave the prilividges to user isaac to grant access to schema Schema .. and then i created two user groups named db2admn , and administrators (predefined in db2) and added the same privilidges for them also.

    and then i opened control panel -> computer management -> users and groups, and saw that user isaac is not a member db2admins, or db2users, and i added it to the db2admins groups, and tried to run the code again, but still it gives the same error :( can there be something that i need to make for openjpa see these changes such as restarting db2, or maybe RAD .. or if what i did is not enough, what more can i do to have this prilividge ??
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-11T18:19:20Z  
    after doing all these, i went to conrol center, and i right-clicked on parent and child tables and opened prilividges for them, and i saw that the user isaac doesnot have any privilidge, and i granted all access to user isaac and user group db2admn. but still it gives an error and it is the same sql 204 error :(

    what is the thing i cant see ??
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T16:08:36Z  
    after doing all these, i went to conrol center, and i right-clicked on parent and child tables and opened prilividges for them, and i saw that the user isaac doesnot have any privilidge, and i granted all access to user isaac and user group db2admn. but still it gives an error and it is the same sql 204 error :(

    what is the thing i cant see ??
    I saw in DB2 admin center that the schema name is '"Schema"' with the double quote. Try changing that in the persistence.xml and orm.xml if you have it.

    persistence.xml:
    <property name="openjpa.jdbc.Schema" value='"Schema"'/>

    orm.xml:
    <persistence-unit-metadata>
    <persistence-unit-defaults>
    <schema>"Schema"</schema>
    </persistence-unit-defaults>
    </persistence-unit-metadata>
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T16:11:05Z  
    • jim_zhang
    • ‏2010-03-12T16:08:36Z
    I saw in DB2 admin center that the schema name is '"Schema"' with the double quote. Try changing that in the persistence.xml and orm.xml if you have it.

    persistence.xml:
    <property name="openjpa.jdbc.Schema" value='"Schema"'/>

    orm.xml:
    <persistence-unit-metadata>
    <persistence-unit-defaults>
    <schema>"Schema"</schema>
    </persistence-unit-defaults>
    </persistence-unit-metadata>
    trying again, the HTML editor messed up my paste for the orm.xml:

    <persistence-unit-metadata>
    <persistence-unit-defaults>
    <schema>& q u o t ;Schema& q u o t ;</schema>
    </persistence-unit-defaults>
    </persistence-unit-metadata>
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T18:34:38Z  
    thank you jim_zhang for your suggestion,

    after i wrote my last reply, i tried installing and uninstalling DB2 several times with operating system control enabled and disables and i gave all privliges , but it didnt work, and then, by hand , i created the tables parent and child under DENE database after last installation and i saw that the default schema used for my vista account is SYSTEM , and when i changed the schema name in persistence.xml and orm.xml to SYSTEM, it worked fine when i added the line
    
    <property name=
    "openjpa.RuntimeUnenhancedClasses" value=
    "supported"/>
    {code into persistence.xml it worked fine, without any errors, but when i remove that line , it gives the same error i have mentioned in the above code, let me list them again : 
    {code
    }92  Dene  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 261  Dene  INFO   [main] openjpa.jdbc.JDBC - Using dictionary 
    
    class 
    "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 1055  Dene  WARN   [main] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at 
    
    class load time with a javaagent: 
    "[class entities.Parent, class entities.Child]". success success2 Exception in thread 
    "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred 
    
    while parsing the query filter 
    "SELECT p FROM Parent p". Error message: The name 
    "Parent" is not a recognized entity or identifier. Known entity names: [] at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:574) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:105) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:37) at source.Deneme.main(Deneme.java:26)
    


    the Deneme.java class

    
    
    
    import entities.controller.*; 
    
    import entities.*; 
    
    import java.util.List; 
    
    import java.util.Set; 
    
    import javax.persistence.*; 
    
    public 
    
    class Deneme 
    { @SuppressWarnings(
    "unchecked") 
    
    public 
    
    static 
    
    void main(String[] args) 
    { EntityManager em = Persistence.createEntityManagerFactory(
    "Dene").createEntityManager(); System.out.println(
    "success"); 
    //ParentManager pm =  (ParentManager) Persistence.createEntityManagerFactory("Dene").createEntityManager(); 
    //ChildManager cm =  (ChildManager) Persistence.createEntityManagerFactory("Dene").createEntityManager(); em.getTransaction().begin(); System.out.println(
    "success2"); List<Parent> p =  em.createNamedQuery(
    "getParent").getResultList(); System.out.println(
    "success3"); em.getTransaction().commit(); Parent pl= em.find(Parent.class, 
    "1");  
    //pm.getParent(); Set<Child> sc=pl.getChildCollection(); System.out.println(
    "success4"); 
    } 
    }
    


    what i think is there is something to fix about openjpa new versions, because it seems this ENhance thing is new, and i need to learn more about it, what it does, why is it useful, and how can i activate it so that my entitites will be "known" by jpa enhancer and my code will work fine either in java , jpa application or web application.

    anyone who has any idea or knowledge about this, if shares will be appreciated so much.

    thank you all
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T18:44:15Z  
    and in addition, your &q u ot suggestion about schema in persistence.xml , is very smart, i have not noticed that could be problem, but since i changed the default schema with SYSTEM , i cant try it out, but as "evil is in details", that could be my problem , this made me decide to give smarter names that are not likely to be quoted by db2.

    thanks again for your different view and bright suggestion.

    now the problem is JPA enhancer , i hope we can find a quick solution for that too, last night before exhausting, i have favourited all the tabs i was reading about jpa enhancer, and now i will continue to that, if anyyone doesnt return a reply, after all done, i will share the results,

    thank you all
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T20:01:11Z  
    @ jim_zhang

    well , i just checked the DB2 admin console again and i saw that SYSTEM schema is also in quotation marks, and it means, if it worked with SYSTEM schema without quotation marks , it should have worked with schema schema also, most probably the issue was about permissions.

    but what i dont understand is , i created a data model project in RAD, and i created logical data model, and then i created physical data model and when creating ddl from physical data model, i chose schema name as Schema. i did all these in "isaac" user account. and if i had been able to create this schema, then why i cant read or write the tables I created in it.

    i think one reason for that may be -even it is still nonsense for me- the connection i used to do all these is connected to database with the db2 admin user "db2" and its password ,but when teh application runs it doesnt use the authorization values described in the database connection, but it uses the operating system user authorization, to see if the user has right to act on the table, i dont know, i just think a reason for why it didnt work, it is reallyt weird,

    anyone who has an answer for this, please explain these details to know better :( and do not make mistake

    thank you all
  • jim_zhang
    jim_zhang
    86 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-12T21:41:24Z  
    @ jim_zhang

    well , i just checked the DB2 admin console again and i saw that SYSTEM schema is also in quotation marks, and it means, if it worked with SYSTEM schema without quotation marks , it should have worked with schema schema also, most probably the issue was about permissions.

    but what i dont understand is , i created a data model project in RAD, and i created logical data model, and then i created physical data model and when creating ddl from physical data model, i chose schema name as Schema. i did all these in "isaac" user account. and if i had been able to create this schema, then why i cant read or write the tables I created in it.

    i think one reason for that may be -even it is still nonsense for me- the connection i used to do all these is connected to database with the db2 admin user "db2" and its password ,but when teh application runs it doesnt use the authorization values described in the database connection, but it uses the operating system user authorization, to see if the user has right to act on the table, i dont know, i just think a reason for why it didnt work, it is reallyt weird,

    anyone who has an answer for this, please explain these details to know better :( and do not make mistake

    thank you all
    hi ishakteyran, at this point it gets a little difficult to compile a complete picture of your trouble points. But what I would suggest is that:
    • set up your DB2 schema and database with a tried-and-true DDL such as the "SAMPLE" database that you can create from the DB2 admin center. This gets you a solid foundation of the back-end that is guaranteed to work
    • test your connection properties in RAD with the "Datasource explorer" view. beside exploring for schemas and table, also perform a data sampling (right click on the table and Data -> Sample contents)
    • make sure to use the same connection properties in your JPA configuration that you've tested, including user account, schema, etc.
    • enable the JPA enhancer. i recommend against the property openjpa.RuntimeUnenhancedClasses. I have developed many JPA applications, web modules or standalone java applications, I never had to use that property. OpenJPA handles enhancement with a lot of flexibility, allowing build time, class load time (deploy time) and runtime (creating subclasses) enhancement. Your trouble should not have been caused by the enhancer.

    Hope that helps a bit.
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-19T00:13:49Z  
    • jim_zhang
    • ‏2010-03-12T21:41:24Z
    hi ishakteyran, at this point it gets a little difficult to compile a complete picture of your trouble points. But what I would suggest is that:
    • set up your DB2 schema and database with a tried-and-true DDL such as the "SAMPLE" database that you can create from the DB2 admin center. This gets you a solid foundation of the back-end that is guaranteed to work
    • test your connection properties in RAD with the "Datasource explorer" view. beside exploring for schemas and table, also perform a data sampling (right click on the table and Data -> Sample contents)
    • make sure to use the same connection properties in your JPA configuration that you've tested, including user account, schema, etc.
    • enable the JPA enhancer. i recommend against the property openjpa.RuntimeUnenhancedClasses. I have developed many JPA applications, web modules or standalone java applications, I never had to use that property. OpenJPA handles enhancement with a lot of flexibility, allowing build time, class load time (deploy time) and runtime (creating subclasses) enhancement. Your trouble should not have been caused by the enhancer.

    Hope that helps a bit.
    hello, sorry for such late reply, i was kept busy by an article writing for a data mining conference, what i did about to solve this issue was re-installation of DB2 express-C , and while installing giving my local username and password as db2 admin and disabling operating system level security. and it now works fine if i disable the enhancement, i will work on enhancement enabling, but first i need to see how JPA works, then i will try to enable enhancement. but now, here is a nonsense -at least for me- error again i receive, again i will now include persistence.xml , my main java code , and manager classes. and also the stack trace of the error. however , you will see that i have received this error before and i asked it in this post, what i want to ask is, that code, i have not used specifically parentManager class, but i have done everything from Entitymanager, and it has selected and listed the values of my entities, however as you will see in my main code, when i try to use managers of my entities -ParentManager in this case- it gives the same error, what would be your suggestion for this? what i do wrong ?? and how can it be fixed ??

    here are contents of my files :

    persistence.xml :

    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <persistence version=
    "1.0" xmlns=
    "http://java.sun.com/xml/ns/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_1_0.xsd"> <persistence-unit name=
    "Dene_JPA"> <class>entities.Child</class> <class>entities.Parent</class> <properties> <property name=
    "RuntimeUnenhancedClasses" value=
    "supported"/> <property name=
    "openjpa.ConnectionDriverName" value=
    "com.ibm.db2.jcc.DB2Driver"/> <property name=
    "openjpa.ConnectionURL" value=
    "jdbc:db2://localhost:50000/SAMPLE:retrieveMessagesFromServerOnGetMessage=true;"/> <property name=
    "openjpa.ConnectionUserName" value=
    "isaac"/> <property name=
    "openjpa.ConnectionPassword" value=
    "mypassword"/> <property name=
    "RuntimeUnenhancedClasses" value=
    "supported"/> </properties> </persistence-unit> </persistence>
    


    main class :

    
    
    
    package source;   
    
    import java.util.List;   
    
    import javax.persistence.*;   
    
    import entities.*; 
    
    import entities.controller.*;   
    
    public 
    
    class Main 
    {   
    /** * @param args */ 
    
    public 
    
    static 
    
    void main(String[] args) 
    { EntityManagerFactory emf = Persistence.createEntityManagerFactory(
    "Dene_JPA"); EntityManager em = emf.createEntityManager(); System.out.println(
    "success1"); 
    // TODO Auto-generated method stub ParentManager pm = 
    
    new ParentManager(emf); System.out.println(
    "success2"); ChildManager cm = 
    
    new ChildManager(emf); System.out.println(
    "success3"); Parent newParent = pm.getNewParent(); System.out.println(
    "success4"); Child newChild = cm.getNewChild(); System.out.println(
    "success5"); List<Parent> listParent=pm.getParent(); 
    //This is line 29 that gives the error. Child c= cm.findChildById(
    "5"); c.setParentid(pm.findParentById(
    "2")); em.persist(c); System.out.println(
    "success6"); newChild.setParentid(pm.findParentById(
    "3")); newChild.setName(
    "c11"); em.persist(newChild); System.out.println(
    "success7");   
    }   
    }
    

    ParentManager class :

    
    
    
    package entities.controller;   
    
    import com.ibm.jpa.web.JPAManager; 
    
    import javax.persistence.EntityManagerFactory; 
    
    import javax.persistence.EntityManager; 
    
    import com.ibm.jpa.web.NamedQueryTarget; 
    
    import com.ibm.jpa.web.Action; 
    
    import javax.persistence.Persistence; 
    
    import entities.Parent; 
    
    import java.lang.String; 
    
    import java.util.List; 
    
    import javax.persistence.Query;   
    /** * @author isaac * */ @JPAManager(targetEntity=entities.Parent.class) @SuppressWarnings(
    "unchecked") 
    
    public 
    
    class ParentManager 
    {   
    
    private EntityManagerFactory emf;   
    
    public ParentManager() 
    { 
    }   
    
    public ParentManager(EntityManagerFactory emf) 
    { this.emf = emf; 
    }   
    
    public 
    
    void setEntityManagerFactory(EntityManagerFactory emf) 
    { this.emf = emf; 
    }   
    
    private EntityManager getEntityManager() 
    { 
    
    if (emf == 
    
    null) 
    { 
    //You can create an EntityManagerFactory as shown in the code below. 
    //If you create an EntityManagerFactory you must call the 
    //dispose method when you are done using it. 
    //emf = Persistence.createEntityManagerFactory("Dene_JPA"); 
    
    throw 
    
    new RuntimeException( 
    "The EntityManagerFactory is null.  This must be passed in to the constructor or set using the setEntityManagerFactory() method."); 
    } 
    
    return emf.createEntityManager(); 
    }   @Action(Action.ACTION_TYPE.CREATE) 
    
    public String createParent(Parent parent) 
    
    throws Exception 
    { EntityManager em = getEntityManager(); 
    
    try 
    { em.getTransaction().begin(); em.persist(parent); em.getTransaction().commit(); 
    } 
    
    catch (Exception ex) 
    { 
    
    try 
    { 
    
    if (em.getTransaction().isActive()) 
    { em.getTransaction().rollback(); 
    } 
    } 
    
    catch (Exception e) 
    { ex.printStackTrace(); 
    
    throw e; 
    } 
    
    throw ex; 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return 
    ""; 
    }   @Action(Action.ACTION_TYPE.DELETE) 
    
    public String deleteParent(Parent parent) 
    
    throws Exception 
    { EntityManager em = getEntityManager(); 
    
    try 
    { em.getTransaction().begin(); parent = em.merge(parent); em.remove(parent); em.getTransaction().commit(); 
    } 
    
    catch (Exception ex) 
    { 
    
    try 
    { 
    
    if (em.getTransaction().isActive()) 
    { em.getTransaction().rollback(); 
    } 
    } 
    
    catch (Exception e) 
    { ex.printStackTrace(); 
    
    throw e; 
    } 
    
    throw ex; 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return 
    ""; 
    }   @Action(Action.ACTION_TYPE.UPDATE) 
    
    public String updateParent(Parent parent) 
    
    throws Exception 
    { EntityManager em = getEntityManager(); 
    
    try 
    { em.getTransaction().begin(); parent = em.merge(parent); em.getTransaction().commit(); 
    } 
    
    catch (Exception ex) 
    { 
    
    try 
    { 
    
    if (em.getTransaction().isActive()) 
    { em.getTransaction().rollback(); 
    } 
    } 
    
    catch (Exception e) 
    { ex.printStackTrace(); 
    
    throw e; 
    } 
    
    throw ex; 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return 
    ""; 
    }   @Action(Action.ACTION_TYPE.FIND) 
    
    public Parent findParentById(String id) 
    { Parent parent = 
    
    null; EntityManager em = getEntityManager(); 
    
    try 
    { parent = (Parent) em.find(Parent.class, id); 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return parent; 
    }   @Action(Action.ACTION_TYPE.NEW) 
    
    public Parent getNewParent() 
    { Parent parent = 
    
    new Parent(); 
    
    return parent; 
    }   @NamedQueryTarget(
    "getParent") 
    
    public List<Parent> getParent() 
    { EntityManager em = getEntityManager(); List<Parent> results = 
    
    null; 
    
    try 
    { Query query = em.createNamedQuery(
    "getParent"); results = (List<Parent>) query.getResultList(); 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return results; 
    }   @NamedQueryTarget(
    "getParentById") 
    
    public List<Parent> getParentById(String id) 
    { EntityManager em = getEntityManager(); List<Parent> results = 
    
    null; 
    
    try 
    { Query query = em.createNamedQuery(
    "getParentById"); query.setParameter(
    "id", id); results = (List<Parent>) query.getResultList(); 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return results; 
    }   @NamedQueryTarget(
    "getParentByName") 
    
    public List<Parent> getParentByName(String name) 
    { EntityManager em = getEntityManager(); List<Parent> results = 
    
    null; 
    
    try 
    { Query query = em.createNamedQuery(
    "getParentByName"); query.setParameter(
    "name", name); results = (List<Parent>) query.getResultList(); 
    } 
    
    finally 
    { em.close(); 
    } 
    
    return results; 
    } 
    }
    

    Error i receive :
    
    176  Dene_JPA  INFO   [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 644  Dene_JPA  INFO   [main] openjpa.jdbc.JDBC - Using dictionary 
    
    class 
    "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 3923  Dene_JPA  WARN   [main] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at 
    
    class load time with a javaagent: 
    "[class entities.Parent, class entities.Child]". success1 success2 success3 success4 success5 Exception in thread 
    "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred 
    
    while parsing the query filter 
    "SELECT p FROM Parent p". Error message: The name 
    "Parent" is not a recognized entity or identifier. Known entity names: [] at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:574) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:105) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:37) at entities.controller.ParentManager.getParent(ParentManager.java:144) at source.Main.main(Main.java:29)
    


    as i mentioned above too, when i didnt use ParentManager , and used Entitymanager to obtain entities it has worked last time, but now, i just wanted to work with ParentManager and Childmanager classes, but despite it allows them to be created, it says those entities are not knows, how can i make them to be known, where is my mistake, and how should i fix it?

    thank you all.
  • SystemAdmin
    SystemAdmin
    14225 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-19T13:39:11Z  
    hello, sorry for such late reply, i was kept busy by an article writing for a data mining conference, what i did about to solve this issue was re-installation of DB2 express-C , and while installing giving my local username and password as db2 admin and disabling operating system level security. and it now works fine if i disable the enhancement, i will work on enhancement enabling, but first i need to see how JPA works, then i will try to enable enhancement. but now, here is a nonsense -at least for me- error again i receive, again i will now include persistence.xml , my main java code , and manager classes. and also the stack trace of the error. however , you will see that i have received this error before and i asked it in this post, what i want to ask is, that code, i have not used specifically parentManager class, but i have done everything from Entitymanager, and it has selected and listed the values of my entities, however as you will see in my main code, when i try to use managers of my entities -ParentManager in this case- it gives the same error, what would be your suggestion for this? what i do wrong ?? and how can it be fixed ??

    here are contents of my files :

    persistence.xml :

    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <persistence version= "1.0" xmlns= "http://java.sun.com/xml/ns/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_1_0.xsd"> <persistence-unit name= "Dene_JPA"> <class>entities.Child</class> <class>entities.Parent</class> <properties> <property name= "RuntimeUnenhancedClasses" value= "supported"/> <property name= "openjpa.ConnectionDriverName" value= "com.ibm.db2.jcc.DB2Driver"/> <property name= "openjpa.ConnectionURL" value= "jdbc:db2://localhost:50000/SAMPLE:retrieveMessagesFromServerOnGetMessage=true;"/> <property name= "openjpa.ConnectionUserName" value= "isaac"/> <property name= "openjpa.ConnectionPassword" value= "mypassword"/> <property name= "RuntimeUnenhancedClasses" value= "supported"/> </properties> </persistence-unit> </persistence> </pre>

    main class :

    <pre class="jive-pre"> package source; import java.util.List; import javax.persistence.*; import entities.*; import entities.controller.*; public class Main { /** * @param args */ public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory( "Dene_JPA"); EntityManager em = emf.createEntityManager(); System.out.println( "success1"); // TODO Auto-generated method stub ParentManager pm = new ParentManager(emf); System.out.println( "success2"); ChildManager cm = new ChildManager(emf); System.out.println( "success3"); Parent newParent = pm.getNewParent(); System.out.println( "success4"); Child newChild = cm.getNewChild(); System.out.println( "success5"); List<Parent> listParent=pm.getParent(); //This is line 29 that gives the error. Child c= cm.findChildById( "5"); c.setParentid(pm.findParentById( "2")); em.persist(c); System.out.println( "success6"); newChild.setParentid(pm.findParentById( "3")); newChild.setName( "c11"); em.persist(newChild); System.out.println( "success7"); } } </pre>
    ParentManager class :

    <pre class="jive-pre"> package entities.controller; import com.ibm.jpa.web.JPAManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManager; import com.ibm.jpa.web.NamedQueryTarget; import com.ibm.jpa.web.Action; import javax.persistence.Persistence; import entities.Parent; import java.lang.String; import java.util.List; import javax.persistence.Query; /** * @author isaac * */ @JPAManager(targetEntity=entities.Parent.class) @SuppressWarnings( "unchecked") public class ParentManager { private EntityManagerFactory emf; public ParentManager() { } public ParentManager(EntityManagerFactory emf) { this.emf = emf; } public void setEntityManagerFactory(EntityManagerFactory emf) { this.emf = emf; } private EntityManager getEntityManager() { if (emf == null) { //You can create an EntityManagerFactory as shown in the code below. //If you create an EntityManagerFactory you must call the //dispose method when you are done using it. //emf = Persistence.createEntityManagerFactory("Dene_JPA"); throw new RuntimeException( "The EntityManagerFactory is null. This must be passed in to the constructor or set using the setEntityManagerFactory() method."); } return emf.createEntityManager(); } @Action(Action.ACTION_TYPE.CREATE) public String createParent(Parent parent) throws Exception { EntityManager em = getEntityManager(); try { em.getTransaction().begin(); em.persist(parent); em.getTransaction().commit(); } catch (Exception ex) { try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Exception e) { ex.printStackTrace(); throw e; } throw ex; } finally { em.close(); } return ""; } @Action(Action.ACTION_TYPE.DELETE) public String deleteParent(Parent parent) throws Exception { EntityManager em = getEntityManager(); try { em.getTransaction().begin(); parent = em.merge(parent); em.remove(parent); em.getTransaction().commit(); } catch (Exception ex) { try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Exception e) { ex.printStackTrace(); throw e; } throw ex; } finally { em.close(); } return ""; } @Action(Action.ACTION_TYPE.UPDATE) public String updateParent(Parent parent) throws Exception { EntityManager em = getEntityManager(); try { em.getTransaction().begin(); parent = em.merge(parent); em.getTransaction().commit(); } catch (Exception ex) { try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Exception e) { ex.printStackTrace(); throw e; } throw ex; } finally { em.close(); } return ""; } @Action(Action.ACTION_TYPE.FIND) public Parent findParentById(String id) { Parent parent = null; EntityManager em = getEntityManager(); try { parent = (Parent) em.find(Parent.class, id); } finally { em.close(); } return parent; } @Action(Action.ACTION_TYPE.NEW) public Parent getNewParent() { Parent parent = new Parent(); return parent; } @NamedQueryTarget( "getParent") public List<Parent> getParent() { EntityManager em = getEntityManager(); List<Parent> results = null; try { Query query = em.createNamedQuery( "getParent"); results = (List<Parent>) query.getResultList(); } finally { em.close(); } return results; } @NamedQueryTarget( "getParentById") public List<Parent> getParentById(String id) { EntityManager em = getEntityManager(); List<Parent> results = null; try { Query query = em.createNamedQuery( "getParentById"); query.setParameter( "id", id); results = (List<Parent>) query.getResultList(); } finally { em.close(); } return results; } @NamedQueryTarget( "getParentByName") public List<Parent> getParentByName(String name) { EntityManager em = getEntityManager(); List<Parent> results = null; try { Query query = em.createNamedQuery( "getParentByName"); query.setParameter( "name", name); results = (List<Parent>) query.getResultList(); } finally { em.close(); } return results; } } </pre>
    Error i receive :
    <pre class="jive-pre"> 176 Dene_JPA INFO [main] openjpa.Runtime - Starting OpenJPA 1.2.2-SNAPSHOT 644 Dene_JPA INFO [main] openjpa.jdbc.JDBC - Using dictionary class "com.ibm.ws.persistence.jdbc.sql.DB2Dictionary". 3923 Dene_JPA WARN [main] openjpa.Enhance - This configuration disallows runtime optimization, but the following listed types were not enhanced at build time or at class load time with a javaagent: "[class entities.Parent, class entities.Child]". success1 success2 success3 success4 success5 Exception in thread "main" <openjpa-1.2.2-SNAPSHOT-r422266:821449 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT p FROM Parent p". Error message: The name "Parent" is not a recognized entity or identifier. Known entity names: [] at org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:118) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:180) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:150) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69) at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756) at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56) at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153) at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658) at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639) at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605) at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667) at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:574) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:105) at com.ibm.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:37) at entities.controller.ParentManager.getParent(ParentManager.java:144) at source.Main.main(Main.java:29) </pre>

    as i mentioned above too, when i didnt use ParentManager , and used Entitymanager to obtain entities it has worked last time, but now, i just wanted to work with ParentManager and Childmanager classes, but despite it allows them to be created, it says those entities are not knows, how can i make them to be known, where is my mistake, and how should i fix it?

    thank you all.
    First, show me the Parent entity code. Second, show me the code that works in main without the Manager Beans.
  • SystemAdmin
    SystemAdmin
    14225 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-19T13:57:36Z  
    First, show me the Parent entity code. Second, show me the code that works in main without the Manager Beans.
    It seems there is something strange with your DB2 setup. I just ran a similar test. Here is what I did.

    1) Create a new JPA project
    2) Generate entity Department.
    3) Configure it with named queries, set the primary key to deptno
    4) Generate manager bean that does not use injection
    5) Add OpenJPA 1.2.2 libraries from apache.org as a User Library on the project.
    6) Add DB2 drivers as a User Library on the project.
    7) Configured the project for deployement. Used the option to set the properties directly
    8) Create a basic main method and ran it as a java application.

    Here is my persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
    <persistence-unit name="jpa">
    <class>entities.Department</class>
    <properties>
    <property name="openjpa.jdbc.Schema" value="SAMPLE"/>
    <property name="openjpa.ConnectionDriverName" value="com.ibm.db2.jcc.DB2Driver"/>
    <property name="openjpa.ConnectionURL" value="jdbc:db2://db2server:20000/SAMPLE:retrieveMessagesFromServerOnGetMessage=true;"/>
    <property name="openjpa.ConnectionUserName" value="username"/>
    <property name="openjpa.ConnectionPassword" value="password"/>
    </properties>
    </persistence-unit>
    </persistence>
    Here is my main method:
    /**
    * @param args
    */
    public static void main(String[] args) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
    DepartmentManager deptMgr = new DepartmentManager(emf);
    List<Department> departments = deptMgr.getDepartment();
    for (Department department : departments) {
    System.out.println(department.getDeptno());
    }
    Department departmentB01 = deptMgr.findDepartmentByDeptno("B01");
    System.out.println(departmentB01.getDeptname());
    emf.close();
    }

    This code ran fine without problems. Perhaps you should try doing this with Derby to make sure its not a DB2 setup issue.
  • ishakteyran
    ishakteyran
    24 Posts

    Re: JPA application noclassdeffound error

    ‏2010-03-19T16:04:53Z  
    It seems there is something strange with your DB2 setup. I just ran a similar test. Here is what I did.

    1) Create a new JPA project
    2) Generate entity Department.
    3) Configure it with named queries, set the primary key to deptno
    4) Generate manager bean that does not use injection
    5) Add OpenJPA 1.2.2 libraries from apache.org as a User Library on the project.
    6) Add DB2 drivers as a User Library on the project.
    7) Configured the project for deployement. Used the option to set the properties directly
    8) Create a basic main method and ran it as a java application.

    Here is my persistence.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/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_1_0.xsd">
    <persistence-unit name="jpa">
    <class>entities.Department</class>
    <properties>
    <property name="openjpa.jdbc.Schema" value="SAMPLE"/>
    <property name="openjpa.ConnectionDriverName" value="com.ibm.db2.jcc.DB2Driver"/>
    <property name="openjpa.ConnectionURL" value="jdbc:db2://db2server:20000/SAMPLE:retrieveMessagesFromServerOnGetMessage=true;"/>
    <property name="openjpa.ConnectionUserName" value="username"/>
    <property name="openjpa.ConnectionPassword" value="password"/>
    </properties>
    </persistence-unit>
    </persistence>
    Here is my main method:
    /**
    * @param args
    */
    public static void main(String[] args) {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
    DepartmentManager deptMgr = new DepartmentManager(emf);
    List<Department> departments = deptMgr.getDepartment();
    for (Department department : departments) {
    System.out.println(department.getDeptno());
    }
    Department departmentB01 = deptMgr.findDepartmentByDeptno("B01");
    System.out.println(departmentB01.getDeptname());
    emf.close();
    }

    This code ran fine without problems. Perhaps you should try doing this with Derby to make sure its not a DB2 setup issue.
    hi, i have resolved the problem, the problem is in my persistence xml, while writing the properties i have not noticed that i made mistake by writing "RuntimeUnhancedClasses" instead of writing "openjpa.RuntimeUnenhancedClasses" , to see this , took my almost 12 hours, i almost read all posts about runtimeunenhancedclasses mail lists,forum posts and when i corrected it to openjpa.Runtime....... , it worked , just the devil was in a very hard to see detail.
    now, i need to enable and use this enhancement tool.