Derby gets stuck closing? - maven-2

I've got unit tests (in maven) that use derby.
At the end of the test run, there is a very long pause, with these log messages before the pause.
INFO: Closing Hibernate SessionFactory
Nov 16, 2009 8:30:31 PM org.hibernate.impl.SessionFactoryImpl close
INFO: closing
Nov 16, 2009 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Nov 16, 2009 8:30:31 PM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Hibernate config:
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="hbm2ddl.auto">create-drop</property>
<property name="show_sql">false</property>
</session-factory>
</hibernate-configuration>
referenced from:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- data source elsewhere -->
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>com/basistech/configdb/dao/Gazetteer.hbm.xml</value>
<value>com/basistech/configdb/dao/FileGazetteer.hbm.xml</value>
<value>com/basistech/configdb/dao/Regexpset.hbm.xml</value>
<value>com/basistech/configdb/dao/Redactjoiner.hbm.xml</value>
<value>com/basistech/configdb/dao/Misc.hbm.xml</value>
</list>
</property>
<property name="configLocation" value="classpath:com/basistech/configdb/dao/hibernate.xml"/>
and finally maven:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>codegen</id>
<goals>
<goal>hbm2java</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<components>
<component>
<name>hbm2java</name>
</component>
</components>
<componentProperties>
<configurationfile>src/main/hibernate/codegen-hibernate.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
</executions>
</plugin>

Could you try with hibernate.connection.autocommit=true? It helped me to solve some problems with the Maven Hibernate3 plugin (see HBX-1145). Not sure it's related though.

I am not sure, if this would still make a difference, but I just thought I'd let you know that I knocked up a derby-maven-plugin a while ago aimed at exactly being able to run tests against a Derby database. You can have a look at the GitHub project here.

Related

Adding Information To JUnit Test Results via tycho-surefire-plugin

The test results of JUnit tests have a properties tag with a bunch of properties. What is logged seems to be at the discretion of each executor of the tests.
I want to process the XML files further, so it would be really nice to have the same keys each time. For maven-surefire-plugin that's pretty straightforward:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<propertyName>propertyValue1</propertyName>
</systemPropertyVariables>
</configuration>
</plugin>
This adds the line <property name="propertyName" value="propertyValue1"/> to the XML result file.
For the tycho-surefire-plugin, I tried the following:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<systemPropertyVariables>
<propertyName>propertyValue1</propertyName>
</systemPropertyVariables>
<systemProperties>
<property>
<name>propertyName</name>
<value>propertyValue2</value>
</property>
</systemProperties>
<argLine>-DpropertyName=propertyValue3</argLine>
</configuration>
</plugin>
...but neither of these values is printed inside the XML result.
How do I add information to the JUnit test results using tycho-surefire-plugin?
The documentation of the tycho-surefire-plugin states that you should use the <systemProperties> map:
<configuration>
<systemProperties>
<propertyName>propertyValue1</propertyName>
</systemProperties>
</configuration>
This will start the forked test JVM with -DpropertyName=propertyValue1.

org.jboss.arquillian.container.spi.ConfigurationException: jbossHome 'null' must exist

I'm getting
org.jboss.arquillian.container.spi.ConfigurationException: jbossHome 'null' must exist
when I try to run my Arquillian test from maven. What should I do?
You can also try to point the required property in arquillian.xml.
For instance in my arquillian.xml:
<?xml version="1.0" encoding="UTF-8"?>
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://jboss.org/schema/arquillian"
xsi:schemaLocation="http://jboss.org/schema/arquillian
http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<container qualifier="jboss" default="true">
<configuration>
<property name="jbossHome">c:\dev\jboss-eap-6.3\</property>
<property name="serverConfig">standalone-test.xml</property>
<property name="javaVmArguments">-Xrunjdwp:transport=dt_socket,address=5505,server=y,suspend=n -Xmx1024m -XX:MaxPermSize=256m</property>
</configuration>
</container>
</arquillian>
You need to set the JBOSS_HOME environment variable pointing to your Jboss/EAP server before running your integration tests. You do it either from command line:
set JBOSS_HOME=c:\jboss-eap-6.4 (on Windows)
export JBOSS_HOME=/home/jboss-eap-6.4 (on Linux)
or set in your pom.xml file:
<build><plugins><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<environmentVariables>
<JBOSS_HOME>c:\jboss-eap-6.4</JBOSS_HOME>
</environmentVariables>
</configuration>
</execution>
</executions>
</plugin></plugins></build>

Can I create classes from schema/sql/and sql queries in mybatis?

I am more a database person than OO (even that I can do). So, I have a database as sql strings, and a lot of queries (also of course the content). I do not, actually, want to "type that down" to an OO model (e.g. class Person int id get/set(int id) etc) - SQL is so quick instead of that. It is a client requirement to use ORM.
Is there a tool that can do that for me? (I would rather write my own parser to do that procedure than to "code" that all). Also, if mybatis can't do it, is there another ORM software that can do so? (any ORM software will do, actually, just that mybatis is said to be lightweight and sql-similar).
You can use Mybatis generator plugin pretty bit simple.
If you are using maven in your project here is basic plugin configuration
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<versionRange>[1.3.2,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>${basedir}/src/main/resources/kp-mybatis-generator.xml</configurationFile>
<outputDirectory>${basedir}/src/main/java</outputDirectory>
<overwrite>true</overwrite>
</configuration>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
And the generator xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<classPathEntry location="C:\down\ojdbc6.jar" />
<context id="kpOracleGens" targetRuntime="MyBatis3Simple">
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:#localhost:1521:KPORACLE" userId="******"
password="******">
</jdbcConnection>
<javaModelGenerator targetPackage="com.kp.swasthik.db.domain"
targetProject="MAVEN">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="false" />
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.kp.swasthik.db.persistence"
targetProject="MAVEN">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER"
targetPackage="com.kp.swasthik.db.mapper" targetProject="MAVEN"
implementationPackage="com.kp.swasthik.db.service">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table tableName="%KPC%" catalog="*" schema="kprasad">
<property name="useActualColumnNames" value="true" />
</table>
<table tableName="FOO" catalog="*" schema="kprasad">
<property name="useActualColumnNames" value="true" />
</table>
</context>
</generatorConfiguration>

Cryptic jetty-maven-plugin error message 'ERROR: PWC6117: File "null" not found'

I have a Maven Webapp producing a WAR file.
I've just upgraded my Jetty plugin to the 7.4.2.v20110526 (from 6.x). I have the following set up:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>7.4.2.v20110526</version>
<executions>
<execution>
<id>jetty-run</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<connectors>
<connector implementation="${connector}">
<port>80</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<webAppConfig>
<contextPath>/foo</contextPath>
</webAppConfig>
<webappDirectory>${project.build.directory}/foo</webappDirectory>
<scanIntervalSeconds>10</scanIntervalSeconds>
<systemProperties>
<systemProperty>
<name>logback.configurationFile</name>
<value>file:${basedir}/target/${project.artifactId}-${project.version}/WEB-INF/classes/logback.xml</value>
</systemProperty>
</systemProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.13</version>
</dependency>
</dependencies>
</plugin>
For some unclear to me reason, I keep getting the cryptic error message below:
2011-07-07 11:51:16.431:WARN::Aliased resource: file:/java/foo/branches/stable/modules/foo-web/src/main/webapp/WEB-INF/jsps/main.jsp~=file:/java/foo/branches/stable/modules/foo-web/src/main/webapp/WEB-INF/jsps/main.jsp
2011-07-07 11:51:16.507:WARN::Aliased resource: file:/java/foo/branches/stable/modules/foo-web/src/main/webapp/WEB-INF/jsps/main.jsp~=file:/java/foo/branches/stable/modules/foo-web/src/main/webapp/WEB-INF/jsps/main.jsp
ERROR: PWC6117: File "null" not found
There is no exception, however I cannot log in to the webapp.
However, if I grab the produced war file and deploy it into a clean Jetty installation, it works perfectly. What's the deal here...? I mean, this used to work with the 6.x plugin. No code changes whatsoever.
The contents of the exploded directory are exactly the same as the ones in the war file - I checked -- there are no missing files or any obvious differences.
This is a Spring Web project.
Any ideas? Has anybody seen this before?
Many thanks in advance!
Make sure your ModelAndView-s are mapped properly in your controller:
return new ModelAndView("WEB-INF/jsps/main");
In my case, above solution #tftd provided did not work so I commented out defaultHandler property, then error log disappeared.
<bean id="classNameControllerMappings"
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<property name="caseSensitive" value="true" />
<property name="order" value="2" />
<!--property name="defaultHandler">
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
</property-->
</bean>
Make sure you have imported org.springframework.web.servlet.ModelAndView. Once i had got this problem by importing org.springframework.web.portlet.ModelAndView.

Ant, Maven and Jdeveloper SOA Extension

We are in the middle of a large Java EE project/programme. Up to this point, we've been using Eclipse and Maven for our development. The appserver we are targeting is WebLogic (Oracle, these days).
It has been decided we are going to start using Oracle Business Rules (Part of Oracle SOA Suite 11g). Development for Soa Suite is confined to JDeveloper. It has some nice ant scripts to build and deploy SOA Composites (which is how rules are packaged and deployed).
I have been tasked with getting these ant scripts to run from maven using antrun, and I've gotten some of the way, but not all...
My main question is: has anyone succeeded doing this? (Has anyone even attempted..? Can't really find anything googling...)
Below is the relevant part of my pom:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<target>
<property name="oracle.home" value="C:\Oracle\Middleware\jdeveloper"/>
<property name="oracle.soa.mgmt.home" value="C:\Oracle\Middleware\jdeveloper"/>
<property name="common.components.home" value="C:\Oracle\Middleware\oracle_common"/>
<property name="env.JAVA_HOME" value="${java.home}"/>
<property name="env.PWD" value="."/>
<ant antfile="${oracle.home}\bin\ant-sca-compile.xml"/>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
Maven is run from the project dir, outside the Oracle/Middleware tree. This almost works...
Actually, it gives the following result:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building BilagorReglerSCA
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [antrun:run {execution: default}]
[INFO] Executing tasks
main:
scac:
Validating composite "C:\JDeveloper\mywork\BilagorReglerSCA\BilagorRegler\composite.xml"
[scac] oracle.fabric.common.wsdl.XSDException: Error loading schema from file:/C:/JDeveloper/mywork/BilagorReglerSCA/BilagorRegler/BilagorRegler_DecisionService.wsdl [Cause=Error in getting XML input stream: oramds:/soa/shared/rules/BpelProcess.xsd: oracle.mds.exception.MDSException: MDS-00054: Filen som ska laddas oramds:/soa/shared/rules/BpelProcess.xsd finns inte.]
[scac] at oracle.fabric.common.wsdl.SchemaBuilder.loadEmbeddedSchemas(SchemaBuilder.java:496)
[scac] at oracle.fabric.common.wsdl.SchemaBuilder.loadSchemasFromWSDL(SchemaBuilder.java:365)
...
The phrase "Filen som ska laddas oramds:/soa/shared/rules/BpelProcess.xsd finns inte." means the "file you are trying to load does not exist" (why does my client insist on installing Swedish language version of Windows, rather than international?).
ant-sca-compile.xml contains numerous import statements similar to this:
<fileset dir="${common.components.home}/modules">
...
<include name="oracle.mds_11.1.1/oramds.jar"/>
I assume oramds.jar is needed to process oramds-URL:s, which are used in the WSDS/XSD:s JDeveloper generates.
Any help appreciated...
OK, so I eventually got a chance to sit down with an ace Oracle consultant and get this to work.
This is what we came up with:
<properties>
<oracle.fmw.soa.home>C:/Oracle/Middleware</oracle.fmw.soa.home>
<!-- this is relative reference to JDK / Jrockit from ant-sca-compile|*.xml. For jdev it is ../../, for Soa Suite: TBD. -->
<env.JAVA_HOME>../../jdk160_24</env.JAVA_HOME>
<!-- For real server with Soa Suite installed use: Oracle_SOA1, for devenv use jdeveloper -->
<oracle.fmw.productName>jdeveloper</oracle.fmw.productName>
<antOutputDir>deploy</antOutputDir>
<mvnOutputDir>target</mvnOutputDir>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sca-compile</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="scac.input" value="${basedir}/composite.xml" />
<property name="scac.application.home" value="${basedir}/.." />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-compile.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/"
target="scac" />
</target>
</configuration>
</execution>
<execution>
<id>sca-package</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="package">
<property name="build.compiler" value="extJavac" />
<property name="compositeName" value="${project.artifactId}" />
<property name="compositeDir" value="${basedir}" />
<property name="revision" value="${project.version}" />
<property name="scac.application.home" value="${basedir}/.." />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<property name="antOutputFile" value="sca_${project.artifactId}_rev${project.version}.jar" />
<property name="mvnOutputFile" value="${project.artifactId}-${project.version}.jar" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-package.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="package" />
<copy tofile="${mvnOutputDir}/${mvnOutputFile}" file="${antOutputDir}/${antOutputFile}" />
</target>
</configuration>
</execution>
<execution>
<id>sca-deploy</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target name="deploy">
<property name="serverURL" value="${weblogic.serverURL}" />
<property name="user" value="${weblogic.user}" />
<property name="password" value="${weblogic.password}" />
<property name="sarLocation" value="${basedir}/deploy/sca_${project.artifactId}_rev${project.version}.jar" />
<property name="overwrite" value="true" />
<property name="forceDefault" value="true" />
<property name="partition" value="default" />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-deploy.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="deploy" />
</target>
</configuration>
</execution>
<execution>
<id>sca-test</id>
<phase>deploy</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="jndi.properties.input" value="${basedir}/sca-test.jndi.properties" />
<property name="scatest.input" value="scatestinput" />
<property name="scatest.format" value="junit" />
<property name="scatest.result" value="reports" />
<property name="oracle.home" value="${oracle.fmw.soa.home}/${oracle.fmw.productName}" />
<ant
antfile="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin/ant-sca-test.xml"
dir="${oracle.fmw.soa.home}/${oracle.fmw.productName}/bin"
target="test" />
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Note, both different sets of properties and parameters to the ant-tag than what I was originally attempting with.
To run on a CI-server, you obviously need a local install of JDeveloper or SOA Suite. weblogic.serverURL, weblogic.user and weblogic.password needs to be set to your corresponding environment (I use profiles for local/dev/tst/etc...).
Other than that, it works like a charm...
I've not used Maven + Oracle SOA build scripts but generally when using any of the Oracle deployment tools (ADF, SOA, etc) you will need to have either an Oracle SOA Home or a JDev home (with the SCA extension) on the same machine that the build is running on. You'll need to set the Ant environment variables correctly e.g. oracle.home and common.components.home etc
Use ant-sca-package.xml (not ant-sca-compile.xml):
<ant antfile="ant-sca-package.xml" dir="${env.BEA_HOME}/jdeveloper/bin">
<property name="compositeDir" value="#{compositeDir}" />
<property name="compositeName" value="#{compositeName}" />
<property name="revision" value="${deploy.revision}" />
</ant>