Dependencias de Firebird, Jaybird e Hibernate

I was interested to see the performance of Firebird with Hibernate, but I can not manage to make it run correctly. I added to my pom.xml:

<dependency>
    <groupId>net.sf.squirrel-sql.thirdparty-non-maven</groupId>
    <artifactId>jaybird</artifactId>
    <version>2.1.6</version>
</dependency>

When running it I keep getting:

java.lang.ClassNotFoundException: javax.resource.ResourceException

I tried adding all kinds of javax, javaee and others dependencies (via Maven), but I can't manage to run it. With PostgreSQL I have no issues and everything works as it is supposed to.

Running on Apache Tomcat 7.0.26.

preguntado el 10 de marzo de 12 a las 13:03

Is there a reason you are not using the standard pom entry for Jaybird? -

2 Respuestas

The 'problem' is that Jaybird internally depends on the JavaEE concept of a resource-adapter and therefor requires some classes from JavaEE (specifically one that includes the javax.resource package (and subpackages). You need to include a JavaEE jar, or use

<groupId>org.firebirdsql.jdbc</groupId>
<artifactId>jaybird-jdk18</artifactId>
<version>3.0.5</version>

This one should automatically download the required dependency.

If all else fails, download the distribution from http://www.firebirdsql.org/en/jdbc-driver/ and use the connector-api-1.5.jar from the lib folder.

BTW: I hope to eliminate this dependency in Jaybird 5.

Descargo de responsabilidad: soy uno de los desarrolladores de Jaybird

Respondido 06 Feb 19, 08:02

@Vojtěch Did you try using the dependency in my answer, did it work? - Marcos Rotteveel

No, it did not make any difference, I had to add the jar manually. - Vojtech

@Vojtěch That is weird, I created tracker.firebirdsql.org/browse/JDBC-244 to investigate that further. - Marcos Rotteveel

@Vojtěch Actually, I think I found the cause: tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html Last, any JAR file that contains Servlet API classes will be explicitly ignored by the classloader The geronimo dependency that is used for maven instead of that mini-j2ee.jar also contains javax.servlet and is therefor entirely ignored. - Marcos Rotteveel

@Vojtěch Just as a follow up: using the jaybird 2.1.6 in my post and excluding the geronimo dependency and including groupID: javax.resource, artifactId: connector-api, version: 1.5 as dependency also works - Marcos Rotteveel

We'll i was able to figure this out:

  1. you can use hibernate's own connection pool
  2. you can use commons-dbcp connection pool
  3. you can use new tomcat7's jdbc connection pool.

Assuming you want to use 3, there are few steps you must perform, if you use firebird

  1. Download jdk from : http://sourceforge.net/projects/firebird/files/firebird-jca-jdbc-driver/2.2.0-release-jdk16/Jaybird-2.2.0JDK_1.6.zip/download

  2. Extract archive, copy jaybird*.jar and connector-api*.jar to /usr/share/tomcat7/lib. Inside the connector-api jar, there is the missing class ResourceException.

WARNING: do not copy huge j2eeapi.jar instead, beacuse they contain offending classes to servlet-api.jar from tomcat

  1. If you installed tomcat7 from tar, that's all. If you use ubuntu apt to install tomcat's package, then download original tar from tomcat's download side, extract it and copy tomcat-jdbc to wherever is you tomcat's lib folder (for ubuntu, that is /usr/share/tomcat7/lib)

That's all. Put the configuration into context.xml and that's all

<Resource
    name="jdbc/SOME_NAME"
    auth="Container"
    type="javax.sql.DataSource"
    factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
    testWhileIdle="true"
    testOnBorrow="true"
    testOnReturn="false"
    validationQuery="SELECT 'NOW' from RDB$DATABASE"
    validationInterval="30000"
    timeBetweenEvictionRunsMillis="30000"
    maxActive="100"
    minIdle="10"
    maxWait="10000"
    initialSize="10"
    removeAbandonedTimeout="60"
    removeAbandoned="true"
    logAbandoned="true"
    minEvictableIdleTimeMillis="30000"
    jmxEnabled="true"
    jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer"
    username="sysdba"
    password="masterke"
    driverClassName="org.firebirdsql.jdbc.FBDriver"
    url="jdbc:firebirdsql:IP:ALIAS?lc_ctype=UTF-8"
/>

Respondido el 06 de Septiembre de 12 a las 12:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.