BroadleafCommerce / ReactStarter

Broadleaf Commerce Spring Boot React Starter
Creative Commons Zero v1.0 Universal
43 stars 41 forks source link

Converting ReactStarter API and Admin to mySQL + Tomcat #11

Closed sosproduction closed 5 years ago

sosproduction commented 5 years ago

Hi Broadleaf guys, I am currently working with the ReactStarter and converting it to use mySQL and Tomcat for the Admin and API applications. I am finding that the site/pom structure of the React Starter is a little different from the regular Broadleaf Demo and running into some issues. After I get through these steps I plan on writing up some detailed instructions that I can commit back to you guys for the community.

Basically what is happening at the moment, that when building in IntelliJ for some reason Apache Solr blows up. I have the mySQL tables connected in IntelliJ and I can view everything. I will post the error from Solr below, and then all the steps I have done thus far (I am assuming that the /site directory plays no part at all in configuring, as it is served with webpack/node)

First Question

  1. I see in the build for admin that the site starts Tomcat. Was wondering if you guys already ported this code over to use Tomcat as the default instead of Jetty?
Tomcat initialized with port(s): 8444 (https) 8081 (http)
Starting service [Tomcat]
Starting Servlet Engine: Apache Tomcat/8.5.27

Solr The problem is mostly likely related to me improperly configuring mySQL The error is part of a long java stack trace:

Not found in 'org.owasp.esapi.resources' directory or file not readable: /Users/rgeisman/Development/broadleaf-react/admin/ESAPI.properties

Steps I took in setting up mySQL The root pom.xml actually doesn't have a reference to the HSQL database like the regular Heat Clinic demo does. The exporting of the schema fails until I add it. The instructions differ also between the Heat Clinic Demo and just the general moving to mySQL instructions. These are the steps I have taken so far:

  1. Added mySQL connector to root pom.xml
<dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
     <version>5.1.46</version>
     <type>jar</type>
     <scope>compile</scope>
</dependency>
  1. In both of the pom.xml files for /admin, and /api I added:
    <dependency>
    <groupId>com.broadleafcommerce</groupId>
    <artifactId>broadleaf-boot-starter-database</artifactId>
    </dependency>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    </dependency>
  2. In the common-shared.properties file at core/src/main/resources/runtime-properties I added the mySQL connectors and commented out the HSQL ones:
    blPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    blCMSStorage.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    blSecurePU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
    blEventPU.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
  3. In the common-shared.properties file at core/src/main/resources/runtime-properties I removed the settings that cause mySQL errors:
blPU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor
#
blSecurePU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor
# blCMSStorage.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor
# blEventPU.hibernate.hbm2ddl.import_files_sql_extractor=org.broadleafcommerce.common.util.sql.importsql.DemoHsqlSingleLineSqlCommandExtractor
  1. Next, In the common-shared.properties file at core/src/main/resources/runtime-properties I added my database connection properties:

    # your local database username, just a user that has readwrite permissions
    database.user=rgeisman
    # local database password
    database.password=***********
    database.driver=com.mysql.jdbc.Driver
    # this connection URL assumes that it is connecting to a schema called broadleaf
    database.url=jdbc:mysql://localhost:3306/broadleaf?useUnicode=true&amp;characterEncoding=utf8
  2. Installed mySQL on my local machine, with a user as rgeisman, and granted all privileges, and also created a database called: broadleaf

  3. Then in my ~/rgeisman directory, I created a file called .my.cnf Inside the file I placed these contents:

    [mysqld]
    lower_case_table_names=1
    character-set-server=utf8
    collation-server=utf8_general_c
  4. When I set up the database configuration in IntelliJ to look at the tables, it requested that I needed to download the connector. So I did. The connector .jar file 5.1.46 matches the version in the root pom.xml. I then tested the connection in IntelliJ and it is successful.

I don't think I am missing anything... but both the /admin, and /api fail to build when relating to Solr. All the tables are created in MySQL. Any hints guys? Like I was saying, after I get it all ironed out I can write some detailed instructions to contribute to the React/Broadleaf initiative. It's amazing.

An observation

  1. If I do mvn spring-boot:run in the /api, or /admin directory, I get a different set of errors than when running the build configuration in IntelliJ (perhaps I have only the JDBC configured in IntelliJ, but this may be a lead:
2018-10-19 14:32:18.296  WARN 8300 --- [ost-startStop-1] o.a.tomcat.jdbc.pool.PooledConnection    : Not loading a JDBC driver as driverClassName property is null.
2018-10-19 14:32:18.310 ERROR 8300 --- [ost-startStop-1] o.a.tomcat.jdbc.pool.ConnectionPool      : Unable to create initial connections of pool.

java.sql.SQLException: The url cannot be null