JBoss
Our reference architecture specifies Tomcat as our default container. However, developers may wish to launch Broadleaf Commerce in JBoss for any
number of reasons. This tutorial provides the steps necessary to use JBoss EAP 7.1 as the container in which to launch an instance of Broadleaf Commerce version 5.2.x. JBoss EAP 7.1 compatibility for Broadleaf Commerce requires at least the latest 5.2.x version of Broadleaf.
WARNING: JBoss is built to be a JEE container and tends to bring in a lot of additional subsystems and dependencies that may or may not conflict with the Broadleaf Spring Boot application. Be diligent about excluding unnecessary subsystems and dependencies if you run into conflicts.
Assumptions:
- You're launching JBoss using the standalone configuration
- You're installing the Broadleaf Commerce Heat Clinic demo on JBoss (or a project based on the Heat Clinic demo)
- You are using Broadleaf's out-of-box HSQLDB and not your production DB (additional steps necessary if not using HSQLDB)
Configure JBoss
Download and install JBoss EAP 7.1 (https://developers.redhat.com/products/eap/download/)
Edit
$JBOSS_HOME/bin/standalone.conf
to include the following JAVA_OPTS, which you may adjust for your environment:JAVA_OPTS="$JAVA_OPTS -javaagent:/path/to/your/spring-instrument.jar" JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" JAVA_OPTS="$JAVA_OPTS -Xms4096m -Xmx4096m"
Configure the Application
Add a
jboss-deployment-structure.xml
file to yoursite
andadmin
atsrc/main/resources/webapp/WEB-INF/jboss-deployment-structure.xml
:<?xml version="1.0" encoding="UTF-8"?> <jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2"> <deployment> <exclude-subsystems> <subsystem name="jaxrs" /> <subsystem name="webservices" /> <subsystem name="jsf"/> </exclude-subsystems> </deployment> </jboss-deployment-structure>
Note: The JSF subsystem especially is incompatible with Broadleaf and causes numerous class loading issues. This MUST be excluded.
Modify your
site
andadmin
POMs to package as a war, e.g.<packaging>war</packaging>
.Ensure your
site
has afinalName
ofROOT
.<build> <finalName>ROOT</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> </plugin> ... </plugins> </build>
Add
spring-boot-starter-tomcat
as aprovided
dependency to yoursite
andadmin
POMs:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
Remove tomcat servlet container factory bean and Connector from your
SiteConfig
orAdminConfig
, if they exist:// REMOVE THESE METHODS! @Bean public EmbeddedServletContainerFactory tomcatEmbeddedServletContainerFactory(@Value("${http.server.port:8080}") int httpServerPort) { TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); tomcat.addAdditionalTomcatConnectors(createStandardConnector(httpServerPort)); return tomcat; } private Connector createStandardConnector(int port) { Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); connector.setPort(port); return connector; }
Deploy to JBoss
- Build your WARs using
mvn package
ormvn install
- Copy
site/target/ROOT.war
andadmin/target/admin.war
to$JBOSS_HOME/standalone/deployments/
- Start up JBoss using
$JBOSS_HOME/bin/standalone.sh
Note: This will deploy both apps on the 8443 port by default, there may be additional configuration to deploy them to separate ports; this usually involves separate standalone deployments.
Deploy using Wildfly Maven Plugin
You can also use the Wildfly Maven Plugin for an easier time deploying your WAR.
Add the plugin to your root
pom.xml
:<plugin> <groupId>org.wildfly.plugins</groupId> <artifactId>wildfly-maven-plugin</artifactId> <version>1.2.1.Final</version> </plugin>
Be sure your standalone JBoss is running already using
$JBOSS_HOME/bin/standalone.sh
Navigate to your
site
oradmin
and runmvn clean install wildfly:deploy
, ormvn wildfly:deploy
Details on the Wildfly Maven Plugin can be found here: http://docs.jboss.org/wildfly/plugins/maven/latest/