views:

126

answers:

0

I have a project that compiles and runs completely fine under OS/X, but under Linux an exception is thrown that gives no clue as to what might be the problem. I've been stuck on this for hours trying to narrow it down, any pointers would be helpful!

java.lang.ExceptionInInitializerError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:169)
Caused by: javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:375)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at au.edu.unimelb.security.model.EMF.getTestInstance(EMF.java:44)
    at au.edu.unimelb.grssc.TestHelper.reset(Unknown Source)
    at au.edu.unimelb.grssc.model.MasterResultsScoreTest.<clinit>(Unknown Source)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -5
    at java.lang.String.substring(String.java:1937)
    at org.hibernate.ejb.packaging.JarVisitorFactory.getJarURLFromURLEntry(JarVisitorFactory.java:55)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:341)

The environment that I am having trouble under is

  • OS: Ubuntu 10.4 and/or Ubuntu 8.4
  • Java: Ubuntu sun java package and/or latest java 1.6 downloaded from Oracle
  • Hibernate: version 3.5.4

The relevant part of the persistence.xml file is as follows:

<persistence-unit name="testing">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>package.grssc.model.Application</class>
    <class>package.grssc.model.ExternalPerson</class>
    <class>package.grssc.model.Organisation</class>
    <class>package.grssc.model.Qualification</class>
    <class>package.grssc.model.Recommendation</class>
    <class>package.grssc.model.FyGrade</class>
    <class>package.grssc.model.IsisRewardCode</class>

    <class>package.security.model.Person</class>
    <class>package.security.model.Permission</class>
    <class>package.security.model.Throttle</class>
    <class>package.security.model.Role</class>
    <class>package.security.model.SimpleReport</class>
    <class>package.security.model.Template</class>
    <class>package.security.model.TemplateItem</class>
    <class>package.security.model.Setting</class>

    <exclude-unlisted-classes>true</exclude-unlisted-classes>
    <properties>
        <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:unit-testing-jpa" />
        <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver" />
        <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="create-drop" />
        <property name="hibernate.connection.username" value="sa" />
        <property name="hibernate.connection.password" value="" />
    </properties>
</persistence-unit>

I have been doing some digging into the source code, and it doesn't help. It appears there is some unsafe code in hibernate:

/**
 * Get the JAR URL of the JAR containing the given entry
 * Method used in a non managed environment
 *
 * @param url URL pointing to the known file in the JAR
 * @param entry file known to be in the JAR
 * @return the JAR URL
 * @throws IllegalArgumentException if none URL is found
 */
public static URL getJarURLFromURLEntry(URL url, String entry) throws IllegalArgumentException {
    URL jarUrl;
    String file = url.getFile();
    if ( ! entry.startsWith( "/" ) ) entry = "/" + entry;
    file = file.substring( 0, file.length() - entry.length() );

If the url parameter is a shorter string than the entry parameter, then an exception occurs. Not sure I have done it right, but here is the output when i set the log level to debug:

 INFO [main] (Environment.java:570) - Hibernate 3.5.4-Final
 INFO [main] (Environment.java:603) - hibernate.properties not found
 INFO [main] (Environment.java:781) - Bytecode provider name : javassist
 INFO [main] (Environment.java:662) - using JDK 1.4 java.sql.Timestamp handling
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [uuid] -> [class org.hibernate.id.UUIDHexGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [hilo] -> [class org.hibernate.id.TableHiLoGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [assigned] -> [class org.hibernate.id.Assigned]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [identity] -> [class org.hibernate.id.IdentityGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [select] -> [class org.hibernate.id.SelectGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [sequence] -> [class org.hibernate.id.SequenceGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [seqhilo] -> [class org.hibernate.id.SequenceHiLoGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [increment] -> [class org.hibernate.id.IncrementGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [foreign] -> [class org.hibernate.id.ForeignGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [guid] -> [class org.hibernate.id.GUIDGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [uuid.hex] -> [class org.hibernate.id.UUIDHexGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [sequence-identity] -> [class org.hibernate.id.SequenceIdentityGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [enhanced-sequence] -> [class org.hibernate.id.enhanced.SequenceStyleGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [enhanced-table] -> [class org.hibernate.id.enhanced.TableGenerator]
 INFO [main] (Version.java:37) - Hibernate Commons Annotations 3.2.0.Final
 INFO [main] (Version.java:42) - Hibernate EntityManager 3.5.4-Final
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [uuid] -> [class org.hibernate.id.UUIDHexGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [hilo] -> [class org.hibernate.id.TableHiLoGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [assigned] -> [class org.hibernate.id.Assigned]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [identity] -> [class org.hibernate.id.IdentityGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [select] -> [class org.hibernate.id.SelectGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [sequence] -> [class org.hibernate.id.SequenceGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [seqhilo] -> [class org.hibernate.id.SequenceHiLoGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [increment] -> [class org.hibernate.id.IncrementGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [foreign] -> [class org.hibernate.id.ForeignGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [guid] -> [class org.hibernate.id.GUIDGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [uuid.hex] -> [class org.hibernate.id.UUIDHexGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [sequence-identity] -> [class org.hibernate.id.SequenceIdentityGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [enhanced-sequence] -> [class org.hibernate.id.enhanced.SequenceStyleGenerator]
DEBUG [main] (DefaultIdentifierGeneratorFactory.java:99) - Registering IdentifierGenerator strategy [enhanced-table] -> [class org.hibernate.id.enhanced.TableGenerator]
DEBUG [main] (Ejb3Configuration.java:301) - Look up for persistence unit: testing
TRACE [main] (Ejb3Configuration.java:320) - PersistenceMetadata(version=1.0) [
    name: standard
    jtaDataSource: null
    nonJtaDataSource: null
    transactionType: RESOURCE_LOCAL
    provider: org.hibernate.ejb.HibernatePersistence
    useQuotedIdentifiers: false
    classes[
        package.grssc.model.Application     package.grssc.model.ExternalPerson      package.grssc.model.Organisation        package.grssc.model
.Qualification      package.grssc.model.Recommendation      package.grssc.model.MastersGrade        package.grssc.model.GraduatingClassPositionScore        package.grssc.model.MasterResultsScore      package.grssc.model.PenultimateAndFinalYearScore        package.grssc.model.IsisRewardCode      package.grs
sc.model.PyGrade        package.grssc.model.FyGrade             package.security.model.Person       package.security.model.Permission       package.security.model.Throttle     package.security.model.Role     package.security.model.Privilege        package.security.model.Group        package.security.model.LogEntry     package.security.model.LogEntryData     package.security.model.SimpleReport     package.security.model.Template     package.security.model.TemplateItem     package.security.model.Setting  ]
    packages[
    ]
    mappingFiles[
    ]
    jarFiles[
    ]
    hbmfiles: 0
    properties[
        java.runtime.name: Java(TM) SE Runtime Environment
        hibernate.connection.password: password
        sun.boot.library.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64
        java.vm.version: 16.3-b01
        hibernate.connection.username: username
        java.vm.vendor: Sun Microsystems Inc.
        java.vendor.url: http://java.sun.com/
        path.separator: :
        java.vm.name: Java HotSpot(TM) 64-Bit Server VM
        file.encoding.pkg: sun.io
        sun.java.launcher: SUN_STANDARD
        user.country: US
        sun.os.patch.level: unknown
        java.vm.specification.name: Java Virtual Machine Specification
        user.dir: /tmp/GRSSC
        java.runtime.version: 1.6.0_20-b02
        java.awt.graphicsenv: sun.awt.X11GraphicsEnvironment
        java.endorsed.dirs: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/endorsed
        os.arch: amd64
        java.io.tmpdir: /tmp
        line.separator: 

        java.vm.specification.vendor: Sun Microsystems Inc.
        os.name: Linux
        hibernate.c3p0.idle_test_period: 500
        sun.jnu.encoding: ANSI_X3.4-1968
        hibernate.c3p0.timeout: 300
        java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64:/usr/jav
a/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
        java.class.version: 50.0
        java.specification.name: Java Platform API Specification
        sun.management.compiler: HotSpot 64-Bit Server Compiler
        os.version: 2.6.32-22-server
        user.home: /home/jacob
        user.timezone: 
        java.awt.printerjob: sun.print.PSPrinterJob
        java.specification.version: 1.6
        file.encoding: ANSI_X3.4-1968
        hibernate.format_sql: false
        hibernate.c3p0.min_size: 5
        hibernate.connection.driver_class: com.mysql.jdbc.Driver
        user.name: jacob
        java.class.path: /tmp/GRSSC/ant.build:/tmp/GRSSC/lib/ApplicationTemplate-1.0.jar:/tmp/GRSSC/lib/UMServices.jar:/tmp/GRSSC/lib/Validator.jar:/tmp/GRSSC/lib/Authentication-1.1.jar:/tmp/GRSSC/lib/UptecsEmail.jar:/tmp/GRSSC/lib/catalina-ant.jar:/tmp/GRSSC/lib/hibernate/antlr-2.7.6.jar:/tmp/GRSSC/lib/hibernate/c3p0-0.9.1.jar:/tmp/GRSSC/lib/hibernate/commons-co
llections-3.1.jar:/tmp/GRSSC/lib/hibernate/dom4j-1.6.1.jar:/tmp/GRSSC/lib/hibernate/hibernate-jpa-2.0-api-1.0.0.Final.jar:/tmp/GRSSC/lib/hibernate/hibernate3.jar:/tmp/GRSSC/lib/hibernate/javassi
st-3.9.0.GA.jar:/tmp/GRSSC/lib/hibernate/jta-1.1.jar:/tmp/GRSSC/lib/hibernate/slf4j-api-1.6.1.jar:/tmp/GRSSC/lib/hibernate/slf4j-log4j12-1.6.1.jar:/tmp/GRSSC/lib/hsqldb.jar:/tmp/GRSSC/lib/iText-
2.1.7.jar:/tmp/GRSSC/lib/jsp-api.jar:/tmp/GRSSC/lib/junit-3.8.2.jar:/tmp/GRSSC/lib/log4j-1.2.16.jar:/tmp/GRSSC/lib/mysql-connector-java-5.1.6-bin.jar:/tmp/GRSSC/lib/ojdbc5.jar:/tmp/GRSSC/lib/ser
vlet-api.jar:/tmp/GRSSC/lib/soap/axis-ant.jar:/tmp/GRSSC/lib/soap/axis.jar:/tmp/GRSSC/lib/soap/commons-discovery-0.2.jar:/tmp/GRSSC/lib/soap/commons-logging-1.0.4.jar:/tmp/GRSSC/lib/soap/jaxrpc.
jar:/tmp/GRSSC/lib/soap/saaj.jar:/tmp/GRSSC/lib/soap/wsdl4j-1.5.1.jar:/tmp/GRSSC/lib/soap/xercesImpl.jar:/usr/share/java/ant-launcher-1.7.1.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-
junit.jar
        hibernate.show_sql: false
        java.vm.specification.version: 1.0
        sun.arch.data.model: 64
        java.home: /usr/lib/jvm/java-6-sun-1.6.0.20/jre
        hibernate.connection.url: jdbc:oracle:thin:blah
        hibernate.dialect: org.hibernate.dialect.OracleDialect
        java.specification.vendor: Sun Microsystems Inc.
        user.language: en
        hibernate.c3p0.max_size: 20
        java.vm.info: mixed mode
        java.version: 1.6.0_20
        java.ext.dirs: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext:/usr/java/packages/lib/ext
        sun.boot.class.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/sunrsasign.ja
r:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/cl
asses
        java.vendor: Sun Microsystems Inc.
        file.separator: /
        java.vendor.url.bug: http://java.sun.com/cgi-bin/bugreport.cgi
        hibernate.hbm2ddl.auto: update
        sun.cpu.endian: little
        sun.io.unicode.encoding: UnicodeLittle
        sun.cpu.isalist: 
    ]]
TRACE [main] (Ejb3Configuration.java:320) - PersistenceMetadata(version=1.0) [
    name: testing
    jtaDataSource: null
    nonJtaDataSource: null
    transactionType: RESOURCE_LOCAL
    provider: org.hibernate.ejb.HibernatePersistence
    useQuotedIdentifiers: false
    classes[
        package.grssc.model.Application     package.grssc.model.ExternalPerson      package.grssc.model.Organisation        package.grssc.model
.Qualification      package.grssc.model.Recommendation      package.grssc.model.MastersGrade        package.grssc.model.GraduatingClassPositionScore        package.grssc.model.MasterResultsScore      package.grssc.model.PenultimateAndFinalYearScore        package.grssc.model.IsisRewardCode      package.grs
sc.model.PyGrade        package.grssc.model.FyGrade     package.grssc.model.IsisRewardCode      package.security.model.Person       package.security.model.Permission       package.security.model.Throttle     package.security.model.Role     package.security.model.Privilege        package.security.model.Group        package.security.model.LogEntry     package.security.model.LogEntryData     package.security.model.SimpleReport     -package.security.model.Template        package.security.model.TemplateItem     package.security.model.Setting  ]
    packages[
    ]
    mappingFiles[
    ]
    jarFiles[
    ]
    hbmfiles: 0
    properties[
        java.runtime.name: Java(TM) SE Runtime Environment
        hibernate.connection.password: 
        sun.boot.library.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64
        java.vm.version: 16.3-b01
        hibernate.connection.username: sa
        java.vm.vendor: Sun Microsystems Inc.
        java.vendor.url: http://java.sun.com/
        path.separator: :
        java.vm.name: Java HotSpot(TM) 64-Bit Server VM
        file.encoding.pkg: sun.io
        user.country: US
        sun.java.launcher: SUN_STANDARD
        sun.os.patch.level: unknown
        java.vm.specification.name: Java Virtual Machine Specification
        user.dir: /tmp/GRSSC
        java.runtime.version: 1.6.0_20-b02
        java.awt.graphicsenv: sun.awt.X11GraphicsEnvironment
        java.endorsed.dirs: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/endorsed
        os.arch: amd64
        java.io.tmpdir: /tmp
        line.separator: 

        java.vm.specification.vendor: Sun Microsystems Inc.
        os.name: Linux
        sun.jnu.encoding: ANSI_X3.4-1968
        java.library.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64/server:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/amd64:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/../lib/amd64:/usr/jav
a/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
        java.specification.name: Java Platform API Specification
        java.class.version: 50.0
        sun.management.compiler: HotSpot 64-Bit Server Compiler
        os.version: 2.6.32-22-server
        user.home: /home/jacob
        user.timezone: 
        java.awt.printerjob: sun.print.PSPrinterJob
        java.specification.version: 1.6
        file.encoding: ANSI_X3.4-1968
        hibernate.connection.driver_class: org.hsqldb.jdbcDriver
        user.name: jacob
        java.class.path: /tmp/GRSSC/ant.build:/tmp/GRSSC/lib/ApplicationTemplate-1.0.jar:/tmp/GRSSC/lib/UMServices.jar:/tmp/GRSSC/lib/Validator.jar:/tmp/GRSSC/lib/authentiAuthenti
cation-1.1.jar:/tmp/GRSSC/lib/UptecsEmail.jar:/tmp/GRSSC/lib/catalina-ant.jar:/tmp/GRSSC/lib/hibernate/antlr-2.7.6.jar:/tmp/GRSSC/lib/hibernate/c3p0-0.9.1.jar:/tmp/GRSSC/lib/hibernate/commons-co
llections-3.1.jar:/tmp/GRSSC/lib/hibernate/dom4j-1.6.1.jar:/tmp/GRSSC/lib/hibernate/hibernate-jpa-2.0-api-1.0.0.Final.jar:/tmp/GRSSC/lib/hibernate/hibernate3.jar:/tmp/GRSSC/lib/hibernate/javassi
st-3.9.0.GA.jar:/tmp/GRSSC/lib/hibernate/jta-1.1.jar:/tmp/GRSSC/lib/hibernate/slf4j-api-1.6.1.jar:/tmp/GRSSC/lib/hibernate/slf4j-log4j12-1.6.1.jar:/tmp/GRSSC/lib/hsqldb.jar:/tmp/GRSSC/lib/iText-
2.1.7.jar:/tmp/GRSSC/lib/jsp-api.jar:/tmp/GRSSC/lib/junit-3.8.2.jar:/tmp/GRSSC/lib/log4j-1.2.16.jar:/tmp/GRSSC/lib/mysql-connector-java-5.1.6-bin.jar:/tmp/GRSSC/lib/ojdbc5.jar:/tmp/GRSSC/lib/ser
vlet-api.jar:/tmp/GRSSC/lib/soap/axis-ant.jar:/tmp/GRSSC/lib/soap/axis.jar:/tmp/GRSSC/lib/soap/commons-discovery-0.2.jar:/tmp/GRSSC/lib/soap/commons-logging-1.0.4.jar:/tmp/GRSSC/lib/soap/jaxrpc.
jar:/tmp/GRSSC/lib/soap/saaj.jar:/tmp/GRSSC/lib/soap/wsdl4j-1.5.1.jar:/tmp/GRSSC/lib/soap/xercesImpl.jar:/usr/share/java/ant-launcher-1.7.1.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-
junit.jar
        java.vm.specification.version: 1.0
        sun.arch.data.model: 64
        java.home: /usr/lib/jvm/java-6-sun-1.6.0.20/jre
        hibernate.connection.url: jdbc:hsqldb:mem:unit-testing-jpa
        hibernate.dialect: org.hibernate.dialect.HSQLDialect
        java.specification.vendor: Sun Microsystems Inc.
        user.language: en
        java.vm.info: mixed mode
        java.version: 1.6.0_20
        java.ext.dirs: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/ext:/usr/java/packages/lib/ext
        sun.boot.class.path: /usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/sunrsasign.ja
r:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.20/jre/cl
asses
        java.vendor: Sun Microsystems Inc.
        file.separator: /
        java.vendor.url.bug: http://java.sun.com/cgi-bin/bugreport.cgi
        hibernate.hbm2ddl.auto: create-drop
        sun.cpu.endian: little
        sun.io.unicode.encoding: UnicodeLittle
        sun.cpu.isalist: 
    ]]