Tomcat 7
Tomcat 7
This section explains how to deploy Elastic Path web applications on a Tomcat 7 production server.
Make sure that:
- A Java 7 JDK or JRE is installed.
- Oracle Weblogic 11g is installed.
- You have the Web Application .WAR files that were specifically built for Weblogic. For more information, see Elastic_Path_Maven_Commands.html#BuildingWARFiles.
- You have synchronized the date and time of all application servers with the date and time of your database server.
Installing Java Advanced Imaging
If you are using Storefront, you must install Java Advanced Imaging into your production server's JDK as detailed below:
- Go to: http://download.java.net/media/jai/builds/release/1_1_3/
- Download and unzip jai-1_1_3-lib.zip
- Copy the contents of JAI_HOME\lib to your Java_HOME\jre\lib\ext directory.
Creating a .keystore file
In order to use SSL on your production server, you must create a .keystore file.
- Open the command prompt and input the following command to begin creating the .keystore file.
keytool -genkey -alias ElasticPath -keyalg RSA
- Enter in a password, full name, organizational unit, organization, city, state, and country code when promoted.
- When prompted to enter a key password, press Return to generate the .keystore file in your home directory.
Configuring Tomcat
Configuring Startup Scripts
- In <Tomcat_HOME>\bin, open catalina.bat (catalina.sh for Linux) with a text editor.
- Modify JAVA_OPTS to include the following:
-Xmx1024m -XX:MaxPermSize=512m -Dsun.lang.ClassLoader.allowArraySyntax=true
Configuring Connectors
- With an XML editor, open server.xml located in <Tomcat_HOME>\conf
- In server.xml, replace the HTTP Connector element as shown below:
Before After <Tomcat_HOME>\conf\server.xml <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" acceptCount="100" disableUploadTimeout="true" enableLookups="false" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" URIEncoding="UTF-8"/commerce-legacy/>
- In server.xml, replace the SSL Connector element as shown below:
Before After <Tomcat_HOME>\conf\server.xml <!-- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> -->
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" secure="true" enableLookups="false" disableUploadTimeout="true" keystoreFile="HOME\.keystore" keystorePass="PASSWORD" acceptCount="100" maxThreads="25" scheme="https" clientAuth="false" sslProtocol="TLS" URIEncoding="UTF-8"/commerce-legacy/>
where PASSWORD is the password you entered into the .keystore file and and HOME is your home directory.
Deploying Web Applications
Creating Context Files
- In <Tomcat_HOME>\conf, create a directory named Catalina
- Create a subdirectory in Catalina named after your hostname. ie. localhost
- For each web application you want to deploy:
- In your hostname subdirectory, create an xml file named <CONTEXT_PATH>.xml:
Web Application
Context Path.xml Name
Cortex API
cortex
Cortex Studio studio - In <CONTEXT_PATH>.xml, insert the following code:
<?xml version='1.0' encoding='UTF-8'?> <Context useHttpOnly="false"> <Resource auth="Container" name="mail/Session" type="javax.mail.Session"/commerce-legacy/> <Resource name="jdbc/epjndi" auth="Container" scope="Shareable" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" username="USER" password="PASSWORD" driverClassName="DRIVER" url="JDBC_URL" testOnBorrow="false" testWhileIdle="true" timeBetweenEvictionRunsMillis="300000" validationQuery="select 1" /> </Context>
Note: Tomcat 7 XXS is DisabledTomcat 7's useHttpOnly XSS-prevention feature is disabled as a workaround for a bug around DWR's CSRF prevention measures.
- Replace USER and PASSWORD with the information of an account that can access your database.
- Replace DRIVER with the JDBC Driver that corresponds to your DBMS and JDBC_URL with your Database Connection URL
Table 2. Database JDBC Driver JAR file MySQL 5.6 mysql-connector-java-5.1.25.jar MS SQL 2008 sqljdbc.jar Oracle 11g ojdbc15-11.1.0.7.0.jar where HOSTNAME, PORT, DBNAME, and SID correspond to your specific database.
- In your hostname subdirectory, create an xml file named <CONTEXT_PATH>.xml:
Deploying .WAR files
- Place the Web Application .WAR files in <Tomcat_HOME>\webapps
- Rename the copied .WAR file with its context path. For example, if you created storefront.xml, you rename the storefront WAR file you're deploying to storefront.war.
You must have the search server deployed and running to use Cortex API's search functionality.
When you start Tomcat 7, you may see the following error message in your console and logs:
SEVERE: Unable to process Jar entry [com/ibm/icu/impl/data/LocaleElements_zh_PINYIN.class] from Jar [jar:file:/c:/apache-tomcat-7.0.30/webapps/cmserver/WEB-INF/lib/icu4j-2.6.1.jar!/] for annotations org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60
This is a known issue with the icu4j-2.6.1.jar that can be ignored.