Page 1 of 1
build-sql ant target
Posted: Thu Dec 06, 2012 6:32 pm
by felixnutella
Hello
I'm wondering how this target is supposed to work. From the description I would think that it would create a complete schema for use when "bootstrapping" a new database, but for some reason it fails with an exception. The error is UnsupportedOperationException - The user must supply a JDBC connection....
Anyone have an idea if it can be used to create the schema or if I am better of just leaving it alone
Regards,
Svend
Re: build-sql ant target
Posted: Fri Dec 07, 2012 1:02 pm
by ktisdell
Which version of BLC are you using? This should work as you describe, without the need for a database connection. That said, I ran into this issue about a month ago as well, and it may be a bug in an older version of BLC. This ant task causes the BLC merge process to happen, allowing all entities to be available to the persistence unit for introspection. This merge process causes Spring's application context lifecycle to be invoked. We added a lifecycle event to Broadleaf that reads the database on startup (unrelated to this ant task). Of course, this will cause a problem if no database exists, as is the case here. We fixed this in version 2.1, I believe. Can you let me know which version you are having trouble with?
My guess is the best way to fix this is to create a new ant-applicationContext.xml file (not one that you will actually reference in your application). This is for the ant task only. Put it on your classpath. Add the following bean definition to it:
<bean id="blSequenceGeneratorCorruptionDetection" class="java.lang.Object"/>
Then modify your build.xml file:
Under the build-sql ant task, try adding the following:
<classPathApplicationContext path="ant-applicationContext.xml"/>
What this should do is cause the ant task to include your ant-applicationContext.xml file in the Broadleaf merge process, overriding the blSequenceGeneratorCorruptionDetection bean with a plain object that does not implement ApplicationListener, and will therefore not be invoked as part of Spring's Application Context Lifecycle events.
Hope this helps.
Re: build-sql ant target
Posted: Fri Dec 07, 2012 5:37 pm
by felixnutella
Hi - and thank U for the reply..
I will try your suggestion and get back to you. But I can tell you already now (I'm fast) that I'm using version 2.0.1-GA
Regards,
Svend
Re: build-sql ant target
Posted: Tue Feb 12, 2013 1:00 pm
by TNuzzi
I am also having an issue with this using the latest version of the Demo project from github. I followed the steps to enable a local version of MySQL and then ran the "build-create-sql" script. The script said it succeeded but no tables were create in MYSQL.
Any thoughts?
Thanks,
Tony
Re: build-sql ant target
Posted: Tue Feb 12, 2013 1:12 pm
by phillipuniverse
This will not modify your database at all, but rather will create SQL import scripts in target/sql/create (or target/sql/update if you are running build-update-sql).
Re: build-sql ant target
Posted: Tue Feb 12, 2013 1:15 pm
by TNuzzi
Thanks for the clarification.