Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

WAR files in JBOSS

 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello, I have a fairly serious problem. I have a web application deployed as a WAR file, service.war. Now inside this WAR file, specifically the WEB-INF folder, I have a portable HSQL database. Previously I didn't know how JBOSS works, I didn't know that it extracts the WAR file to the tmp folder. What this meant was that each time I restart JBOSS all the data in my HSQL database and my XML files appear to be wiped out or reset. My question basically is, is there a way of specifying that certain files in my WAR file are not to be deleted or that each time the WAR file is redeployed or reloaded, those files will remain in the state they were in the tmp directory. Thanks.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Would it make sense to "externalize" the HSQL data file instead of keeping it located inside WEB-INF (or wherever you put it inside the .war)?

For example, instead of reading the database from "/WEB-INF/hsql.db", reading it from "/tmp/myapp/hsql.db".
 
norman richards
Author
Ranch Hand
Posts: 367
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Lasse is right, you should externalize this. Writing data into the WAR file/directory is a bad idea. JBoss provides the data directory (server/default/data, for example) for you to place application data that you want to survive a server reset. In fact, that's exactly where JBoss puts the hypersonic database that it provides to you.

And that begs the question, why not simply use the HSQL JBoss provides? Or better yet, why not simply use a standard datasource and not overcomplicate your application with database-specific code? One of the things that makes application servers so appealing is that you can externalize services your application requires and make your life much simpler.
 
igwe kalu kalu ogba
Ranch Hand
Posts: 133
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi, thanks for your replies. However I am really new to JBOSS and probably can't act on everything you have suggested. My question now is, from a JSP page, how can I get to the JBOSS data folder? In my JSP page, to get to Card.xml in WEB-INF/templates I use

String cardPath = getServletContext().getRealPath("WEB-INF/templates/Card.xml");

How can I do the same to get Card.xml in the server/default/data directory. Thanks.
 
Dave Salter
Ranch Hand
Posts: 293
Java Mac OS X Netbeans IDE
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
You can get the data directory by doing something like:

 
Adrian Precub
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello,

Can you please tell me how can i acces a picture stored in jboss server/default/data directory in my jsp?

Thank you.
 
Jaikiran Pai
Marshal
Pie
Posts: 10444
227
IntelliJ IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Adrian Precub wrote:Hello,

Can you please tell me how can i acces a picture stored in jboss server/default/data directory in my jsp?

Thank you.

Let's continue the discussion on your question here http://www.coderanch.com/t/488645/JBoss/externalize-resources-from-webapp
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic