Hello friends,
I am trying to create a web application using Spring 3.0.3, JPA 1.0, Hibernate 3, zkoss 5 and JBOSS 5.1 server with jdk support.
Following is list of jar files in my /WEB-INF/lib directory
Code:commons-dbcp-all-1.3.jar commons-io.jar org.springframework.*-3.0.3.RELEASE.jar zcommon.jar zcommons-el.jar zhtml.jar zk.jar zkplus.jar zul.jar zweb.jar
Following is my /WEB-INF/web.xml file
Code:<?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> <!-- Spring --> <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> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:dataSourceContext.xml,classpath:spring-context.xml</param-value> </context-param> <!-- Spring --> <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>
Following is my /src/spring-context.xml file
Code:<?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:context="http://www.springframework.org/schema/context" 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/context http://www.springframework.org/schema/context/spring-context.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 "> <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /> <!-- import the dataSource definition --> <import resource="dataSourceContex.xml"/> <!-- Activates a load-time weaver for the context. Any bean within the context that implements LoadTimeWeaverAware (such as LocalContainerEntityManagerFactoryBean) will receive a reference to the autodetected load-time weaver. --> <context:load-time-weaver/> <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/> <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"/> <!-- JPA primary EntityManagerFactory --> <bean id="entityManagerFactory" lazy-init="true" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:persistenceUnitName="ExamplePU" p:jpaVendorAdapter-ref="jpaVendorAdapter" p:jpaDialect-ref="jpaDialect" p:dataSource-ref="dataSource"/> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager" p:entity-manager-factory-ref="entityManagerFactory" /> <!-- JPA config --> <tx:annotation-driven /> <!-- 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>
Following is my /src/dataSourceContext.xml file
Code:<?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="org.hsqldb.jdbcDriver" p:url="jdbc:hsqldb:mem:zktodo" p:username="sa" p:password=""/> </beans>
Following is my /src/META-INF/persistence.xml file
Code:<?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="ExamplePU" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/> <property name="hibernate.showsql" value="true"/> <property name="hibernate.cache.use_second_level_cache" value="false"/> </properties> </persistence-unit> </persistence>
JOBSS server gives me following error
Can any one help me in solving the problem.Code:13:27:02,250 INFO [PersistenceUnitDeployment] Starting persistence unit persistence.unit:unitName=#ExamplePU 13:27:02,265 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=#ExamplePU state=Create java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a non-jta-data-source for a RESOURCE_LOCAL enabled persistence context named: ExamplePU at org.jboss.jpa.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:124) at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:275) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Thanks.


Reply With Quote
