How can I get JBoss to explode a deployed WAR file? - jboss

I am running JBoss 4.3 on Ubuntu under /usr/local/jboss-4.3/. I have deployed my application as a WAR file i.e. myapp.war, to /usr/local/jboss-4.3/server/myserver/deploy. However, there doesn't seem to be an 'exploded' /myapp directory under the deploy folder, how come?
I am used to Tomcat running on Windows so I am a bit new to JBoss. When you deply WAR to Tomcat, the physical contents of this WAR will be exploded to a /myapp directory. With this it is then possible to modify files under the web app, such as config settings etc.
How can I do this in JBoss?

You can unzip your .war contents in a "myapp.war" folder, which JBoss will consider a deployed application just as if it was a zipped war.
Even better, most IDEs (Eclipse for sure, but i guess other IDEs such as Netbeans) allow you to deploy the exploded package instead of the zipped .war, allowing you to change just the single files you modify instead of the whole .war package

This link can be useful:
http://community.jboss.org/wiki/DeployTipsAndBuildSampleScripts
Quick Summary of what the article concerns: When it comes application builds/deployments in JBoss, there are a plethora of viable approaches. This wiki highlights several build/deploy scenerios, along with steps and pertinent build script samples. The following approaches are covered:
Point/click deployment using JBossIDE - For users that don't like ANT build scripts
Exploded EAR, JAR, SAR, WAR deployment (Option 1) - Maximize development productivity by eliminating ANT copy tasks
Exploded EAR, JAR, SAR, WAR deployment (Option 2) - Separate IDE from the compile, build and deploy process
Normal EAR, JAR, SAR, WAR deployment - Deploy a zipped archive (Necessary when using Clustering/Farm Deployment

Same problem facing, when I export as .war file from Eclipse and copy it into (UAT or Prod) JBOSS Server 7.1.1 Final AS deployement directory, And Start Windows JBOSS Service
.war file deployed sucessfully but .war file not unpacked or exploded into deployment folder.
For This solution is copy example.war exploded folder (name of folder) into deployment folder and then start. And mentions auto-deploye-exploded=true in standalon.xml

it does this in a tmp folder......
but you can explode the file in the deploy directoy just name it "app.war"

I had exactly the same problem with JBoss 7. My ant script would copy the .war file to the JBoss deployments folder (jboss-as-7.1.1.Final/standalone/deployments in my system) but the .war wouldn't explode. The .war was perfectly deployable through the administration CLI so it wasn't an unsatisfied dependency or anything. It was solved when I instructed my Ant war task to not compress the war (set the property compress to false) as in:
...
<target name="war" depends="build">
<mkdir dir="${build.dir}"/>
<war
compress="false"
needxmlfile="false"
basedir="${webroot.dir}"
warfile="${build.dir}/${project.distname}.war">
<exclude name="WEB-INF/${build.dir}/**"/>
<exclude name="WEB-INF/src/**"/>
</war>
</target>

In the standalone.xml I do see only this part of the code:
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
I do not see the deployment-scanner parameters like:
auto-deploy-exploded" => false,
"auto-deploy-zipped" => true,
"deployment-timeout" => 60L,
and so on.

Related

Jboss default deployer war size is more than the same export using eclipse .why?

I have created the workspace in eclipse. I set up a Jboss server for the code deployment. On staring on the Jboss server the new ear is created in the deploy directory of Jboss.Then I have export EAR using export as EAR option available in Eclipse.I found that the Jboss created EAR size is more than eclipse created EAR size. Anyone came across same scenario.?
Note :My ear file not contain any jsp files and its having xsl files.Its a webservice application.
Un zip the ear from eclipse in some local hard drives and check the file size. The same ear from jboss also un zip and chek the file size.you will find both file size is same.If you check the Jboss ear's compression raio you will find it is zero but for the eclipse compression ratio is 100.Its problem of compression mechanisam used ( creating ear file in jboss and eclipse)

deploy.last in JBoss 5.1 in web configuration?

We have ear that depends on war file.
We use web configuration.
I put war file to <jboss_home>/server/web/deploy directory.
And I put ear file to <jboss_home>/server/web/deploy/deploy.last directory.
But ear starts prior to war.
Why?
I use a similar configuration to what you describe, though I put all the apps I want to deploy first in deploy/myapps and all the ones to deploy afterwards in deploy/myapps.last. This works correctly for me on JBoss 5.1.2.
Although I can't explain why it isn't working for you, I can offer an alternative solution. You can make the EAR declare a dependency on the WAR and JBoss will then ensure the WAR is deployed first.
First, add a file called aliases.txt into the META-INF directory of your WAR. This file should just contain a single line with an arbitrary name / identifier for your WAR. For example, if you have mywebapp.war, your META-INF/aliases.txt file could contain 'mywebapp'. It just needs to be something that won't clash with any other aliases declared by other apps deployed on the same server.
Next, add a jboss-dependency.xml file to the META-INF directory of your EAR, containing the following (subsituting 'mywebapp' for the alias you created above):
<dependency xmlns="urn:jboss:dependency:1.0">
<item whenRequired="Real" dependentState="Create">mywebapp</item>
</dependency>
This should ensure the WAR is deployed before the EAR.
Also, if you try to deploy the EAR without the WAR being present, JBoss will log a clear deployment error message telling you about the missing dependency.

I need Eclipse to deploy the WAR file my ANT script builds, not what it builds internally

I'm using Eclipse Helios. I have a dynamic web project going and I've set up Eclipse to use an Ant Builder to generate a WAR file. This all works fine; if I change a .java file, Eclipse automatically runs my build.xml via Ant and updates my WAR. If I deploy the WAR to an external instance of Tomcat, it works perfectly.
However, when I tell Eclipse to run my project under Tomcat, it is not using the WAR file generated by the Ant build, or using my Ant script to generate a temporary WAR.
I know this because my build.xml script includes some additional XML configuration files in WEB-INF/classes in the WAR that are not ending up in the WEB-INF/classes dir that Eclipse pushes out.
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
An alternate approach would be to tell Tomcat when it is building a WAR to do so by adding a list of files, but I can't seem to find a way to do that either.
I'm also curious how Eclipse knows what to publish since it is obviously ignoring my build.xml and my previously-generated WAR file.
Eclipse deploys a web application by looking at the Web Deployment Assembly options for your project. You can see this by right-clicking the project, choosing Properties, and then click on Deployment Assembly. Eclipse usually uses an expanded directory deployment here rather than creating and deploying a WAR (this is based on the server plugin being used, but I think most of them use an expanded directory structure for speed). If you export as a WAR it will create a WAR with the same content.
There are two main choices to do what you'd like:
Modify the Web Deployment Assembly options to match exactly what you would like in the deployed app
Don't use Eclipse's deployment; add an "External Ant Builder" to the "Builders" options for your project (right-click project, choose Properties->Builders). You can then select which targets in the ant file you want to use when eclipse builds the project. One of these options can be a deployment step
I can't seem to find anything within Eclipse that says "when you publish, use this WAR file instead of building your own".
I'm an IntelliJ user, so take this with a grain of salt. But...
Right-click on the Project Explorer target/foo.war, select Mark Deployable.
Then right-click on the foo.war file again and Run As... -> Run On Server...
Choose the JBoss instance.
If you go to the Servers view, you'll now see your WAR file under the JBoss instance as /proj_root/target/foo.war
Oh Eclipse, sigh...

How to deploy EAR into web configuration in JBoss?

We use "web" configuration of JBoss.
Now we deploy war files only.
But we are going to deploy ear to JBoss.
As far as I can see it is impossible to deploy ear on web configuration because there is no ear deployer in web configuration.
Will it be enough just to copy file default\deployers\ear-deployer-jboss-beans.xml to web\deployers directory?
Or some additional files should be copied too?
Instead of starting with the web configuration I will suggest to use the "default" configuration and trim it. For example, remove JMS.

How do you unwar a .war file with ant on windows?

I'm only remotely familiar with what ant does, but apparently I have to setup a service that's run on jboss and put it into a deploy directory...
the problem is the .war file -- I only have winzip 7zip and ant and I dont know how to ge the contentsa out of the .war file to put it in the deploy directory...
are there other conf and build.xml files a well that are needed?
thanks for your help!
//edit
the problem is the instructions say to unwar the .war file. And I Dont know how to do this via JBOSS or any other means. How?
//edit
7zip unwar-ed the file but I'm not sure where to put the contents in jboss.
/server/ ?
Thanks for your help. As this is my first time doing this I'm completely clueless.
Usually you can just place the WAR file into the directory and the container will take care of unpacking it.
But, a WAR file is simply a ZIP file with a different extension, so you could also use any popular unzip tool (WinZip, WinRAR, 7Zip, etc) to unzip it manually if need be.
Ant has an unzip task as well.
JBoss should be able to deploy a war file and unpack it on it's own. You shouldn't be writing scripts that unpack war files for JBoss.
Using unzip task: http://ant.apache.org/manual/Tasks/unzip.html
Unless you have something else in mind1, you don't have to depoy you war in an "exploded" format (i.e. unpacked). Just deploy you war on JBoss and JBoss will deal with it. To do so, just copy your war into /server/default/deploy.
1 The only good reason I can see to deploy a war in an exploded format is if you plan to make incremental changes to the content (e.g. changing just a class) without deploying the whole webapp again. But this doesn't seem to be the case. So just deploy you war without unpacking it.