Page 1 of 1

Deploy Broadleaf Commerce on Tomcat

Posted: Wed Jun 26, 2013 5:44 am
by coy198x
Hi there,

I am trying to deploy Broadleaf Commerce on Tomcat. I deployed admin project well but with site project is not. Tomcat throw "permgen space exception". I don't know what i miss. Here is my catalina.bat and porm.xml of admin and site project:

- catalina
....
JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=1024m -XX:MaxPermSize=1024m -XX:+DisableExplicitGC"

rem Suppress Terminate batch job on CTRL+C
if not ""%1"" == ""run"" goto mainEntry
if "%TEMP%" == "" goto mainEntry
if exist "%TEMP%\%~nx0.run" goto mainEntry
echo Y>"%TEMP%\%~nx0.run"
if not exist "%TEMP%\%~nx0.run" goto mainEntry
echo Y>"%TEMP%\%~nx0.Y"
call "%~f0" %* <"%TEMP%\%~nx0.Y"
rem Use provided errorlevel
set RETVAL=%ERRORLEVEL%
del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1
exit /B %RETVAL%
:mainEntry
del /Q "%TEMP%\%~nx0.run" >NUL 2>&1
...


- porm.xml of admin project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>ecommerce-website</artifactId>
<version>1.0</version>
</parent>
<artifactId>admin</artifactId>
<packaging>war</packaging>
<name>admin</name>
<description>Web Module For Customized Broadleaf Commerce Admin</description>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<!-- httpsPort and httpPort are used by embeded jetty server. -->
<!-- Make sure the following httpsPort matches what's in the runtime-properties
file, -->
<httpsPort>8444</httpsPort>
<httpPort>8081</httpPort>
</properties>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<finalName>admin</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
<contextPath>/admin</contextPath>
<stopPort>9967</stopPort>
<stopKey>foo</stopKey>

<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>${httpPort}</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
<connector
implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<port>${httpsPort}</port>
<keystore>${webappDirectory}/WEB-INF/blc-example.keystore</keystore>
<keyPassword>broadleaf</keyPassword>
<password>broadleaf</password>
</connector>
</connectors>
<webAppConfig>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</webAppConfig>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<warSourceDirectory>${webappDirectory}</warSourceDirectory>
<path>/</path>
<port>${httpPort}</port>
<httpsPort>${httpsPort}</httpsPort>
<keystoreFile>${webappDirectory}/WEB-INF/blc-example.keystore</keystoreFile>
<keystorePass>broadleaf</keystorePass>
<password>broadleaf</password>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>genkey</id>
<goals>
<goal>genkey</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${webappDirectory}/WEB-INF/blc-example.keystore</keystore>
<dname>cn=localhost</dname>
<keypass>broadleaf</keypass>
<storepass>broadleaf</storepass>
<alias>broadleaf</alias>
<keyalg>RSA</keyalg>
</configuration>
</plugin>

<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<configuration>
<packaging>war</packaging>
<rootPath>${basedir}</rootPath>
</configuration>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>timestamp-property</id>
<phase>generate-sources</phase>
<goals>
<goal>timestamp-property</goal>
</goals>
<configuration>
<name>clientBuildDate</name>
<pattern>yyyy-MM-dd HH:mm:ss</pattern>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-admin-module</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-contentmanagement-module</artifactId>
</dependency>

<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-framework-web</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-common</artifactId>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
</dependencies>
</project>


- porm.xml of site project
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mycompany</groupId>
<artifactId>ecommerce-website</artifactId>
<version>1.0</version>
</parent>
<artifactId>site</artifactId>
<packaging>war</packaging>
<name>site</name>
<description>Web Module For Broadleaf Commerce Based ECommerce Site</description>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- httpsPort and httpPort are used by embeded jetty server. -->
<!-- Make sure the following httpsPort matches what's in the runtime-properties
file, -->
<httpsPort>8443</httpsPort>
<httpPort>8082</httpPort>
</properties>
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<finalName>JMango</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>

<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>8.1.5.v20120716</version>
<configuration>
<webAppSourceDirectory>${webappDirectory}</webAppSourceDirectory>
<contextPath>/</contextPath>
<stopPort>9966</stopPort>
<stopKey>foo</stopKey>
<connectors>
<connector implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
<port>${httpPort}</port>

<maxIdleTime>60000</maxIdleTime>
</connector>
<connector
implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<port>${httpsPort}</port>
<keystore>${webappDirectory}/WEB-INF/blc-example.keystore</keystore>
<keyPassword>broadleaf</keyPassword>
<password>broadleaf</password>
</connector>
</connectors>
<webAppConfig>
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
</webAppConfig>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<warSourceDirectory>${webappDirectory}</warSourceDirectory>
<path>/</path>
<port>${httpPort}</port>
<httpsPort>${httpsPort}</httpsPort>
<keystoreFile>${webappDirectory}/WEB-INF/blc-example.keystore</keystoreFile>
<keystorePass>broadleaf</keystorePass>
<password>broadleaf</password>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>genkey</id>
<goals>
<goal>genkey</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>${webappDirectory}/WEB-INF/blc-example.keystore</keystore>
<dname>cn=localhost</dname>
<keypass>broadleaf</keypass>
<storepass>broadleaf</storepass>
<alias>broadleaf</alias>
<keyalg>RSA</keyalg>
</configuration>
</plugin>

<plugin>
<groupId>org.zeroturnaround</groupId>
<artifactId>jrebel-maven-plugin</artifactId>
<configuration>
<packaging>war</packaging>
<rootPath>${basedir}</rootPath>
</configuration>
<executions>
<execution>
<id>generate-rebel-xml</id>
<phase>process-resources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>core</artifactId>
</dependency>
<dependency>
<groupId>org.broadleafcommerce</groupId>
<artifactId>broadleaf-framework-web</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
</dependency>
</dependencies>
</project>


Can someone suggest me what i need to do?

Thanks in advance!

P/s: Sorry for my bad English!

Re: Deploy Broadleaf Commerce on Tomcat

Posted: Wed Jun 26, 2013 9:50 am
by phillipuniverse
First of all, I would change JAVA_OPTS to CATALINA_OPTS. This stack overflow post has a good definition on the differences: http://stackoverflow.com/questions/1122 ... difference.

As for your problem, it looks like you have your environment variables set correctly (-XX:MaxPermSize). I suppose it's possible that those environment variables are not used? Sometimes this happens if you set an environment variable in 1 shell but then actually execute the process in another shell.

Also, I know you didn't explicitly say where you are setting the JAVA_OPTS variable but the recommended way for tomcat is to create a setenv.sh file in the same folder as the 'startup.sh' file ($CATALINA_BASE/bin). This file would have something like this:

Code: Select all

#!/bin/bash
CATALINA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=1024m -XX:MaxPermSize=1024m -XX:+DisableExplicitGC"


This setenv.sh file will get sourced every time the startup task is executed.

Re: Deploy Broadleaf Commerce on Tomcat

Posted: Wed Jun 26, 2013 9:55 pm
by coy198x
Thank you, I changed JAVA_OPTS to CATALINA_OPTS, like this:
CATALINA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms1536m -Xmx1536m -XX:NewSize=512m -XX:MaxNewSize=512m -XX:PermSize=1024m -XX:MaxPermSize=2048m -XX:+DisableExplicitGC"
rem Suppress Terminate batch job on CTRL+C
if not ""%1"" == ""run"" goto mainEntry
if "%TEMP%" == "" goto mainEntry
if exist "%TEMP%\%~nx0.run" goto mainEntry
echo Y>"%TEMP%\%~nx0.run"
if not exist "%TEMP%\%~nx0.run" goto mainEntry
echo Y>"%TEMP%\%~nx0.Y"
call "%~f0" %* <"%TEMP%\%~nx0.Y"
rem Use provided errorlevel
set RETVAL=%ERRORLEVEL%
del /Q "%TEMP%\%~nx0.Y" >NUL 2>&1
exit /B %RETVAL%
:mainEntry
del /Q "%TEMP%\%~nx0.run" >NUL 2>&1

rem Guess CATALINA_HOME if not defined


But when i try to deploy site project, it take a long time for "deploying". Until now it still be deploying, about 15 minutes and not stop yet. Is it normal?

Re: Deploy Broadleaf Commerce on Tomcat

Posted: Thu Jun 27, 2013 8:57 am
by phillipuniverse
It should only take a couple of minutes to deploy. 15 minutes is definitely out of the ordinary.

Did it get stuck on a particular part? Are there other applications being deployed at the same time in your Tomcat container?

Re: Deploy Broadleaf Commerce on Tomcat

Posted: Thu Jul 18, 2013 10:36 pm
by coy198x
Thank you for your reply. I solved problem. The problem is deployment 2 project admin and site in the same Tomcat server. I deploy it into 2 Tomcat Server, one for one. May be there are some problems with project configuration for deployment in the same server.