-->
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.  [ 6 posts ] 
Author Message
 Post subject: no persistent classes found for query class
PostPosted: Thu Sep 15, 2005 1:26 pm 
Newbie

Joined: Thu Sep 15, 2005 12:36 pm
Posts: 4
This is my first time working with hibernate, I am following a couple of tutorials and I am just trying to get one object working.

Everything seems to start up and deploy ok in JBoss, but when I run a servlet to test I get: "[QuerySplitter] no persistent classes found for query class: ..."

I have looked around in the forums and searched around using google, but haven't been able to find a solution to this problem.

Any pointers or help anyone could provide me in solving this problem would be greatly appreciated.

My application is packaged like so:
Code:
hibtest.ear
     +hibtest.har
        +hibtest.jar
             -com/test/hibernate/Channel.class
             -com/test/hibernate/Channel.hbm.xml
        -meta-inf/hibernate-service.xml
     +hibtest.war
        -web-inf/classes/com/test/HelloWorld.class
        -web-inf/web.xml
     -meta-inf/application.xml
     -meta-inf/jboss-app.xml


Hibernate version: Hibernate 3.0.2 /w JBoss 4.0.2

Mapping documents:

Channel.hmb.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

        <class name="com.test.hibernate.Channel" table="zf_channel">
                <id name="id" column="id" type="long">
                        <generator class="increment"/>
                </id>
                <property name="adult" column="adult"/>
                <property name="forumid" column="forumid"/>
                <property name="hide" column="hide"/>
                <property name="id" column="id"/>
                <property name="name" column="name"/>
                <property name="orderid" column="orderid"/>
                <property name="pagename" column="pagename"/>
                <property name="parentid" column="parentid"/>
        </class>

</hibernate-mapping>


hibernate-service.xml
Code:
<server>
    <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=Hibernate">
        <attribute name="DatasourceName">java:/test</attribute>
        <attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
        <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
        <attribute name="CacheProviderClass">
            org.hibernate.cache.HashtableCacheProvider
        </attribute>
    </mbean>
</server>


Code between sessionFactory.openSession() and session.close():
HelloWorld Servlet
Code:
        SessionFactory factory = (SessionFactory)
         ctx.lookup("java:/hibernate/SessionFactory");
         Session hsession = factory.openSession();
         
         try {
            
            out.println("Hello World");
            
            Query query = hsession.createQuery("from com.test.hibernate.Channel order by name");
            List list = query.list();
            
            Iterator it = list.iterator();
            
            if(it.hasNext()) {
               out.println("The following channels:");
            }
            
            while(it.hasNext()) {
               Channel thisChannel = (Channel)it.next();
               out.println(thisChannel.getName());
            }
            
         } finally {
            hsession.close();
         }


Name and version of the database you are using: mySQL 4.0.22

Debug level Hibernate log excerpt:

JBoss deploy log for hibtest.ear
Code:
10:48:48,156 INFO  [EARDeployer] Init J2EE application: file:/C:/jboss/server/default/deploy/hibtest.ear
10:48:48,453 INFO  [Environment] Hibernate 3.0.2
10:48:48,453 INFO  [Environment] hibernate.properties not found
10:48:48,453 INFO  [Environment] using CGLIB reflection optimizer
10:48:48,468 INFO  [Environment] using JDK 1.4 java.sql.Timestamp handling
10:48:48,609 INFO  [Hibernate] Using JDBC batch size : null
10:48:48,609 INFO  [Configuration] Searching for mapping documents in jar: hibte
st.har
10:48:48,625 INFO  [Configuration] processing extends queue
10:48:48,625 INFO  [Configuration] processing collection mappings
10:48:48,625 INFO  [Configuration] processing association property references
10:48:48,625 INFO  [Configuration] processing foreign key constraints
10:48:48,640 INFO  [NamingHelper] JNDI InitialContext properties:{}
10:48:48,656 INFO  [DatasourceConnectionProvider] Using datasource: java:/test
10:48:49,937 INFO  [SettingsFactory] RDBMS: MySQL, version: 4.0.22-nt
10:48:49,937 INFO  [SettingsFactory] JDBC driver: MySQL-AB JDBC Driver, version:
mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2
$ )
10:48:50,000 INFO  [Dialect] Using dialect: org.hibernate.dialect.MySQLDialect
10:48:50,093 INFO  [SettingsFactory] JDBC batch size: 15
10:48:50,093 INFO  [SettingsFactory] JDBC batch updates for versioned data: disa
bled
10:48:50,109 INFO  [SettingsFactory] Scrollable result sets: enabled
10:48:50,109 INFO  [SettingsFactory] JDBC3 getGeneratedKeys(): enabled
10:48:50,109 INFO  [SettingsFactory] Aggressive release : enabled
10:48:50,109 INFO  [SettingsFactory] Maximum outer join fetch depth: 2
10:48:50,125 INFO  [SettingsFactory] Default batch fetch size: 1
10:48:50,125 INFO  [SettingsFactory] Generate SQL with comments: disabled
10:48:50,125 INFO  [SettingsFactory] Order SQL updates by primary key: disabled
10:48:50,125 INFO  [SettingsFactory] Query translator: org.hibernate.hql.ast.AST
QueryTranslatorFactory
10:48:50,140 INFO  [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
10:48:50,140 INFO  [SettingsFactory] Query language substitutions: {}
10:48:50,156 INFO  [TransactionFactoryFactory] Transaction strategy: org.hiberna
te.transaction.JTATransactionFactory
10:48:50,156 INFO  [NamingHelper] JNDI InitialContext properties:{}
10:48:50,156 INFO  [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
10:48:50,171 INFO  [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
10:48:50,171 INFO  [TransactionManagerLookupFactory] instantiating TransactionMa
nagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
10:48:50,171 INFO  [TransactionManagerLookupFactory] instantiated TransactionMan
agerLookup
10:48:50,187 INFO  [SettingsFactory] Automatic flush during beforeCompletion():
enabled
10:48:50,187 INFO  [SettingsFactory] Automatic session close at end of transacti
on: enabled
10:48:50,203 INFO  [SettingsFactory] Second-level cache: enabled
10:48:50,203 INFO  [SettingsFactory] Query cache: disabled
10:48:50,203 INFO  [SettingsFactory] Cache provider: org.hibernate.cache.Hashtab
leCacheProvider
10:48:50,218 INFO  [SettingsFactory] Optimize cache for minimal puts: disabled
10:48:50,218 INFO  [SettingsFactory] Structured second-level cache entries: enab
led
10:48:50,234 INFO  [SettingsFactory] Statistics: disabled
10:48:50,234 INFO  [SettingsFactory] Deleted entity synthetic identifier rollbac
k: disabled
10:48:50,250 INFO  [SettingsFactory] Default entity-mode: pojo
10:48:50,468 INFO  [SessionFactoryImpl] building session factory
10:48:50,468 INFO  [SessionFactoryObjectFactory] Not binding factory to JNDI, no
JNDI name configured
10:48:50,484 INFO  [NamingHelper] JNDI InitialContext properties:{}
10:48:50,484 INFO  [SessionFactoryImpl] Checking 0 named queries
10:48:50,484 INFO  [Hibernate] SessionFactory successfully built and bound into
JNDI [java:/hibernate/SessionFactory]
10:48:50,515 INFO  [TomcatDeployer] deploy, ctxPath=/hibtest, warUrl=file:/C:/jb
oss/server/default/tmp/deploy/tmp46343hibtest.ear-contents/hibtest-exp.war/
10:48:50,703 INFO  [EARDeployer] Started J2EE application: file:/C:/jboss/server
/default/deploy/hibtest.ear
10:48:50,906 INFO  [Http11Protocol] Starting Coyote HTTP/1.1 on http-0.0.0.0-808
0
10:48:51,078 INFO  [ChannelSocket] JK: ajp13 listening on /0.0.0.0:8009
10:48:51,093 INFO  [JkMain] Jk running ID=0 time=0/31  config=null
10:48:51,109 INFO  [Server] JBoss (MX MicroKernel) [4.0.2 (build: CVSTag=JBoss_4
_0_2 date=200505022023)] Started in 27s:891ms


Log entries when running the servlet:
Code:
10:51:27,265 INFO  [Log4jService$URLWatchTimerTask] Configuring from URL: resour
ce:log4j.xml
10:52:28,250 WARN  [QuerySplitter] no persistent classes found for query class:
from com.test.hibernate.Channel order by name


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 1:36 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Maybe you forgot to refer to your channel.hbm.xml from your Hibernate.cfg.xml.


<mapping resource="you/file/location/Channel.hbm.xml"/>

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 1:50 pm 
Newbie

Joined: Thu Sep 15, 2005 12:36 pm
Posts: 4
I was following this example:

http://docs.jboss.org/jbossas/jboss4gui ... /ch13.html

Quote:
Notice that the hibernate-service.xml file does not contain a list of the classes Hibernate is to map the way a hibernate.cfg.xml would nor do you need to manually add the Hibernate mapping files to the configuration the way you would when using a hibernate.properties file. Instead the Hibernate deployer in JBoss scans the archive for .hbm.xml mapping files at deployment time and adds them to the configuration for you.


Top
 Profile  
 
 Post subject: problem found
PostPosted: Thu Sep 15, 2005 2:29 pm 
Newbie

Joined: Thu Sep 15, 2005 12:36 pm
Posts: 4
I have found the problem...

The problem was my packaging:

I had packaged my .har int he following way

Code:
     +hibtest.har
        +hibtest.jar
             -com/test/hibernate/Channel.class
             -com/test/hibernate/Channel.hbm.xml
        -meta-inf/hibernate-service.xml


I had read that there was a problem with exploded paths in JBoss 4.0.2 so I packaged up the classes in my .har in a .jar file. Once I got rid of the .jar and used exploded file structure everything works:

Code:
     +hibtest.har
         -com/test/hibernate/Channel.class
         -com/test/hibernate/Channel.hbm.xml
       -meta-inf/hibernate-service.xml


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 2:33 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Oh, Ok. I was not aware of JBoss' HAR files.

The error message your are getting: no persistent classes found for query class is typical of this problem: You issue a query on an entity for which Hibernate was not provided a mapping file.

If I look at the structure of the HAR file:
Image

It looks to me like you should try putting the classes directly in the HAR and not in a JAR. Have you tried it?[/img]

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 11:48 pm 
Newbie

Joined: Thu Sep 15, 2005 12:36 pm
Posts: 4
Yup, problem solved...

It was the packaging of the .har file, I needed to use the classes directly in the .har rathet than using a .jar file.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.