Can we change Jboss default deploy folder path? - deployment

Let's assume I've war file in one location in file system and I have Jboss server installed at different location in file system.Now my question is there any way Jboss can access my war file directly.
In short I don't want to move my war file in deploy folder instead I want location of war file to be treated as deploy folder.
Is it possible??If yes then how?

Add path of custom deployment directory in standalone-*xml like :
<paths>
<path name="custom.dir" path="/PATH_TO/jboss/applications"/>
</paths>
and then in deployment-scanner subsystem mention it like :
<subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
<deployment-scanner path="customDeployDir" relative-to="custom.dir" > scan-interval="5000"/>
</subsystem>

Related

Eclipse + Tomcat 8 - application double deployment

I'm developing for Tomcat 8 under Eclipse Mars.
This is my application context in published server.xml:
<Context docBase="C:\automation\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\ROOT" path="" reloadable="false"/>
<Context docBase="AutomationWeb" path="/automation" reloadable="true" source="org.eclipse.jst.jee.server:AutomationWeb"/>
No other contexts defined there. But when I open tomcat manager app I see 2 contexts for my application:
One with "/AutomationWeb" path,
other with "/automation" path
My app has no context.xml
What I've discovered:
They share display name from my application's web.xml
My application can run on both paths.
The one with /AutomationWeb path is not actually reloadable
If I remove my application(Web Module) from Tomcat server in Eclipse, both entries disappear from tomcat manager app.
Deleting server in Eclipse and deleting contents of \workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\ didn't help.
How can I remove undesired application context with /AutomationWeb path? What configs should i check?
Solved it by changing publish directory from webapps to webappsauto. It seems the problem was in server.xml because of this statement:
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">

Deploy .war file from another directory to Tomcat 6

If it is possible, how do I deploy a war file from another directory (say D:\foo.war) to Tomcat 6, without copying it into the webapps directory of Tomcat?
If not, is there any configuration to change the default webapp folder to some other folder?
You can do both.
how do I deploy a war file from another directory (say D:\foo.war) to Tomcat 6, without copying it into the webapps directory of Tomcat?
Add a Context xml file to conf/Catalina/localhost. The name of the file should be the name that you want for the context. For example, if my URL is http://your.domain.com/my-context then the name of the file would be my-context.xml. Inside that XML file add something like this.
<?xml version="1.0"?>
<Context docBase="d:\foo.war">
</Context>
The docBase attribute should point to your WAR file or an exploded WAR directory. See more on this here.
If not, is there any configuration to change the default webapp folder to some other folder?
In conf/server.xml locate your Host tag and set the appBase attribute. This defaults to webapps, but you can change it to any location that you like.
Ex:
<Host appBase="d:\my-web-apps" ...>
For best results, point to local storage and not network storage (i.e. NFS or Samba).
Simply specify a context entry in your server.xml (under <Host> </Host>
<Context docBase="xyz/abc.war" path="/myapp" reloadable="true"/>

Eclipse WTP - specify deploy folder for the project

I'm using Eclipse WTP plugin for my java web project. I am deploying project via Servers view. Now, I'd like to know whether it is possible to specify name of the deploy folder, by default all files are being placed into a folder that has same name as project has. Is this configurable? Can this be done without modifying project name?
For instance: I have project name in Eclipse MyCompanyProject and when it is being deployed, I get folder with binaries and other resources in webapps\MyCompanyProject. But I'd like to have it deployed to webapps\projectA
Okay, file org.eclipse.wst.common.component should be modified in order to achieve that.
Lines:
<wb-module deploy-name="projectA">
...
<property name="context-root" value="projectA"/>
This change will be reflected inside server.xml:
<Context docBase="MyCompanyProject" path="/projectA" reloadable="true"/>
Resolved...

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.

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

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.