aspose file tools*
The moose likes JBoss/WildFly and the fly likes JBoss virtual directory in jboss 5.0.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "JBoss virtual directory in jboss 5.0.1" Watch "JBoss virtual directory in jboss 5.0.1" New topic
Author

JBoss virtual directory in jboss 5.0.1

Tia Haenni
Greenhorn

Joined: Mar 17, 2009
Posts: 5
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
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

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.


JBoss In Action
Tia Haenni
Greenhorn

Joined: Mar 17, 2009
Posts: 5
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
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

Try adding a /opt/scripts/static.war/WEB-INF/web.xml file with empty contents:

Tia Haenni
Greenhorn

Joined: Mar 17, 2009
Posts: 5
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!!

Eric Ford
Greenhorn

Joined: Jun 04, 2010
Posts: 17
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?
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
168

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

Joined: Jun 04, 2010
Posts: 17
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
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
168

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
didier lobeau
Greenhorn

Joined: Oct 14, 2010
Posts: 1
Thanks a lot, i got the same problem and you guys save my day.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

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.
Bart Blacha
Greenhorn

Joined: Feb 04, 2011
Posts: 1
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
Bartender

Joined: May 14, 2008
Posts: 5843
    
    7

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.
 
Don't get me started about those stupid light bulbs.
 
subject: JBoss virtual directory in jboss 5.0.1