我该如何解决这个问题“没有为查询类找到持久类”信息? [英] How do I fix this "no persistent classes found for query class" message?
问题描述
我使用zkoss 5.0.4,Spring 3.0.3,Hibernate 3和JpA 1.0与JBOSS 5.1 GA(支持JDK)创建Web应用程序。
I am creating a web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3, and JpA 1.0 with JBOSS 5.1 GA (with JDK support).
该项目与JBOSS编译良好。但是看起来persitence并没有被应用。
The project compiles fine with JBOSS. But it seems that persitence is not applying for some reason.
当我在控制台中运行应用程序时,它会显示以下内容:
When I run an application in the console, it displays the following:
10:07:35,265 WARN [QuerySplitter] no persistent classes found for query class: from org.zkforge.zktodo2.Reminder
以下是我在 / WEB-INF / lib
中使用的jar文件列表,目录。
Following is list of jar files that I am using in the /WEB-INF/lib
directory.
aopalliance.jar
asm-1.5.3.jar
asm-attrs-1.5.3.jar
cglib-2.1_3.jar
commons-dbcp-1.2.2.jar
commons-fileupload-1.2.1.jar
commons-io.jar
commons-pool-1.3.jar
ehcache-1.2.3.jar
fckez.jar
groovy.jar
jruby.jar
js.jar
junit-3.8.1.jar
jython.jar
org.springframework.aop-3.0.3.RELEASE.jar
org.springframework.asm-3.0.3.RELEASE.jar
org.springframework.aspects-3.0.3.RELEASE.jar
org.springframework.beans-3.0.3.RELEASE.jar
org.springframework.context.support-3.0.3.RELEASE.jar
org.springframework.context-3.0.3.RELEASE.jar
org.springframework.core-3.0.3.RELEASE.jar
org.springframework.expression-3.0.3.RELEASE.jar
org.springframework.instrument.tomcat-3.0.3.RELEASE.jar
org.springframework.instrument-3.0.3.RELEASE.jar
org.springframework.jdbc-3.0.3.RELEASE.jar
org.springframework.jms-3.0.3.RELEASE.jar
org.springframework.orm-3.0.3.RELEASE.jar
org.springframework.oxm-3.0.3.RELEASE.jar
org.springframework.test-3.0.3.RELEASE.jar
org.springframework.transaction-3.0.3.RELEASE.jar
org.springframework.web.portlet-3.0.3.RELEASE.jar
org.springframework.web.servlet-3.0.3.RELEASE.jar
org.springframework.web.struts-3.0.3.RELEASE.jar
org.springframework.web-3.0.3.RELEASE.jar
zcommon.jar
zcommons-el.jar
zhtml.jar
zk.jar
zkplus.jar
zul.jar
zweb.jar
以下是我的 web.xml
文件:
Following is my web.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
< web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
< display-name >
zk5
< / display-name >
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:dataSourceContext.xml,classpath:spring-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<!-- The Spring RequestContextLister uses thread bound variables so to
use this Spring freatures requires that we apply <disable-event-thread />
within zk.xml -->
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
< description>
Used to cleanup when a session is destroyed< / description>
< display-name>
ZK Session cleaner< / display-name>
<listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class>
</listener>
<servlet>
<description>
The ZK loader for ZUML pages</description>
<servlet-name>zkLoader</servlet-name>
<servlet-class>
org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class>
<init-param>
<param-name>update-uri</param-name>
<param-value>/zkau</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<description>
The asynchronous update engine for ZK</description>
<servlet-name>auEngine</servlet-name>
<servlet-class>
org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zul</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>zkLoader</servlet-name>
<url-pattern>*.zhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>auEngine</servlet-name>
<url-pattern>/zkau/*</url-pattern>
</servlet-mapping>
< welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
<welcome-file>index.zul</welcome-file>
< / welcome-file-list>
</web-app>
以下是我的 spring-context.xml
file:
Following is my spring-context.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
">
<!--
JPA config
-->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
p:persistenceUnitName="ExamplePU"
p:persistenceXmlLocation="classpath:/META-INF/persistence.xml"
p:dataSource-ref="dataSource"
>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"
p:showSql="true"
p:generateDdl="true">
</bean>
</property>
<property name="jpaProperties">
<value>
hibernate.ejb.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
hibernate.dialect=${hibernate.dialect}
hibernate.hbm2ddl.auto=${hibernate.hbm2ddl.auto}
</value>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager"
p:entityManagerFactory-ref="entityManagerFactory"
/>
<tx:annotation-driven />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<!--
JPA helpers
-->
<bean id="basicDao" class="org.zkforge.zktodo2.BasicDao" />
<!--
First article classes
-->
<bean id="reminderService" class="org.zkforge.zktodo2.ReminderService"
p:basicDao-ref="basicDao"
/>
<bean id="toDoControllerV1" class="org.zkforge.zktodo2.ZkToDoControllerV1"
p:reminderService-ref="reminderService" scope="prototype"
/>
<!--
Data binding enhancement classes
-->
<!--
Note that the following bean is session scoped.
-->
<bean id="toDoModel" class="org.zkforge.zktodo2.ZkToDoModelImpl"
p:reminderService-ref="reminderService" scope="session">
<!--
// scoped proxy is commented out as only referenced by a prototype bean
// if you wanted to pass this bean to a singleton you need to include
// the following configurration.
<aop:scoped-proxy proxy-target-class="false"/>
-->
</bean>
<bean id="toDoControllerV2" class="org.zkforge.zktodo2.ZkToDoControllerV2"
p:toDoModel-ref="toDoModel" scope="prototype"
/>
</beans>
以下是我的 dataSourceContext.xml
文件:
Following is my dataSourceContext.xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:driverClassName="${jdbc.driver}"
p:url="${jdbc.url}"
p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<!--
Injected properties
-->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:zktodo2.properties</value>
</list>
</property>
</bean>
</beans>
以下是我的zktodo2.properties文件
Following is my zktodo2.properties file
jdbc.url=jdbc:hsqldb:mem:salvation
jdbc.username=sa
jdbc.password=
jdbc.driver=org.hsqldb.jdbcDriver
hibernate.dialect=org.hibernate.dialect.HSQLDialect
hibernate.hbm2ddl.auto=update
以下是我从JBOSS服务器编译的东西:
Following is my compiling stuff from JBOSS server:
10:06:41,000 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=#ExamplePU
10:06:41,156 INFO [Version] Hibernate Annotations 3.4.0.GA
10:06:41,156 INFO [Environment] Hibernate 3.3.1.GA
10:06:41,171 INFO [Environment] hibernate.properties not found
10:06:41,171 INFO [Environment] Bytecode provider name : javassist
10:06:41,171 INFO [Environment] using JDK 1.4 java.sql.Timestamp handling
10:06:41,343 INFO [Version] Hibernate Commons Annotations 3.1.0.GA
10:06:41,343 INFO [Version] Hibernate EntityManager 3.4.0.GA
10:06:41,375 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [
name: ExamplePU
...]
10:06:41,375 WARN [Ejb3Configuration] Persistence provider caller does not implement the EJB3 spec correctly. PersistenceUnitInfo.getNewTempClassLoader() is null.
10:06:41,515 INFO [AnnotationBinder] Binding entity from annotated class: org.zkforge.zktodo2.Reminder
10:06:41,546 INFO [EntityBinder] Bind entity org.zkforge.zktodo2.Reminder on table REMINDER
10:06:41,593 INFO [Version] Hibernate Validator 3.1.0.GA
10:06:41,625 INFO [HibernateSearchEventListenerRegister] Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
10:06:41,687 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
10:06:41,703 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
10:06:41,734 INFO [SettingsFactory] RDBMS: HSQL Database Engine, version: 1.8.0
10:06:41,734 INFO [SettingsFactory] JDBC driver: HSQL Database Engine Driver, version: 1.8.0
10:06:41,781 INFO [Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
10:06:41,796 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
10:06:41,796 INFO [TransactionManagerLookupFactory] instantiating TransactionManagerLookup: org.hibernate.transaction.JBossTransactionManagerLookup
10:06:41,796 INFO [TransactionManagerLookupFactory] instantiated TransactionManagerLookup
10:06:41,796 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
10:06:41,796 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
10:06:41,796 INFO [SettingsFactory] JDBC batch size: 15
10:06:41,796 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
10:06:41,796 INFO [SettingsFactory] Scrollable result sets: enabled
10:06:41,796 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
10:06:41,796 INFO [SettingsFactory] Connection release mode: auto
10:06:41,796 INFO [SettingsFactory] Default batch fetch size: 1
10:06:41,796 INFO [SettingsFactory] Generate SQL with comments: disabled
10:06:41,796 INFO [SettingsFactory] Order SQL updates by primary key: disabled
10:06:41,796 INFO [SettingsFactory] Order SQL inserts for batching: disabled
10:06:41,796 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
10:06:41,812 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
10:06:41,812 INFO [SettingsFactory] Query language substitutions: {}
10:06:41,812 INFO [SettingsFactory] JPA-QL strict compliance: enabled
10:06:41,812 INFO [SettingsFactory] Second-level cache: enabled
10:06:41,812 INFO [SettingsFactory] Query cache: disabled
10:06:41,812 INFO [SettingsFactory] Cache region factory : org.hibernate.cache.impl.bridge.RegionFactoryCacheProviderBridge
10:06:41,828 INFO [RegionFactoryCacheProviderBridge] Cache provider: org.hibernate.cache.HashtableCacheProvider
10:06:41,828 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
10:06:41,828 INFO [SettingsFactory] Cache region prefix: persistence.unit:unitName=#ExamplePU
10:06:41,828 INFO [SettingsFactory] Structured second-level cache entries: disabled
10:06:41,828 INFO [SettingsFactory] Statistics: disabled
10:06:41,828 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
10:06:41,828 INFO [SettingsFactory] Default entity-mode: pojo
10:06:41,828 INFO [SettingsFactory] Named query checking : enabled
10:06:41,875 INFO [SessionFactoryImpl] building session factory
10:06:42,046 INFO [SessionFactoryObjectFactory] Factory name: persistence.unit:unitName=#ExamplePU
10:06:42,046 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
10:06:42,046 INFO [SessionFactoryObjectFactory] Bound factory to JNDI name: persistence.unit:unitName=#ExamplePU
10:06:42,046 WARN [SessionFactoryObjectFactory] InitialContext did not implement EventContext
10:06:42,046 INFO [NamingHelper] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
10:06:42,046 WARN [SessionFactoryImpl] JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
10:06:42,062 INFO [TomcatDeployment] deploy, ctxPath=/zk5
10:06:42,171 INFO [[/zk5]] Initializing Spring root WebApplicationContext
10:06:42,171 INFO [ContextLoader] Root WebApplicationContext: initialization started
10:06:42,906 INFO [XmlWebApplicationContext] Refreshing Root WebApplicationContext: startup date [Sat Oct 02 10:06:42 IST 2010]; root of context hierarchy
10:06:42,953 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [dataSourceContext.xml]
10:06:43,046 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [spring-context.xml]
10:06:43,171 INFO [PropertyPlaceholderConfigurer] Loading properties file from class path resource [zktodo2.properties]
10:06:43,203 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10fe280: defining beans [dataSource,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,entityManagerFactory,transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0,basicDao,reminderService,toDoControllerV1,toDoModel,toDoControllerV2]; root of factory hierarchy
10:06:43,296 INFO [LocalContainerEntityManagerFactoryBean] Building JPA container EntityManagerFactory for persistence unit 'ExamplePU'
10:06:43,296 INFO [Ejb3Configuration] Processing PersistenceUnitInfo [
name: ExamplePU
...]
10:06:43,296 INFO [HibernateSearchEventListenerRegister] Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
10:06:43,296 INFO [ConnectionProviderFactory] Initializing connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
10:06:43,296 INFO [InjectedDataSourceConnectionProvider] Using provided datasource
10:06:43,312 INFO [SettingsFactory] RDBMS: HSQL Database Engine, version: 1.8.0
10:06:43,312 INFO [SettingsFactory] JDBC driver: HSQL Database Engine Driver, version: 1.8.0
10:06:43,312 INFO [Dialect] Using dialect: org.hibernate.dialect.HSQLDialect
10:06:43,312 INFO [TransactionFactoryFactory] Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
10:06:43,312 INFO [TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
10:06:43,312 INFO [SettingsFactory] Automatic flush during beforeCompletion(): disabled
10:06:43,312 INFO [SettingsFactory] Automatic session close at end of transaction: disabled
10:06:43,312 INFO [SettingsFactory] JDBC batch size: 15
10:06:43,312 INFO [SettingsFactory] JDBC batch updates for versioned data: disabled
10:06:43,312 INFO [SettingsFactory] Scrollable result sets: enabled
10:06:43,312 INFO [SettingsFactory] JDBC3 getGeneratedKeys(): disabled
10:06:43,312 INFO [SettingsFactory] Connection release mode: auto
10:06:43,312 INFO [SettingsFactory] Default batch fetch size: 1
10:06:43,312 INFO [SettingsFactory] Generate SQL with comments: disabled
10:06:43,312 INFO [SettingsFactory] Order SQL updates by primary key: disabled
10:06:43,312 INFO [SettingsFactory] Order SQL inserts for batching: disabled
10:06:43,312 INFO [SettingsFactory] Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
10:06:43,312 INFO [ASTQueryTranslatorFactory] Using ASTQueryTranslatorFactory
10:06:43,312 INFO [SettingsFactory] Query language substitutions: {}
10:06:43,312 INFO [SettingsFactory] JPA-QL strict compliance: enabled
10:06:43,312 INFO [SettingsFactory] Second-level cache: enabled
10:06:43,312 INFO [SettingsFactory] Query cache: disabled
10:06:43,312 INFO [SettingsFactory] Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
10:06:43,312 INFO [SettingsFactory] Optimize cache for minimal puts: disabled
10:06:43,312 INFO [SettingsFactory] Structured second-level cache entries: disabled
10:06:43,312 INFO [SettingsFactory] Echoing all SQL to stdout
10:06:43,312 INFO [SettingsFactory] Statistics: disabled
10:06:43,312 INFO [SettingsFactory] Deleted entity synthetic identifier rollback: disabled
10:06:43,312 INFO [SettingsFactory] Default entity-mode: pojo
10:06:43,312 INFO [SettingsFactory] Named query checking : enabled
10:06:43,312 INFO [SessionFactoryImpl] building session factory
10:06:43,312 INFO [SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
10:06:43,312 INFO [SchemaUpdate] Running hbm2ddl schema update
10:06:43,312 INFO [SchemaUpdate] fetching database metadata
10:06:43,328 INFO [SchemaUpdate] updating schema
10:06:43,328 INFO [SchemaUpdate] schema update complete
10:06:43,484 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 1313 ms
10:06:43,500 INFO [zkoss] Starting ZK 5.0.4 CE (build: 2010083112)
10:06:43,515 INFO [zkoss] Loading system default
10:06:43,625 INFO [zkoss] Parsing jndi:/localhost/zk5/WEB-INF/zk.xml
10:06:43,625 INFO [zkoss] The event processing thread is disabled
10:07:35,265 WARN [QuerySplitter] no persistent classes found for query class: from org.zkforge.zktodo2.Reminder
请让我知道您是否需要任何其他的东西。
Please let me know if you need anything else from my side.
推荐答案
我在持久性文件中添加了以下内容,并且它开始正常工作。
I added the following in my persistence file and it started fine.
< class >org.zkforge.zktodo2.Reminder< / class >
添加上面的行创建了数据库中的表,并且持久性错误消失了。
Adding the above line created the table in the database, and the persistence error is gone.
我不知道为什么我们需要添加它。有什么理由吗?不应该Spring或Hibernate应该从Reminder.java文件中获得这个东西?
I do not know why do we need to add it. Is there any reason? Shouldn't Spring or Hibernate should get that thing from Reminder.java file?
这篇关于我该如何解决这个问题“没有为查询类找到持久类”信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!