Win a copy of Rust Web Development this week in the Other Languages forum!
    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

WAR files in JBOSS

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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".
 
Author
Posts: 367
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 293
Mac OS X Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
You can get the data directory by doing something like:

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 https://coderanch.com/t/488645/JBoss/externalize-resources-from-webapp
 
    Bookmark Topic Watch Topic
  • New Topic