Results 1 to 3 of 3

Thread: Works in J2se, but Exception The user must supply a JDBC Connection in Tomcat+Spring

  1. #1
    Join Date
    May 2011
    Posts
    1

    Default Works in J2se, but Exception The user must supply a JDBC Connection in Tomcat+Spring

    I am using JPA + Hibernate in J2SE my code works.
    I can get the EntityManager and execute queries.

    My persistence unit is defined as follows:
    Code:
    	<persistence-unit name="BRMSPersistenceUnit">
    	   <provider>org.hibernate.ejb.HibernatePersistence</provider>
    		<class>gov.frb.brms.EntityType</class>
    		<properties>
    			<property name="javax.persistence.jdbc.driver"    value="org.apache.derby.jdbc.ClientDriver"/>
    			<property name="javax.persistence.jdbc.url"       value="jdbc:derby://localhost:1527/FRB_DB"/>
    			<property name="javax.persistence.jdbc.password"  value=""/>
    			<property name="javax.persistence.jdbc.user"      value=""/>
    		</properties> 
    	</persistence-unit>
    When i try to use the same in a web app deployed inside Tomcat 7, I get the exception "Exception The user must supply a JDBC Connection".

    It appears that the persistence.xml file is found by the hibernate code in the web app because i can get the EntityManager.

    Note that the webapp uses Spring and some of the parameters are into the persistence.xml and also in a file jdbc.properties.

    Would anyone know a fix for that issue?

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,791

    Default

    Hi

    Code:
    When i try to use the same in a web app deployed inside Tomcat 7, 
    I get the exception "Exception The user must supply a JDBC Connection".
    Post the complete error stack trace to have a better idea
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Dec 2010
    Posts
    175

    Default

    Have you defined entityManagerFactory and transactionManager?

    Example: Take note of jndiName in Tomcat I've to use java:comp/env for specifying jdbc url.
    Code:
    	<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:comp/env/jdbc/FRB_DB"/>
    	</bean>
    	
    	<bean class="org.springframework.orm.jpa.JpaTransactionManager" id="transactionManager">
    		<property name="entityManagerFactory" ref="entityManagerFactory"/>
    		<property name="jpaDialect">
    			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect"/>
    		</property>
    	</bean>
    	
    	<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    		<property name="dataSource" ref="dataSource"/>
    	</bean>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •