Page 1 of 1

Deploy Demo Site into Stand Alone Tomcat server

Posted: Fri Aug 28, 2015 6:46 am
by incre2012
The Broadleaf Demo site works in eclipse through an embedded tomcat server . Now I need to deploy and run it from a stand alone tomcat server .
Went through all relevent links on this as well as other popular forums . Google also did not help . So I am asking for help to solve this problem .

Re: Deploy Demo Site into Stand Alone Tomcat server

Posted: Sun Aug 30, 2015 10:37 am
by rudy
Hi,

You can follow the below steps.

1. Install tomcat server. Lets call the installation directory [TOMCAT_FOLDER]/lib/

2. Generic JDBC Driver
If you are using tomcat 6.0 or below, download tomcat-jdbc.jar and put it inside [TOMCAT_FOLDER]/lib/
You can download this here: http://www.java2s.com/Code/JarDownload/tomcat-jdbc/tomcat-jdbc.jar.zip

3. Database specific JDBC driver
Next, put your JDBC driver into [TOMCAT_FOLDER]/lib/. For oracle, its ojdbc.jar, for MySQL it is mysql-connector.jar [Make sure you get the right version of the JAR]

4. Configure JNDI for tomcat
Next, in your admin OR site (anyone of these) module in your broadleaf workspace, there is a folder named target
which has another folder tomcat-server-config. This folder has a file context.xml.
  • Copy this file into [TOMCAT_FOLDER]/conf/
  • Before replacing, make sure, you backup the original file
  • Now, open this file and replace the following properties with your database values
    • username="${database.user}" : Replace with your database username
    • password="${database.password}" : Replace with your database password
    • driverClassName="${database.driver}" : Replace with your database classname (e.g. oracle.jdbc.driver.OracleDriver)
    • url="${database.url}" : Replace with your database URL with database path, port and name. (e.g. jdbc:oracle:thin:@localhost:1521:orcl)

5. Let the application know about configured JNDI

Next, open web.xml for both, site and admin modules.
Add the following code in both web.xml files.

Code: Select all

    <!-- EXTERNAL SERVER CONFIGURATION -->
    <resource-ref>
        <description>WEB</description>
        <res-ref-name>jdbc/web</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
   
    <resource-ref>
        <description>STORAGE</description>
        <res-ref-name>jdbc/storage</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
   
    <resource-ref>
        <description>SECURE</description>
        <res-ref-name>jdbc/secure</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>


6. Create keystore for SSL switching
Next, open cmd prompt [for windows] OR command shell [for linux].
Navigate to your [JDK directory]/bin and run the below command.

Code: Select all

keytool -genkey -alias tomcat -keyalg RSA -storepass password


7. Enable ports for switching to secure pages
Next, open [TOMCAT_FOLDER]/conf/server.xml
Add the following code to enable SSL switching, just below your default connector port.
Default connector port would look somewhat like

Code: Select all

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />


Add below code just below the above code.

Code: Select all

<Connector port="8443" maxThreads="200"
           scheme="https" secure="true" SSLEnabled="true"
           keystorePass="password"
           clientAuth="false" sslProtocol="TLS"/>


8. Deployment
Finally, copy the WAR files created by MAVEN in your eclipse, and paste into [TOMCAT_FOLDER]/webapp/
folder.

9. Start tomcat, and access the application by
http://localhost:8080/<your_war_file_name>

Let me know how it goes.. :) ;) :mrgreen:

Re: Deploy Demo Site into Stand Alone Tomcat server

Posted: Thu Jan 19, 2017 10:05 am
by sumit17mar
Hi ,

This is working good on local.

However, I want to host it on standalone tomcat. And the hosting provider does not provide access to tomcat/lib folder .

So I could not copy the mysql-connector jar in tomcat/lib folder .

Can you please share the steps to make mysql-connector.jar part of WAR to use it only for 'SITE'.

Many Thanks

Re: Deploy Demo Site into Stand Alone Tomcat server

Posted: Tue Jan 24, 2017 7:07 am
by sumit17mar
@rudy

URGENT !!!

Can somebody please please help .

Re: Deploy Demo Site into Stand Alone Tomcat server

Posted: Tue Jul 25, 2017 10:39 am
by phillipuniverse
So I could not copy the mysql-connector jar in tomcat/lib folder .

Can you please share the steps to make mysql-connector.jar part of WAR to use it only for 'SITE'.


You can add the mysql connector dependency to the site project like this:

Code: Select all

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.31</version>
</dependency>


After you do that and do an 'mvn package' Maven will put the jar into the built .war.

The Broadleaf forums are being retired as a readonly archive of questions. For active discussions and questions, check out the broadleaf-commerce tag on Stack Overflow which is actively monitored by the Broadleaf team.