Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Unable to connect to read-only Embedded Derby database from within EAR file deployed on JBoss server

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access a read-only Embedded Derby database. It is available as myDB.jar. This jar has one folder of the Apache Derby database - myDB (log and seg0 folders and service.properties file). This code works fine when I run from a file with a main method. But, when I package it into EAR and deploy it on server it gives error.

This database is packaged with EAR file and deployed on JBoss 5.0.1 server.

The EAR has following contents:
• myWebApp.war
• myEjbs.jar
• myDB.jar
• META-INF/MANIFEST.MF and META-INF/application.xml

Contents of MANIFEST.MF:
Manifest-Version: 1.0
Class-Path: myDB.jar

myDB.jar is not registered in application.xml


EJB-JAR i.e. myEjbs.jar has the following contents:
• derby.properties
• META-INF/MANIFEST.MF and others such as persistence.xml, etc.
Contents of MANIFEST.MF:
Manifest-Version: 1.0
Class-Path: myDB.jar
• com.xxx.common.DbUtility.class that has the following code accessing the database:
private static String dbURL = "jdbc:derby:jar:(myDB.jar)";
private static String dbName = "myDB";
private static String user = "";
private static String password = "";

Connection con = DriverManager.getConnection(dbURL+ dbName, user, password);

The output of this class is then used by the EJBs in com.xxx.ejbs package.

Following is the error I get:
DEBUG [org.hibernate.engine.StatefulPersistenceContext] (http-127.0.0.1-8080-1) initializing non-lazy collections
INFO [STDOUT] (http-127.0.0.1-8080-1) Connecting to MyDB database ...
INFO [STDOUT] (http-127.0.0.1-8080-1) Loaded database driver: org.apache.derby.jdbc.EmbeddedDriver
INFO [STDOUT] (http-127.0.0.1-8080-1) SQLException: Failed to start database 'jar:(myDB.jar)myDB' with class loader BaseClassLoader@127627{vfsfile:/C:/jboss-5.0.1.GA/server/default/conf/jboss-service.xml}, see the next exception for details.
INFO [STDOUT] (http-127.0.0.1-8080-1) java.sql.SQLException: Failed to start database 'jar:(myDB.jar)myDB' with class loader BaseClassLoader@127627{vfsfile:/C:/jboss-5.0.1.GA/server/default/conf/jboss-service.xml}, see the next exception for details.
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.EmbedConnection.<init>(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.EmbedConnection30.<init>(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.EmbedConnection40.<init>(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
[STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at java.sql.DriverManager.getConnection(DriverManager.java:582)
INFO [STDOUT] (http-127.0.0.1-8080-1) at java.sql.DriverManager.getConnection(DriverManager.java:185)

INFO [STDOUT] (http-127.0.0.1-8080-1) Caused by: java.sql.SQLException: Failed to start database 'jar:(myDB.jar)myDB' with class loader BaseClassLoader@127627{vfsfile:/C:/jboss-5.0.1.GA/server/default/conf/jboss-service.xml}, see the next exception for details.
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)

INFO [STDOUT] (http-127.0.0.1-8080-1) Caused by: java.sql.SQLException: Java exception: 'myDB.jar (The system cannot find the file specified): java.io.FileNotFoundException'.
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)

INFO [STDOUT] (http-127.0.0.1-8080-1) Caused by: java.io.FileNotFoundException: myDB.jar (The system cannot find the file specified)
INFO [STDOUT] (http-127.0.0.1-8080-1) at java.util.zip.ZipFile.open(Native Method)
INFO [STDOUT] (http-127.0.0.1-8080-1) at java.util.zip.ZipFile.<init>(ZipFile.java:114)
NFO [STDOUT] (http-127.0.0.1-8080-1) at java.util.zip.ZipFile.<init>(ZipFile.java:131)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.io.JarStorageFactory.doInit(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.io.BaseStorageFactory.init(Unknown Source)
INFO [STDOUT] (http-127.0.0.1-8080-1) at org.apache.derby.impl.services.monitor.StorageFactoryService.privGetStorageFactoryInstance(Unknown Source)

INFO [STDOUT] (http-127.0.0.1-8080-1) Unable to connect to database: myDB
 
Surabhi Tandon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have now tried the following:

Following is the output when classes are being loaded by JBoss initially:

BaseClassLoader@a75818{vfszip:/C:/jboss-5.0.1.GA/server/default/deploy/Main.ear/} with policy VFSClassLoaderPolicy@88a588{name=vfszip:/C:/jboss-5.0.1.GA/server/default/deploy/Main.ear/ domain=null roots=[MemoryContextHandler@19639558[path= context=vfsmemory://ak42v-bfhwq-ger46v84-1-ger477uj-20 real=vfsmemory://ak42v-bfhwq-ger46v84-1-ger477uj-20], DelegatingHandler@7111491[path=Main.ear context=file:/C:/jboss-5.0.1.GA/server/default/deploy/ real=file:/C:/jboss-5.0.1.GA/server/default/deploy/Main.ear], DelegatingHandler@1948811[path=Main.ear/myEJBs.jar context=file:/C:/jboss-5.0.1.GA/server/default/deploy/ real=file:/C:/jboss-5.0.1.GA/server/default/deploy/Main.ear/myEJBs.jar], DelegatingHandler@4545587[path=Main.ear/ myDB.jar context=file:/C:/jboss-5.0.1.GA/server/default/deploy/ real=file:/C:/jboss-5.0.1.GA/server/default/deploy/Main.ear/ myDB.jar], com.xxx.common, com.xxx.ejb, myDB, myDB.seg0, META-INF, myDB.log, …

So it looks like the myDB.jar is in the classpath and the database folder myDB is also loaded.


So I tried the following:



I again get an error, but, now I do not get the FileNotFoundException:

INFO java.sql.SQLException: Database '/myDB' not found.
INFO Caused by: java.sql.SQLException: Database '/myDB' not found.

I am not able to find the reason for this error.

I also tried the following:


But, get the same SQLException.

Is it possible that JBoss is treating myDB as a java package and not a simple file folder?
 
Surabhi Tandon
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following worked:



 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic