Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java Open Source > Apache Tomcat
|
Apache Tomcat General discussion of the Apache Tomcat servlet container. For discussions specific to the Professional Apache Tomcat book, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Apache Tomcat section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 15th, 2007, 02:40 PM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using HSQLDB database for container authentication

I am trying to use HSQLDB for container authentication in Tomcat. When I start Tomcat, I get this error message in the catalina.YYYY-MM-DD.log:

INFO: Starting Servlet Engine: Apache Tomcat/5.5.23
Aug 8, 2007 2:23:43 PM org.apache.catalina.realm.JDBCRealm start
SEVERE: Exception opening database connection
java.sql.SQLException: The database is already in use by another process: org.hsqldb.persist.NIOLockFile@18ca22fe[file =\\localhost\data\Auth.lck, exists=false, locked=false, valid=false, fl =null]: java.io.FileNotFoundException: \\localhost\data\Auth.lck (The network path was not found)
    at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
    at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
    at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
    at org.hsqldb.jdbcDriver.connect(Unknown Source)
    at org.apache.catalina.realm.JDBCRealm.open(JDBCRealm .java:701)
    at org.apache.catalina.realm.JDBCRealm.start(JDBCReal m.java:769)
    at org.apache.catalina.core.ContainerBase.start(Conta inerBase.java:1006)
    at org.apache.catalina.core.StandardEngine.start(Stan dardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(Sta ndardService.java:448)
    at org.apache.catalina.core.StandardServer.start(Stan dardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalin a.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.catalina.startup.Bootstrap.start(Bootst rap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstr ap.java:433)

I am using the following connectionURL:

connectionURL="jdbc:hsqldb://localhost/data/Auth"

where Auth is the name of my HSQLDB database with the following files:

I setup my realm in server.xml as follows:

            <Realm className="org.apache.catalina.realm.JDBCRealm"
                driverName="org.hsqldb.jdbcDriver"
                connectionURL="jdbc:hsqldb://localhost/data/Auth"
                connectionName="SA" connectionPassword=""
                userTable="USER" userNameCol="USERNAME" userCredCol="PASSWORD"
                userRoleTable="USER_ROLE" roleNameCol="ROLENAME" />


It seems that Tomcat cannot find my database files? Without success, I have located them in various places:

webbapps/MyApp/WEB-INF/data
webbapps/MyApp/WEB-INF/classes/data
webbapps/MyApp/WEB-INF/lib/data
webapps/data

Can someone tell me where to put the database files so Tomcat can find them? I am using Tomcat 6.


 
Old September 4th, 2007, 06:22 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you place them with in your application they wont be availble for the tomcat. Tomcat is trying to connect to the database by using the file you are talking about before it deploys your application so anytime they wont be available to tomcat. If you want those files to be used by tomcat while starting then try placing them in TOMCAT_HOME/shared/classes which is the directory which will be in class path and tomcat picks files from there.

- Rakesh
 
Old September 4th, 2007, 09:04 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the info. I did work out a solution which I posted in the Apache forums. I did not post it here since I got no responses here.

Here is what I posted:

In case anyone is interested, I found the secrets to getting Tomcat to use my HSQLDB database for container authentication:

* Locate hsqldb.jar in %CATALINA_HOME%/common/lib
* Locate the HSQLDB database files in %CATALINA_HOME%/data
* Use the following Realm element in server.xml:

      <Realm className="org.apache.catalina.realm.JDBCRealm"
             driverName="org.hsqldb.jdbcDriver"
          connectionURL="jdbc:hsqldb:data/Auth"
         connectionName="SA" connectionPassword=""
              userTable="USER" userNameCol="USERNAME" userCredCol="PASSWORD"
          userRoleTable="USER_ROLE" roleNameCol="ROLENAME" />

That is the same Realm element as I used above, except for the connectionURL:

* Correct: connectionURL="jdbc:hsqldb:data/Auth"
* Incorrect: connectionURL="jdbc:hsqldb:/localhoast/data/Auth"


You can actually locate the database within your application, at
    data/webapps/MyApp/data
if you use
    connectionURL="jdbc:hsqldb:webApps/MyApp/data/Auth"


 
Old September 4th, 2007, 09:06 AM
Registered User
 
Join Date: Aug 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, there was an error in my last 4 lines. They should have read:

You can actually locate the database within your application, at
    webapps/MyApp/data
if you use
    connectionURL="jdbc:hsqldb:webApps/MyApp/data/Auth"







Similar Threads
Thread Thread Starter Forum Replies Last Post
Hibernate Spring and HSQLDB Error chfarooq Hibernate 0 January 10th, 2008 11:18 AM
login authentication with database ashkitt BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 16th, 2005 02:23 PM
form-based authentication using a database waru BOOK: Beginning ASP.NET 1.0 2 May 28th, 2004 10:37 PM
database authentication vik_asp Classic ASP Databases 1 August 6th, 2003 07:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.