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