Hi,
I hope some can help.
I tried to setup a production profile as Marin Homik previous maven settings
in this thread but I get an exception:
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Full exception:
------------------
[INFO] Preparing hibernate3:hbm2ddl
[WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive
invocation.
[INFO] [aspectj:compile {execution: default}]
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.
[INFO] [hibernate3:hbm2ddl {execution: default}]
[INFO] src/main/resources/hibernate.cfg.xml not found within the project.
Trying absolute path.
[INFO] No hibernate configuration file loaded.
[INFO] Configuration Properties file loaded:
E:\Development\giftmanager\core\target\test-classes\jdbc.properties
ERROR - SchemaExport.execute(202) | schema export unsuccessful
java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost/mydatabase?createDatabaseIfNotExist=true&useUn
at java.sql.DriverManager.getConnection(DriverManager.java:602)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
at
org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at
org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:28)
at
org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180)
at
org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
at
org.codehaus.mojo.hibernate3.exporter.Hbm2DDLExporterMojo.doExecute(Hbm2DDLExporterMojo.java:112)
at
org.codehaus.mojo.hibernate3.HibernateExporterMojo.execute(HibernateExporterMojo.java:140)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[WARNING] 1 errors occurred while performing <hbm2ddl>.
[ERROR] Error #1: java.sql.SQLException: No suitable driver found for
jdbc:mysql://localhost/mydatabase?createDatabaseIfNotEx
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [dbunit:operation {execution: default}]
[INFO]
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO]
------------------------------------------------------------------------
[INFO] Error executing database operation: CLEAN_INSERT
Embedded error: com.mysql.jdbc.Driver
[INFO]
------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error executing
database operation: CLEAN_INSERT
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:583)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:499)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:478)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:330
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:291)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:142)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:336)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:129)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:287)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Error executing
database operation: CLEAN_INSERT
at
org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:110)
at
org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:451)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:558)
... 16 more
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at
org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
at
org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
at
org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
at
org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at
org.codehaus.mojo.dbunit.AbstractDbUnitMojo.createConnection(AbstractDbUnitMojo.java:159)
at
org.codehaus.mojo.dbunit.OperationMojo.execute(OperationMojo.java:93)
... 18 more
[INFO]
------------------------------------------------------------------------
------------------
Following resides in my root pom.xml file (what is wrong ?):
<!-- ================= Production Settings Profile
========================== -->
<!-- Use "-P prod" when you want to run production mode
-->
<!-- This profile skips hibernate3, dbunit repopulation and the test
plugins. -->
<!--
======================================================================== -->
<profiles>
<profile>
<id>prodx</id>
<!--<activation>
<activeByDefault>true</activeByDefault>
</activation>-->
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>dbunit-maven-plugin</artifactId>
<version>1.0-beta-1</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.0-alpha-2</version>
<configuration>
<components>
<component>
<name>hbm2doc</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2ddl</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
<componentProperties>
<drop>false</drop>
<export>true</export>
<outputfilename>schema.sql</outputfilename>
<propertyfile>web/target/classes/jdbc.properties</propertyfile>
<skip>true</skip>
</componentProperties>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<dbunit.dataTypeFactoryName>org.dbunit.dataset.datatype.DefaultDataTypeFactory</dbunit.dataTypeFactoryName>
<dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
<hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>
<jdbc.groupId>mysql</jdbc.groupId>
<jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
<jdbc.version>5.0.5</jdbc.version>
<jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
<jdbc.url><![CDATA[jdbc:mysql://localhost/mydatabase?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8]]></jdbc.url>
<jdbc.username>user</jdbc.username>
<jdbc.password>pass</jdbc.password>
</properties>
</profile>
</profiles>
Martin Homik wrote:
>
> Change the the default database to hsqldb in the end of the pom:
>
>
> <!-- Database settings -->
> <dbunit.dataTypeFactoryName>org.dbunit.ext.hsqldb.HsqldbDataTypeFactory</dbunit.dataTypeFactoryName>
> <dbunit.operation.type>CLEAN_INSERT</dbunit.operation.type>
> <hibernate.dialect>org.hibernate.dialect.HSQLDialect</hibernate.dialect>
> <project.tmpdir>tmp</project.tmpdir>
> <jdbc.groupId>hsqldb</jdbc.groupId>
> <jdbc.artifactId>hsqldb</jdbc.artifactId>
> <jdbc.version>1.8.0.7</jdbc.version>
> <jdbc.driverClassName>org.hsqldb.jdbcDriver</jdbc.driverClassName>
> <jdbc.url><![CDATA[jdbc:hsqldb:tmp/someDB;shutdown=true]]></jdbc.url>
> <jdbc.username>sa</jdbc.username>
> <jdbc.password></jdbc.password>
>
> Add a profile for production use, such as:
>
> <!-- ================= Production Settings Profile ================= -->
> <!-- Use "-P prod" when you want to run production mode -->
> <!-- =============================================================== -->
> <profile><id>prod</id>
> <build>
> <plugins>
> <plugin>
> <artifactId>maven-surefire-plugin</artifactId>
> <configuration>
> <skip>true</skip>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>dbunit-maven-plugin</artifactId>
> <version>1.0-beta-1</version>
> <configuration>
> <skip>true</skip>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>hibernate3-maven-plugin</artifactId>
> <version>2.1</version>
> <configuration>
> <components>
> <component>
> <name>hbm2ddl</name>
>
> <implementation>annotationconfiguration</implementation>
> </component>
> </components>
> <componentProperties>
> <drop>false</drop>
> <jdk5>true</jdk5>
>
> <propertyfile>target/classes/jdbc.properties</propertyfile>
> <skip>true</skip>
> </componentProperties>
> </configuration>
> </plugin>
> </plugins>
> </build>
> <properties>
> <jdbc.groupId>mysql</jdbc.groupId>
> <jdbc.artifactId>mysql-connector-java</jdbc.artifactId>
> <jdbc.version>5.0.5</jdbc.version>
>
> <hibernate.dialect>org.hibernate.dialect.MySQL5InnoDBDialect</hibernate.dialect>
>
>
> <jdbc.driverClassName>com.mysql.jdbc.Driver</jdbc.driverClassName>
>
> <jdbc.url><![CDATA[jdbc:mysql://localhost/db_prod?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf-8]]></jdbc.url>
> <jdbc.username>someone</jdbc.username>
> <jdbc.password>something</jdbc.password>
> </properties>
> </profile>
>
>
> This profile skips hibernate3, dbunit repopulation and the test plugins.
>
> Hope, that helps.
>
> Martin
>
>
>
>
> Tarjei Huse wrote:
>>
>> Hi, I'm using Appfuse with hibernate and I want to run my
>> unit/integration tests in HSQLDB (or a different in-memory database) but
>> use mysql for my production environment as well as my staging
>> environment.
>>
>> Basically:
>> Run the test phase using HSQLDB, but switch to using mysql for mvn
>> jetty:run-war or mvn war -> but then with different username/password
>> configurations.
>>
>> I would guess this is a quite common pattern, so how should it be done?
>>
>> I've found some pointers, but I am not completely satisfied with them:
>> [1] shows how to configure Appfuse to use HSQLDB, but I cannot find where
>> the xml fragments should go. Also [2] discusses how to do this using
>> different profiles.
>>
>> 1. http://thread.gmane.org/gmane.comp.java.appfuse.user/20476
>> 2. http://thread.gmane.org/gmane.comp.java.appfuse.user/28929/focus=29007
>>
>> It seems to me that the best way would be if different profiles could be
>> activated for different phases (test, jetty:run-war) but that seems to me
>> not to be possible.
>>
>> So, what is the best way to do this?
>>
>> Kind regards,
>> Tarjei
>>
>>
>>
>>
>
>
--
View this message in context:
http://www.nabble.com/Separate-database-settings-for-testing%2C-staging-and-production-tp19586169s2369p25495270.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]