Announcement Announcement Module
Collapse
No announcement yet.
[Help] spring persistence.xml jndi datasource tomcat 7 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Help] spring persistence.xml jndi datasource tomcat 7



    persistence.xml
    Code:
    <persistence 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"
    	version="1.0">
    	<persistence-unit name="integrated" transaction-type="RESOURCE_LOCAL">
    		<jta-data-source>java:comp/env/jdbc/integrated</jta-data-source>
    		<provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<!-- <class>org.zkoss.bind.examples.spring.order.domain.Order</class> -->
    		<properties>
    			<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />
    			<property name="hibernate.show_sql" value="true" />
    			<!-- <property name="hibernate.connection.url" value="jdbc:sqlserver://10.1.3.86\FMIS2:1433;databaseName=fmis-integrated" 
    				/> <property name="hibernate.connection.driver_class" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" 
    				/> <property name="hibernate.connection.username" value="erp" /> <property 
    				name="hibernate.connection.password" value="erp" /> -->
    		</properties>
    	</persistence-unit>
    </persistence>
    Tomcat

    context.xml
    Code:
    <Resource name="java:comp/env/jdbc/integrated" auth="Container"
                  type="javax.sql.DataSource" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
                  url="jdbc:sqlserver://localhost:1433;databaseName=fmis-integrated"
                  username="sa" password="sa" maxActive="20" maxIdle="10"
                  maxWait="-1"/>
    web.xml
    Code:
    <resource-ref>
    		<description>Integrated Datasource</description>
    		<res-ref-name>java:comp/env/jdbc/integrated</res-ref-name>
    		<res-type>javax.sql.DataSource</res-type>
    		<res-auth>Container</res-auth>
    	</resource-ref>
    applicationContext.xml
    Code:
    <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"
    	xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-3.1.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
    
    	<context:annotation-config />
    	<context:component-scan base-package="com.evnit.fmis" />
    
    	<tx:annotation-driven transaction-manager="transactionManager" />
    
    	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"
    		autowire="constructor">
    		<property name="entityManagerFactory" ref="emf" />
    	</bean>
    	<bean id="emf"
    		class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
    		<property name="persistenceUnitName" value="integrated" />
    	</bean>
    
    	<!-- <bean id="transactionManagerTK" class="org.springframework.orm.jpa.JpaTransactionManager" 
    		autowire="constructor"> <property name="entityManagerFactory" ref="emfTK" 
    		/> </bean> <bean id="emfTK" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"> 
    		<property name="persistenceUnitName" value="ktA02SXKD" /> </bean> -->
    </beans>
    Code:
    2012-12-08 10:14:43,104 ERROR  [localhost-startStop-1] PersistenceXmlLoader M[error] --> Error parsing XML: XML InputStream(8) cvc-complex-type.2.4.a: Invalid content was found starting with element 'provider'. One of '{"http://java.sun.com/xml/ns/persistence":non-jta-data-source, "http://java.sun.com/xml/ns/persistence":mapping-file, "http://java.sun.com/xml/ns/persistence":jar-file, "http://java.sun.com/xml/ns/persistence":class, "http://java.sun.com/xml/ns/persistence":exclude-unlisted-classes, "http://java.sun.com/xml/ns/persistence":properties}' is expected.
    
    2012-12-08 10:14:43,124 ERROR  [localhost-startStop-1] ContextLoader M[initWebApplicationContext] --> Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [applicationContext-db.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: invalid persistence.xml
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emf' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: invalid persistence.xml
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
Working...
X