How to fail war deployment if dependent war fails in wildfly - wildfly

I have 2 war files as below
1st is for DB jndi registration (jndi-reg.war).
2nd war (actual application)
This war deployment depends on jndi-reg.war, so for this I have added jboss-all.xml under /WEB-INF/ of second war,
jboss-all.xml as below
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="jndir-reg.war" />
</jboss-deployment-dependencies>
</jboss>
The problem is that I want to fail my application war if jndi-reg.war fails (like in case db credential is invalid)
But with above file war, under standalone/deployment/apple.war.deployed show war is deployed but not able to access it, So What things I should do to fail the application war in case if jndi-reg.war fails.

Related

How to create a priority service thread pool in jboss

I have deployed 2 war files in jboss 6.4 (SupposeA.war and B.war) ,I want A.war to be deployed first then B deployment should start.
Is there any way to do it.
This is required as my B.war is dependent on A.war.
You can create a jboss-all.xml deployment file (located under B.war/WEB-INF/jboss-all.xml) and it should be something like:
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="a.war" />
</jboss-deployment-dependencies>
</jboss>
Now B will start after A has been deployed. The same file works for any top level deployment, as an ear.

Specify context-path for spring-boot WAR

I have a spring boot web application that deploys as a WAR. Right now when I deploy it to my Tomcat 7 server, it uses the name of the war file as the context, such as /myartifactid-1.5.4.SNAPSHOT/. I want to specify the context-path, but
server.contextPath=/mywebapp
seems to only work for embedded tomcat. I've added a META-INF/context.xml with only this
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="false" path="/mywebapp" />
but that hasn't had any effect.
EDIT: This is NOT a spring-boot issue, but instead related to how NetBeans behaves differently from Eclipse. NetBeans apparently recognizes the context path parameter in context.xml, but Eclipse doesn't. In Eclipse you have to modify the Web Projects Settings to set the context path.
Changing Tomcat context path of web project in Eclipse
Since you are packaging your Spring Boot application as a war (as opposed to a jar with an embedded tomcat container) the context path will be the name of the war.
For example if you name your packaged application mywebapp.war and you place it under Tomcat's webapps, it will be available under /mywebapp
when the war does not have the same name with the project, the application will not be accessible via the context path on the tomcat,
to fix this you need to go to the POM.xml change the name of package to match the context path name
server.servlet.context-path=/virtualcard
<groupId>com.test.csc.virtualcard</groupId>
<artifactId>virtualcard</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>virtualcard</name>
then the war will be: virtualcard.war

Axis2 doesn't see any services when deployed in ear

I have crated simple webservice with axis2 (1.4.1), without aar files, i have just "services.xml" in proper directory (WEB-INF/services/MyService/META-INF). After deploying WAR on Weblogic 8.1 service works without any issues and is visible on /listServices. When I use same WAR as a part of EAR I get next error:
"The service cannot be found for the
endpoint reference (EPR)"
and /listServices is empty. Other servlets contained in WAR aren't affected and work same way when deployed as WAR or EAR.
Axis requires exploded WAR in EAR. However that won't work with WL 8.1, it throws an exception during deployment. I ended up modifying axis so it extracts war just before it starts searching for services - ugly hack but works flawlessly.

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.