• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JBoss virtual directory in jboss 5.0.1

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to server static html files from a directory outside jboss, such as /opt/myfiles and have this be the path for a context in jboss such as http://localhost:8080/myfiles/someform.html. I really need to do this. I've heard it has been removed from jboss 5.

One potential workaround was to just put my files in ROOT.war folder, which works (until you stop jboss that is )...

Has anyone been able to accomplish the virtual dir configuration in jboss 5? If not, how about a decent work around?

Thanks in advance (TIA)

- Tia
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tia, welcome to Java Ranch!

The correct way to do a virtual directory for static content in JBoss AS 5.0.x is to create an exploded war directory somewhere, such as at /opt/jbossstuff/myfiles.war, place your static content (someform.html from your example) into that directory, and then add an entry to the server/xxx/conf/bootstrap/profile-repository.xml file to add the /otp/jbossstuff directory to the deploy-scanned URLs:



which works (until you stop jboss that is



I'm not sure what you are implying here. No matter what virtual directory mechanism you use, whether the one mentioned above for JBoss AS 5.0.x, or the mechanism that was available in 3.2.x, 4.0,x and 4.2.x, whenever you stop JBoss AS you will not longer have access to the static content.
 
Tia Haenni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter, thanks for your reply! What I meant about adding the files to ROOT.war and the jboss restart is that my files seemed to be removed when jboss shut down. This isn't my preferred method anyway, but I'm under the gun to get this working so I tried it.

I tried the configuration you suggested, but I got startup errors. Here are the specifics:

I created /opt/scripts/static.war and added to /home/jboss/jboss/server/default/conf/bootstrap/profile-repository.xml like this:



And here are the errors on startup.

08:51:03,640 DEBUG [ServerImpl] Failed to start
java.lang.IllegalStateException: Incompletely deployed:
DEPLOYMENTS IN ERROR:
Deployment "ProfileService" is in error due to: org.jboss.profileservice.spi.NoSuchProfileException: Failed to obtain deployment repository for: org.jboss.profileservice.spi.ProfileKey@143b82c3[domain=default,server=default,name=default]
DEPLOYMENTS MISSING DEPENDENCIES:

Deployment "ProfileServiceBootstrap" is missing the following dependencies:
Dependency "ProfileService" (should be in state "Installed", but is actually in state "**ERROR**")
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.internalValidate(AbstractKernelDeployer.java:278)
at org.jboss.kernel.plugins.deployment.AbstractKernelDeployer.validate(AbstractKernelDeployer.java:174)
at org.jboss.bootstrap.microcontainer.ServerImpl.doStart(ServerImpl.java:148)
at org.jboss.bootstrap.AbstractServerImpl.start(AbstractServerImpl.java:394)
at org.jboss.Main.boot(Main.java:209)
at org.jboss.Main$1.run(Main.java:547)
at java.lang.Thread.run(Thread.java:619)
08:51:03,641 INFO [ServerImpl] Runtime shutdown hook called, forceHalt: true
08:51:03,645 INFO [ServerImpl] Shutdown complete

This does not happen if I remove the entry <value>/opt/scripts</value> from profile-repository.xml

Any idea what is wrong?

TIA

- Tia


 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding a /opt/scripts/static.war/WEB-INF/web.xml file with empty contents:

 
Tia Haenni
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Getting closer...

Added WEB-INF/web.xml, jboss complains about the URI

Caused by: java.lang.IllegalArgumentException: URI is not absolute
at java.io.File.<init>(File.java:361)
at org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository.setApplicationURIs(SerializableDeploymentRepository.java:146)
at org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository.<init>(SerializableDeploymentRepository.java:126)
at org.jboss.system.server.profileservice.repository.SerializableDeploymentRepositoryFactory.getDeploymentRepository(SerializableDeploymentRepositoryFactory.java:148)
at org.jboss.system.server.profileservice.repository.FileProfileRepository.getProfileDeploymentRepository(FileProfileRepository.java:134)
at org.jboss.system.server.profileservice.repository.ProfileServiceImpl.getProfile(ProfileServiceImpl.java:158)
... 36 more

So then I checked URI class and changed it to the file:///format:

from <value>/opt/scripts</value> to <value>file:///opt/scripts</value>;

Then jboss complains that there's no deploy dir:

Caused by: java.io.FileNotFoundException: Profile contains no deploy dir: \\opt\scripts
at org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository.load(SerializableDeploymentRepository.java:803)
at org.jboss.system.server.profileservice.repository.FileProfileRepository.getProfileDeploymentRepository(FileProfileRepository.java:135)
at org.jboss.system.server.profileservice.repository.ProfileServiceImpl.getProfile(ProfileServiceImpl.java:158)
... 36 more

I checked with org.jboss.system.server.profileservice.repository.SerializableDeploymentRepository.load() and noticed it expects to find the server/<profile>/deploy so I created the following path: /opt/scripts/server/default/deploy/static.war. This didn't fix things, I started questioning the path I created. I know in Ant for instance, regardless of *nix vs windows, a path like /opt/scripts will be correctly resolved. However, I noticed some entries in server.log like vfszip:/C:/development/jboss-5.0.0.GA....etc and thought perhaps JBoss was not resolving / as /C:/. So after changing my value to explicity list the full windows path, I finally have a remote deploy dir that works.

In summary...

(1)

modify server/<profile>/conf/bootstrap/profile-repository.xml to add your path as a file URI URI API:



(2)
create your path such as:

/opt/scripts/server/default/deploy/static.war/ (add static files here)

(3)
in /opt/scripts/server/default/deploy/static.war/ create dir WEB-INF with empty web.xml as Peter described

(4)
Start jboss. I can now access my files by going to http://localhost:8080/static/test.html etc.

I tested that the above deploy dir is dynamically scanned by creating new static html files after jboss starts and accessing in the browser.

Thanks Peter!!

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very helpful article. Thanks. Naturally, they've changed things again in JBoss 5.1. The config file "profile-repository.xml" is now named just "profile.xml" and the bean to configure is now "BootstrapProfileFactory" rather than "SerializableDeploymentRepositoryFactory". Other than that, the solution works as advertised.

I'm starting to get suspicious of the RedHat team. It almost seems like they're making random naming and functionality changes just to keep their commercial support offering out of balance with the community editions . But then, would that make me a conspiracy theorist?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Ford wrote:Very helpful article. Thanks. Naturally, they've changed things again in JBoss 5.1. The config file "profile-repository.xml" is now named just "profile.xml" and the bean to configure is now "BootstrapProfileFactory" rather than "SerializableDeploymentRepositoryFactory".


Yes, that changed between versions

Eric Ford wrote:
I'm starting to get suspicious of the RedHat team. It almost seems like they're making random naming and functionality changes just to keep their commercial support offering out of balance with the community editions . But then, would that make me a conspiracy theorist?



Personally, I too dislike that the names of config files (which user are allowed to edit) keep changing. But this has nothing to do with community version versus commercial support. Infact, I don't think this is even a valid point:

Eric Ford wrote:
It almost seems like they're making random naming and functionality changes just to keep their commercial support offering out of balance with the community editions


The community edition is meant to be fast moving target to incorporate new technologies and changes. On the other hand the enterprise (commercial) version is meant to be stable and is not meant to have major changes very frequently.
 
Eric Ford
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I touched a nerve - that comment was a joke, a poke in the ribs. There's no "wink-wink" Emoticon - maybe that would have made it more obvious. If I offended you, I apologize but, seriously, lighten up, dude!

Jaikiran Pai wrote:
Personally, I too dislike that the names of config files (which user are allowed to edit) keep changing. But this has nothing to do with community version versus commercial support. Infact, I don't think this is even a valid point:



Jaikiran Pai wrote:
The community edition is meant to be fast moving target to incorporate new technologies and changes. On the other hand the enterprise (commercial) version is meant to be stable and is not meant to have major changes very frequently.

 
Jaikiran Pai
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Eric Ford wrote:I think I touched a nerve - that comment was a joke, a poke in the ribs. There's no "wink-wink" Emoticon - maybe that would have made it more obvious. If I offended you, I apologize but, seriously, lighten up, dude!



I wasn't offended, but I did think that you were serious

Eric Ford wrote:
There's no "wink-wink" Emoticon


Yeah, I wish there was one
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, i got the same problem and you guys save my day.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Didier, welcome to Java Ranch!

And glad that we could help you solve your problem. But please don't do large block quotes, it is not necessary.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a very helpful thread -- thank you especially Tia for posting your full solution.

By the way, in case this helps anyone: a cross-platform version of the file URL (will work on Windows but assumes C: drive) turns out to be...

file:/opt/scripts
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bart, welcome to Java Ranch!

(will work on Windows but assumes C: drive)


The "assumes" part is not correct. Rather, Windows will assume the current working drive. For example, if you have JBoss AS installed on the D: drive and you start it from it's bin directory, the D: drive is assumed. I have used this little fact for years - on my laptop I had JBoss AS on my C: drive, on my desktop at work on the F: drive and on my desktop at home on the D: drive. I always used the drive-less absolute paths in config files and build scripts - works great.
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic