Page 1 of 1

Broadleaf default database is being restored

Posted: Wed May 28, 2014 1:57 am
by anandc8788
Hello Folks,

Greetings !

I'm new to broadleafcommerce and facing below Issue, could you please log your views/suggestions ? Thanks!

Issue - Database is being restored after every time I restart eclipse.

While executing, I am just launching the site using jetty-demo.

Regards,
Anand Chavan

--

Here is my build file (Path \eclipse-workspace\DemoSite ) -

<?xml version="1.0" encoding="UTF-8"?>
<project name="!BroadleafDemoTools" default="change-identifier" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">

<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>

<target name="change-identifier">
<input message="Enter in new maven group (e.g. com.mycompany). Also note that this may only be run once." defaultvalue="com.mycompany" addproperty="maven-group" />

<propertyregex property="maven-group-clean"
input="${maven-group}"
regexp="([^A-Za-z\.])*"
replace=""
global="true" />

<propertyregex property="company-name"
input="${maven-group-clean}"
regexp="[\w]+\.([^\.]*)"
select="\1"
casesensitive="false" />

<propertyregex property="company-tld"
input="${maven-group-clean}"
regexp="([\w]+)*"
select="\0"
casesensitive="false" />

<fail message="Bad input">
<condition>
<not>
<isset property="company-name" />
</not>
</condition>
</fail>

<input message="New maven-group: ${maven-group}, new company-name: ${company-name} -- Continue?" addproperty="continue" validargs="y,n" defaultvalue="y" />

<if>
<equals arg1="${continue}" arg2="y" />
<then>
<echo message="${maven-group}" />
<echo message="${company-name}" />
<!-- Move the required files / directories to their new homes -->
<move file="site/src/main/java/com/mycompany" tofile="site/src/main/java/${company-tld}/${company-name}" />
<move file="core/src/main/java/com/mycompany" tofile="core/src/main/java/${company-tld}/${company-name}" />
<!-- Replace the appropriate tokens -->
<replace file="pom.xml" token="com.mycompany" value="${maven-group}" summary="yes" excludes="target/" />
<replace dir="admin" token="com.mycompany.gwt.mycompanyAdmin" value="${maven-group}.gwt.${company-name}Admin" summary="yes" excludes="target/" />
<replace dir="admin" token="mycompany-admin" value="${company-name}-admin" summary="yes" excludes="target/" />
<replace dir="admin" token="com.mycompany" value="${maven-group}" summary="yes" excludes="target/" />
<replace dir="core" token="com.mycompany" value="${maven-group}" summary="yes" excludes="target/" />
<replace dir="site" token="com.mycompany" value="${maven-group}" summary="yes" excludes="target/" />
<replace dir="site" token="mycompany-site" value="${company-name}-site" summary="yes" excludes="target/" />
<replace dir="site" token="target/mycompany" value="target/${company-name}" summary="yes" excludes="target/" />
<replace file="site/src/main/webapp/WEB-INF/web.xml" token="mycompany" value="${company-name}" summary="yes" excludes="target/" />
<replace file="site/pom.xml" token="mycompany" value="${company-name}" summary="yes" excludes="target/" />
</then>
</if>
</target>

</project>

=========================================================================

build file 2 ( path - \eclipse-workspace\DemoSite\site )

<?xml version="1.0" encoding="UTF-8"?>
<project name="site" default="build-app" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">

<!-- import the ant / maven integration tasks -->
<path id="maven-ant-tasks.classpath" path="../lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />

<property name="project.root" location="../../"/>
<property name="project.name" value="site" />

<!-- See the following URL for a description of this property file strategy -->
<!-- The only difference is we prepend a . for the home directory property files -->
<!-- http://www.javaranch.com/ant/properties.jsp -->
<property file="${user.home}/.${project.name}.properties"/>
<property file="${user.home}/.build.properties"/>
<property name="config.filename" value="${user.name}.properties"/>
<property file="config/${config.filename}"/>
<property file="../build.properties"/>

<property name="runtime.environment" value="development"/>

<target name="jetty-demo-no-db">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>

<target name="jetty-demo" depends="start-db">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>

<target name="jetty-demo-jrebel" depends="start-db">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
<jvmarg value="-Drebel.root=${project.root}" />
<jvmarg value="-Dlogs.dir=${logs.dir}" />
<jvmarg value="-noverify" />
<jvmarg value="-javaagent:${jrebel.path}" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>

<target name="jetty-stop">
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<arg value="jetty:stop"/>
</artifact:mvn>
</target>

<target name="stop-all" depends="jetty-stop, stop-db"/>

<!-- Project Reference Targets -->
<!-- build the application and create the war artifact -->
<target name="build-app">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<arg value="-Dmaven.test.skip=true"/>
<arg value="install"/>
</artifact:mvn>
</target>

<target name="start-db">
<!-- Grab the HSQLDB jar and add it to the classpath -->
<artifact:dependencies filesetId="warDeps">
<dependency groupId="org.hsqldb" artifactId="hsqldb" version="2.3.1" />
</artifact:dependencies>
<path id="build.runtime.classpath">
<fileset refid="warDeps"/>
</path>

<echo message="Starting Data Base..." />
<java fork="true" spawn="true" classname="org.hsqldb.Server" classpathref="build.runtime.classpath">
<arg line="-database.0 file:data/broadleaf -dbname.0 broadleaf"/>
</java>
</target>

<target name="stop-db">
<echo message="Execute SQL on new Data Base..." />
<!-- Grab the HSQLDB jar and add it to the classpath -->
<artifact:dependencies filesetId="warDeps">
<dependency groupId="org.hsqldb" artifactId="hsqldb" version="2.3.1" />
</artifact:dependencies>
<path id="build.runtime.classpath">
<fileset refid="warDeps"/>
</path>
<sql
autocommit="true"
print="true"
classpathref="build.runtime.classpath"
driver="org.hsqldb.jdbcDriver"
url="jdbc:hsqldb:hsql://localhost/broadleaf;ifexists=true"
userid="sa"
password="">
<transaction>SHUTDOWN</transaction>
</sql>
<echo message="SQL Executed on data base..." />
</target>

</project>


=========================================================================

build file 3 ( path - \eclipse-workspace\DemoSite\admin )

<?xml version="1.0" encoding="UTF-8"?>
<project name="admin" default="build-app" basedir="."
xmlns:artifact="antlib:org.apache.maven.artifact.ant"
xmlns:rsel="antlib:org.apache.tools.ant.types.resources.selectors">

<!-- import the ant / maven integration tasks -->
<path id="maven-ant-tasks.classpath" path="../lib/maven-ant-tasks-2.1.3.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml" uri="antlib:org.apache.maven.artifact.ant" classpathref="maven-ant-tasks.classpath" />

<property name="project.root" location="../../"/>
<property name="project.name" value="admin" />

<!-- See the following URL for a description of this property file strategy -->
<!-- The only difference is we prepend a . for the home directory property files -->
<!-- http://www.javaranch.com/ant/properties.jsp -->
<property file="${user.home}/.${project.name}.properties"/>
<property file="${user.home}/.build.properties"/>
<property name="config.filename" value="${user.name}.properties"/>
<property file="config/${config.filename}"/>
<property file="../build.properties"/>

<property name="runtime.environment" value="development"/>

<target name="jetty-demo">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true" >
<jvmarg value="-XX:MaxPermSize=512M" />
<jvmarg value="-Xmx1024M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>

<target name="jetty-demo-jrebel">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n" />
<jvmarg value="-Drebel.root=${project.root}" />
<jvmarg value="-Dlogs.dir=${logs.dir}" />
<jvmarg value="-noverify" />
<jvmarg value="-javaagent:${jrebel.path}" />
<jvmarg value="-javaagent:${spring.instrument.path}" />
<jvmarg value="-Druntime.environment=${runtime.environment}" />
<arg value="compile"/>
<arg value="war:exploded"/>
<arg value="jetty:run"/>
</artifact:mvn>
</target>

<target name="jetty-stop">
<artifact:mvn mavenHome="${maven.home}" fork="true" >
<jvmarg value="-XX:MaxPermSize=256M" />
<jvmarg value="-Xmx512M" />
<arg value="jetty:stop"/>
</artifact:mvn>
</target>

<!-- Project Reference Targets -->
<!-- build the application and create the war artifact -->
<target name="build-app">
<delete dir="war/WEB-INF/lib"/>
<artifact:mvn mavenHome="${maven.home}" fork="true">
<arg value="-Dgwt.logLevel=DEBUG"/>
<arg value="-Dgwt.compiler.strict=true"/>
<arg value="-Dmaven.test.skip=true"/>
<arg value="gwt:compile"/>
<arg value="install"/>
</artifact:mvn>
</target>
</project>

Re: Broadleaf default database is being restored

Posted: Wed May 28, 2014 2:03 pm
by phillipuniverse
This is because of the values in site/src/main/resources/development.properties:


Code: Select all

blPU.hibernate.hbm2ddl.auto=create-drop


This will create the database and run the SQL import on startup and drop the entire database on shutdown. See viewtopic.php?f=15&t=2215&hilit=ddl&start=10.

Re: Broadleaf default database is being restored

Posted: Wed May 28, 2014 2:36 pm
by anandc8788
Thanks for your inputs phillipuniverse !!!