Can't able to deploy EAR on JBoss 8 WildFly - java

I tried to deploy an EAR file into the JBoss WildFly server, but it is not deploying the EAR file.
Steps that I followed:
Copy the EAR file and paste into jboss_dir/standalone/deployments location.
Run the command jboss_dir/bin/standalone.bat
If I put the JAR or WAR file than JBoss server can able to deploy.
Kindly help me out to fix this issue.
In JBoss 4.2 I just copy EAR file into the default/deploy folder and it is able to deploy, but I want to deploy EAR file into JBoss WildFly.

You need to place the application.xml deployment descriptor in META-INF inside the ear.
<?xml version="1.0" encoding="UTF-8"?>
<application version="7" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
<display-name>Your-ear-name</display-name>
<module>
<java>Your-jar-1</java>
</module>
<module>
<java>Your-jar-2</java>
</module>
<library-directory>lib</library-directory>
</application>

Related

Trouble in Externalizing application.properties in tomcat

I have a grade project with active profile stage(application-satge.properties).How can I configure this file from outside my project. War which is deployed in /webapps folder of tomcat, so that I can make changes since no CI/CD used in project.
**.properties files in the project
application.properties -> have spring.profiles.active=stage
2.application-stage.properties
i have tried putting this content as context.xml in tomcat/conf/catalina/localhost
<Context>
<Resources>
<PreResources className="org.apache.catalina.webresources.FileResourceSet"
base="apache-tomcat-8.5.65/webapps/application-stage.properties"
webAppMount="/WEB-INF/classes/application-stage.properties" />
</Resources>
</Context>
any suggestions please do my paths gone wrong?

Can't run Core Java web application into Azure Web app

I have written a core java web application using maven-archetype-webapp and trying to deploy the jar file and web.config in a azure windows based webapp but not able to access the url. I only have home page inside my application. and following below steps. I am able to run it in my local system and can see the homepage.
azure-webapp-maven-plugin added in POM and build with mvn azure-webapp:config, then inside configuration tag I added below tag.
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80</value>
</property>
</appSettings>
Created a web app in Windowsusing Java 8 and Tomcat 8.5
Deployed jar file and web.config file inside wwwroot directory
Web.config
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-Djava.net.preferIPv4Stack=true -Dserver.port=%HTTP_PLATFORM_PORT% -jar "%HOME%\site\wwwroot\TestWebApp.jar"">
</httpPlatform>
</system.webServer>
</configuration>
Folder Structure
Azure directory structure
Local system Output:
Thanks #soumen for the solution.
Deployed the war file inside wwwroot -> webapps folder in azure
webapp. Before deploying deleted the Root folder inside webapps, after
my deployment new root folder was automatically generated, now I can
access the url.
I take it as an answer, hoping to help other members.

Can a class in one WAR be referenced in web.xml of another WAR in the same EAR, in Wildfly 10?

I have an ear with 2 .war files.
In war #1, under WEB-INF/classes/com/my there is a BatchTriggerBuildServlet.class
In war #2 i have the following in its web.xml (in its WEB-INF)
(a reference to a class in war #1):
<web-app id="WebApp">
<!-- other stuff -->
<servlet>
<servlet-name>BatchTriggerBuildServlet</servlet-name>
<display-name>BatchTriggerBuildServlet</display-name>
<servlet-class>com.my.BatchTriggerBuildServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BatchTriggerBuildServlet</servlet-name>
<url-pattern>/BatchTriggerBuildServlet</url-pattern>
</servlet-mapping>
<!-- other stuff -->
</web-app>
This is deployed in Wildfly 10.
I also have a jboss-deployment-structure.xml in the META-INF folder of the containing .ear containing the following:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<!-- Make sub deployments NOT isolated by default, so they can see each others classes without a Class-Path entry -->
<ear-subdeployments-isolated>false</ear-subdeployments-isolated>
</jboss-deployment-structure>
Is this legitimate? Because I'm getting a ClassNotFoundException for the above class when i try to deploy the ear, along with the message that it
"Failed to start service ... from [Module "<my ear name>.<my war #2 name>:main" from Service Module Loader]"
Is there a way to get this to work?
thanks in advance.
ear-subdeployments-isolated does not apply to web modules, which are always isolated from each other. See Class Loading in WildFly.
Try moving the classes and their dependencies into a jar in the EAR/lib directory.

How to deploy one .war after another on JBoss

Is there a way to define order of .war deployments on JBoss 7?
What I would like to accomplish is that on startup of JBoss it first deploys .war A and then .war B.
I need this because .war A is a service which is consumed on a startup of .war B!
You have to specify the dependency on the B war by creating a jboss-all.xml file on the META-INF folder,with a content like this:
<jboss umlns="urn:jboss:1.0">
<jboss-deployment-dependencies xmlns="urn:jboss:deployment-dependencies:1.0">
<dependency name="A.war" />
</jboss-deployment-dependencies>
</jboss>
The procedure is explained here Control the order of Deployed Applications on JBoss
As mentioned in this JBoss's Forum thread, in order to ensure that A.war is deployed first than B.war, you should create a MANIFEST file under your B.war's src/main/webapp/META-INF folder, with the following entry:
dependencies: deployment.A.war
Furthermore, if you need to access A.war classes from B.war, you should also add a jboss-deployment-structure.xml, under your B.war's src/main/webapp/WEB-INF folder, with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:jboss:deployment-structure:1.2 http://www.jboss.org/schema/jbossas/jboss-deployment-structure-1_2.xsd">
<deployment>
<dependencies>
<module name="deployment.A.war" export="true"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
You can also take a look at JBoss AS 7 class loading documentation.

Glassfish and EAR naming conventions

I have a EAR file that contains a webmodule named foo-web-1.01-SNAPSHOT.war that I deploy in Weblogic and it works fine. When I try the same on Glassfish I get a FileNotFound.
java.io.FileNotFoundException: /glassfish/domains/domain1/applications/foo-1.01-SNAPSHOT/foo-web-1_01-SNAPSHOT_war/WEB-INF/web.xml
I'm not sure why it's expanded the dots in the filename with underscores. What's the exact specification around this? Is my filename invalid?
EDIT:
My EAR is structure is as follows.
foo-1.01-SNAPSHOT.ear
META-INF/MANIFEST.MF
META-INF/application.xml
APP-INF/lib/*.jar
foo-web-1.01-SNAPSHOT.war
The war is structured as follows
foo-web-1.01-SNAPSHOT.war
META-INF/MANIFEST.MF
WEB-INF/web.xml
WEB-INF/webservices.xml
WEB-INF/wsdl/foo.wsdl
WEB-INF/lib/*.jar
WEB-INF/classes/*.class
And the application descriptor
<application>
<display-name>foo</display-name>
<description></description>
<module>
<web>
<web-uri>foo-web-1.01-SNAPSHOT.war</web-uri>
<context-root>/foo</context-root>
</web>
</module>
</application>

Categories