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.confto 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.xmlfile to yoursiteandadminatsrc/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
siteandadminPOMs to package as a war, e.g.<packaging>war</packaging>.Ensure your
sitehas afinalNameofROOT.<build> <finalName>ROOT</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> </plugin> ... </plugins> </build>
Add
spring-boot-starter-tomcatas aprovideddependency to yoursiteandadminPOMs:<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
SiteConfigorAdminConfig, 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 packageormvn install - Copy
site/target/ROOT.warandadmin/target/admin.warto$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.shNavigate to your
siteoradminand 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/
JBoss EAP 7.2
An additional configuration is needed for EAP 7.2. On startup JBOSS will throw warning messages about the Load-Time Weaving (LTW) implementation. For this version of JBOSS, the specific LTW implementation will need to be changed to support JBOSS specifically. See Table 11.1 in the Spring Framework Reference for the implementation for your specific Application Server.