Saturday, December 24, 2011

Running Broadleaf E-commerce demo in Various Java Application Server and Database

First we start using MySQL and Tomcat 7.0

1. Extract broadleafdemo.war file into an expanded war
2. As detailed here in http://www.broadleafcommerce.org/forum/viewtopic.php?f=9&t=379



2a. in META-INF/persistence-demo.xml' file replace 
- org.hibernate.dialect.HSQLDialect by org.hibernate.dialect.MySQLDialect in the 'blPU' and 'blSecurePU' persistence unit configurations

2b. in WEB-INF/applicationContext-demo.xml' file replace the following lines 


<bean id="webDS" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
      <property name="url" value="jdbc:hsqldb:mem:broadleaf;ifexists=false" />
      <property name="username" value="sa" />
      <property name="password" value="" />
   </bean>


with


<bean id="webDS" class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close">

      <!-- The JDBC Driver class name. -->
      <property name="driverClassName" value="com.mysql.jdbc.Driver" />
      <property name="url" value="jdbc:mysql://localhost:3306/broadleaf" />
      <property name="username" value="MY_USER_NAME" />
     <property name="password" value="MY_PASSWORD" />
   </bean>






and update the username and password properties accordingly!!!


3. login to mysql and create database 'broadleaf'


mysql>> create database broadleaf;


4. copy the expanded broadleaf.war directory created in #1 above into Tomcat 7.0 directory


5. download & copy mysql-connector-java-5.1.17.jar into broadleafdemo.war/WEB-INF/lib


6. start tomcat.




Caveat:


For some reason Spring Framework complains about NOT finding the com.mysql.jdbc.Driver ?
However the broadleafdemo site works OK.



[ INFO] 07:56:49 SchemaExport - exporting generated schema to database
Cannot load JDBC driver class 'org.mysql.jdbc.Driver'
java.lang.ClassNotFoundException: org.mysql.jdbc.Driver
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoa
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
        at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
        at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.get
ataSourceConnectionProvider.java:71)






1 comment:

  1. Can you suggest me the steps for the broadleaf's new demosite.
    I have downloaded the eclipse workspace of broadleaf demosite 2.2.0
    The above mentioned steps dont go with this version..Glad if you can help me.

    ReplyDelete