Paul J DeCoursey wrote:
Stanley Bradbury wrote:
Stanczak Group wrote:
How does one get Derby embedded in a servlet under Tomcat. In my
development environment I'm using Netbeans and Tomcat. Tomcat
install is under root so I can't write to is, just my web modules
directories. I can connect to a path with Netbeans's database tool,
but when I launch the app on Tomcat I get errors that it can't
create files like createDD.jdbc and derby.log. I'm guessing this is
because Derby is showing it's home as the root of the Tomcat
server. The question is why and how can I fix this? I have an
absolute path set, but it still does it. Shouldn't it write
everything to that path and not just start writing to where ever it
decides home is?
Hi -
For embedded Derby to work properly it needs to be loaded high in the
classloader hierarchy of the server. As far as I know this cannot be
done by an application, the application layer has too many
restrictions and Derby is designed to be a shared resource. Sharing
Derby is done by integrating Derby with Tomcat as described in the
JPetStore write-up at:
http://db.apache.org/derby/integrate/DerbyTomcat5512JPetStor.html
I believe that Derby in client/server architecture might be your only
choice if you cannot get Derby embedded as a global resource at the
Server level.
I've made it a staticly accessible resource. I use my own database
management container, the DataSource container for tomcat has been too
heavy for my needs. I've also set it up in Spring successfully.
Paul
Hi Paul -
Sounds like you have a lot of experience in the area. Your architecture
seems beyond my experience but I did notice something I missed in my
first read that might be of help. You wrote:
"..I have an absolute path set, but it still does it. Shouldn't it write
everything to that path and not just start writing to where ever it
decides home is? .."
Derby writes the logfile to derby.system.home (this also serves as the
ROOT directory for any relative path references). If this is not
explicitly set prior to loading the Derby driver the value defaults to
the default directory for the JVM. Derby's view of the world is from
the JVM perspective, not the server or application that starts it. I
assume the 'absolute path' you set is an application or server property?
Anyway, a possible solution for you might be to set derby.system.home to
an appropriate location (the absolute path?) prior to loading the Derby
driver.
HTH