I know I'm not the only one to have this problem because I've seen at least half a dozen posts on this exact problem and it appears that the problem is that I was jaring the war improperly and other app servers (JRun and tomcat) were covering my error. Jboss will keep you honest. Here is how to properly archive a web app with the Sun jar tool:
imagine I am creating a web app called exampleapp. I start by creating a directory called exampleapp. Inside it I create a index.html file and possible other html files and JSPs. exampleapp must also contain at least a directory called WEB-INF (case sensitive) with a web.xml configuration file inside of it (this should be familiar to everyone and in case it's not there is tons of online tutorials and books that teach how to use web.xml). Optionally, the WEB-INF directory may also contain a directory called classes that contains servlets and classes used by them or by JSPs and a directory called lib where you can store your JAR files used by the classes in your classes directory. So on a unix system your file structure might look like this:
/home/projects/exampleapp <--top-most directory
/home/projects/exampleapp/WEB-INF/classes <-- servlets and helper classes
/home/projects/exampleapp/WEB-INF/lib <-- jars
Once you have prepared your files this way, you package them into a war file by navigating into the exampleapp directory and using the sun jar tool to archive the war. example:
jar -cvf exampleapp.war .
This archives the war like so:
The incorrect way (and the way many of us have done it) would be to navigate to /home/projects/ and type:
jar -cvf exampleapp.war exampleapp
Which would create the incorrect structure of:
Now that you have your exampleapp.war file copy it to:
and Jboss should hot deploy the war, assuming it's running.
Then you go to your favorite web browser and type:
and it should display your index.html page or whatever you configured you web.xml file to show as it's welcome page.
I hope this is helpful.
for projects in development, it is most convenient to create a directory called "exampleapp.war" (or whatever your app is called) and point the JBoss deployer at the directory above it (e.g. "file://home/projects/").
This will save you the trouble of jar'ing your application every time you make a change.
Good post, thanks. I am a JBOSS newbie, moved from JRun recently. Don't we have the JRun equivalent of web server to app server connector here. ?
Also, I get a 400 null error when I do the steps you mentioned.Any obvious mistakes.. ?
Any help would be appreciated
Great post. I followed this and finally got it working.
Q: Now that I have this working, my Apache 2.0 is not working. I have mapped, or tried to, Apache 2.0 to jboss-3.0.0_tomcat-4.0.3 by using mod-jk.dll, which I have working for tomcat-4.0.3 perfectly. To make this work, I put
in tomcat4-service.xml. However, http://localhost/example/jsp/index.html
which should now be working because
works. But it is not.
For those of you just getting into building Web applications - this is also a good time to start to learn about Ant. Ant ( http://jakarta.apache.org/ant ) is a Java-based build tool that will enable you to script the build process, including compilation and packaging, of your application.
Recent versions have featured a task specifically for the purposes of building WAR files. The task is quite flexible, and enables you to build a WAR by referencing files within your existing project - i.e. you do not have to copy the files over into a structure representing the WAR file.
Here's an example snippet that builds a WAR named mywebabb.war, including a dependent library, web.xml, web app related classes, jboss specific web deployment descriptor, tag library descriptions, jsps, and jpeg images.
Is there any reason that this formula can't be used to make the jboss example/template work? I'm struggling with that problem.
a ant profile:
<?xml version="1.0" encoding="UTF-8"?>
clean - Remove all generated files.
prepare - Set up build directory structure.
compile - Compile all needed java source
web-dist - package all needeb by web application
ejb-dist - package all needed by ejb application
all - Almost everything.
web-deploy - copy all needed to jetty
ejb-deploy - copy all needed to jboss
deploy - deploy all
What if you want to access your "application" from the root folder of your website, instead of from a subfolder? How can you do this with JBoss/Tomcat bundled.
I have halted progress on OpenStandards.net for two weeks in search of an answer to this question, but NO ONE will try to answer it. This is extremely frustrating.
Tomcat without JBoss allows you to do it in the server.xml using the context tag and the docBase property. It even gives an example with the ROOT application.
I've been trying to get JBoss to deploy an COMPLETELY UNPACKED standard ear with no success!
I can get an unpacked war to work correctly, but not the whole application - including unpacked ejb.jar and webapp.war
Can JBoss actually handle a completely unpacked application? If so what do you need to do? Unfortunately the books haven't been much help in this case either. Am I missing something?
jboss 3 + certainly can. Does your directory structure exactly match a jarred structure, with each "package name" like myapp.ear being a directory? Did you get META-INF, not meta-inf?
What do you mean root folder of your website? Can you be a little bit more specific? With JBoss/Tomcat bundled, you should still deploy your "application" in JBoss's deploy directory (e.g. jboss/server/default/deploy). You can deploy the "application" as a directory structure or as a packaged archive (war or ear archive).
What I mean is that you can have JSP pages in your web root (e.g., http://www.OpenStandards.net/index.jsp). With war deployment, regardless of whether or use a folder in JBoss deploy or a JAR archive, your JSP pages are effectively deployed in a subfolder from your web root (e.g. deploying testapp.war would result in http://www.OpenStandards.net/testapp/).
Tomcat allows you to configure a specific WAR as your root application. Search for "ROOT" in the server.xml that installs with Tomcat for an example. Tomcat goes even further by allowing you to JSP/servlet enable any folder in your file system.
However, JBoss bundled with Tomcat ignores the server.xml. So, the question is, how can you declare an application as a "root application" that will be accessed from the root folder of your website with JBoss bundled into Tomcat?
BTW, the reason OpenStandards.net is working now is because I am currently using JBoss 2.4 in production bundled with Tomcat 3. This version does not disable the server.xml, so I was able to use all of Tomcat's features. I need to upgrade to JBoss 3/Tomcat 4, though. I have halted adding any new features until this problem is resolved. Considering that the site serves those who support open standards and open source, this is not good.
You can for jboss3 use a WEB-INF/jboss-web.xml with
the following content:
Thank you. It worked.
I've had a lot of difficulty with this issue. I can create a .war directory and define it as the '/' by <context-root> entry in jboss-web.xml, but I can't get the server to recognize a '.war' directory nor a 'ROOT.war' directory as '/' automatically. Any ideas why?