Page 1 of 1

Moving to MySQL

Posted: Wed Sep 16, 2015 11:50 pm
by camroe
Hey all, just working through getting the demo running on mysql and am getting

[artifact:mvn] [ WARN] 22:16:13 AbstractEhcacheRegionFactory - HHH020003: Could not find a specific ehcache configuration for cache named [blSandBoxElements]; using defaults.
[artifact:mvn] [ERROR] 22:16:13 SchemaExport - HHH000389: Unsuccessful: alter table BLC_ADDITIONAL_OFFER_INFO drop foreign key FK3BFDBD63B5D9C34D
[artifact:mvn] [ERROR] 22:16:13 SchemaExport - ALTER command denied to user 'xxx'@'localhost' for table 'blc_additional_offer_info'
[artifact:mvn] [ERROR] 22:16:13 SchemaExport - ALTER command denied to user 'xxx'@'localhost' for table 'blc_additional_offer_info'
... and this repeats hundreds of times.

So a couple of things. 1) The obvious thing is that user 'xxx' does not have permissions. Going to mysql I gave myself (I think) all permissions: AM I WRONG ?

mysql> show grants;
+-------------------------------------------------------------------------------------+
| Grants for xxx@localhost |
+-------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'xxx'@'localhost' IDENTIFIED BY PASSWORD <secret> |
| GRANT ALL PRIVILEGES ON `mysql`.`gophergroceries` TO 'xxx'@'localhost' |
| GRANT ALL PRIVILEGES ON `gophergroceries`.`gophergroceries` TO 'xxx'@'localhost' |
+-------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)

2)the first errors are on trying to ALTER a table. Maybe the tables are not created? Correct, they are not created.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| gophergroceries |
| mysql |
| test |
+--------------------+
4 rows in set (0.00 sec)

mysql> connect gophergroceries;
Connection id: 145
Current database: gophergroceries

mysql> show tables;
Empty set (0.00 sec)

So what gives. I know the scripts are being executed ...... but the tables are not being created ...... they were created using the in memory database .... maybe I better check the scripts -> different syntax?
Checking what scripts and where they are we have the line.

blPU.hibernate.hbm2ddl.import_files=/config/bc/sql/load_admin_permissions.sql,\
/config/bc/sql/load_admin_roles.sql,\
/config/bc/sql/load_admin_menu.sql,\
/config/bc/sql/load_menu_admin_security.sql,\
/sql/load_admin_users.sql,\
/sql/load_code_tables.sql,\
/sql/load_i18n_countries.sql,\
/sql/load_table_sequences.sql,\
/sql/load_content_structure.sql,\
/sql/load_catalog_data.sql,\
/sql/load_content_data.sql,\
/sql/load_content_structure_i18n.sql,\
/sql/load_content_data_i18n.sql,\
/sql/load_catalog_i18n_data_FR.sql,\
/sql/load_catalog_i18n_data_ES.sql,\
/sql/load_sitemap_data.sql,\
/sql/load_menu_data.sql

- BUT I can only find the files under the directory sql! there is no config/bc/sql directory in the project! What gives?

As well there is a comment at the top of each file "The Archetype is configured with "hibernate.hbm2ddl.auto" value="create-drop" in "persistence.xml".". I get it and have set the value to create-drop in the development environment properties, but still no joy. In actual fact there is no such file as persitence.xml file - am I supposed to create one? where?

Anyone been through this before?

Thanks!:)

Re: Moving to MySQL

Posted: Sat Sep 19, 2015 2:26 pm
by camroe
So by luck I solved the problem. when checking grants in mysql, I was only granted access from 'localhost' so 'xxx@localhost'. On a whim I set access for '%' (which apparently means any remote node). This solved the issue and I was able to run the site using MySQL and all the tables got created and the site seemed to run fine. Even though I was on the same host - so I don't get what the problem was but this seems to have solved it. (I suspect something like my host name that I was trying to log in from was not being named 'localhost' but instead my computer name so it would not match 'localhost'. Just a guess)
Now on to being able to deploy to a tomcat instance without having to go through Eclipse!
By the way I copied over the mycompany.war and admin.war to tomcat 8 'webapps' directory and launched tomcat but all kinds of errors, mostly to do with resources not being found (JNDI lookup, etc) so back to hunting for instructions on tomcat the required tomcat configuration.... sigh.

Cheers

19-Sep-2015 13:09:24.347 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.broadleafcommerce.common.web.extensibility.M
ergeContextLoader
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in resource loaded from byte array: Cannot resolve reference to bean 'blPersistenceUnitManager' while setting bean
property 'persistenceUnitManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blPersistenceUnitManager': Injection of resource dependencies failed; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'blMergedDataSources' defined in resource loaded from byte array: Cannot resolve reference to bean 'webDS' while setting bean property 'sourceMap
' with key [TypedStringValue: value [jdbc/web], target type [null]]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webDS': Invocation of init method failed; nested excepti
on is javax.naming.NameNotFoundException: Name [jdbc/web] is not bound in this Context. Unable to find [jdbc].