zootropo
zootropo

Reputation: 2491

JPA is connecting to a non existent HSQL database?

I'm using JPA with the EclipseLink implementation and I inject my entity manager factory using Spring. I'm testing my app with a TomEE server (Tomcat + Java EE) through Eclipse.

For some reason, when I read the log it seems like JPA is connecting to my Oracle database, but also to an HSQL database that I didn't configure anywhere.

[EL Config]: 2013-10-24 13:05:48.515--ServerSession(24468517)--Connection(222262)--Thread(Thread[localhost-startStop-1,5,main])--connecting(DatabaseLogin(
    platform=>OraclePlatform
    user name=> ""
    connector=>JNDIConnector datasource name=>null
))
[EL Config]: 2013-10-24 13:05:49.062--ServerSession(24468517)--Connection(30536968)--Thread(Thread[localhost-startStop-1,5,main])--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
    User: SA
    Database: HSQL Database Engine  Version: 2.2.8
    Driver: HSQL Database Engine Driver  Version: 2.2.8
[EL Finest]: 2013-10-24 13:05:49.062--ServerSession(24468517)--Connection(19789489)--Thread(Thread[localhost-startStop-1,5,main])--Connection acquired from connection pool [read].
[EL Finest]: 2013-10-24 13:05:49.062--ServerSession(24468517)--Connection(19789489)--Thread(Thread[localhost-startStop-1,5,main])--Connection released to connection pool [read].
[EL Config]: 2013-10-24 13:05:49.062--ServerSession(24468517)--Connection(10424924)--Thread(Thread[localhost-startStop-1,5,main])--connecting(DatabaseLogin(
    platform=>OraclePlatform
    user name=> ""
    connector=>JNDIConnector datasource name=>null
))
[EL Config]: 2013-10-24 13:05:49.062--ServerSession(24468517)--Connection(9702992)--Thread(Thread[localhost-startStop-1,5,main])--Connected: jdbc:hsqldb:file:data/hsqldb/hsqldb
    User: SA
    Database: HSQL Database Engine  Version: 2.2.8
    Driver: HSQL Database Engine Driver  Version: 2.2.8

I know that there must be something very wrong with my configuration, but I can't figure out what it is.

This is my persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">

        <persistence-unit name="pu" transaction-type="JTA">
            <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>


            <properties>
                <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform" />
                <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.driver.OracleDriver" />

                <property name="eclipselink.logging.level" value="FINEST" />
                <property name="eclipselink.logging.parameters" value="true" />
                <property name="eclipselink.logging.level.sql" value="FINEST" />
            </properties>
        </persistence-unit>
</persistence>

and this is my applicationContext.xml

<?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:security="http://www.springframework.org/schema/security"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd">

    <jee:jndi-lookup id="dataSource" jndi-name="myPool" />

    <bean id="emFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="loadTimeWeaver">
            <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
        <property name="transactionManagerName" value="java:comp/env/comp/TransactionManager"/>
    </bean>

    <context:component-scan base-package="com.example" />
    <jpa:repositories base-package="com.example.model.dao" />
</beans>

UPDATE: It seems to be TomEE's fault because when I delete hsqldb-2.2.8.jar from its lib directory I get this error in the log:

INFO: Configuring Service(id=myPool, type=Resource, provider-id=ProvidedByTomcat)
oct 24, 2013 2:23:05 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=myPool)
oct 24, 2013 2:23:05 PM org.apache.openejb.config.AutoConfig deploy
INFO: Configuring PersistenceUnit(name=pu, provider=org.eclipse.persistence.jpa.PersistenceProvider)
oct 24, 2013 2:23:05 PM org.apache.openejb.config.ConfigurationFactory configureService
INFO: Configuring Service(id=Default JDBC Database, type=Resource, provider-id=Default JDBC Database)
oct 24, 2013 2:23:05 PM org.apache.openejb.config.AutoConfig logAutoCreateResource
INFO: Auto-creating a Resource with id 'Default JDBC Database' of type 'DataSource for 'pu'.
oct 24, 2013 2:23:05 PM org.apache.openejb.assembler.classic.Assembler createRecipe
INFO: Creating Resource(id=Default JDBC Database)
oct 24, 2013 2:23:05 PM org.apache.tomee.catalina.TomcatWebAppBuilder startInternal
SEVERE: Unable to deploy collapsed ear in war StandardEngine[Catalina].StandardHost[localhost].StandardContext[/dauro]
org.apache.xbean.propertyeditor.PropertyEditorException: Unable to resolve class org.hsqldb.jdbcDriver

Upvotes: 1

Views: 900

Answers (1)

Antoniossss
Antoniossss

Reputation: 32517

I have found something like this . So that means that there are versions of eclipseLink with embedded HSQLDB, and you probably got it. Try to investigate and get eclipseLink without HSQLDB.

Upvotes: 2

Related Questions