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>
Related
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>
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>
I'd like to be able to filter filenames as well as file contents in Maven.
The below snippet enables filtering on file contents, but I need to be able to rename files too.
The usage scenario is that I'd like all static resources in my webapp to be numbered, so they can be treated as different versions by Amazon's CloudFront. Naturally managing the numbers manually would be impractical, so I'd like the build process to do this.
For instance a file called
logo_VERSION.jpg
would end up being called
logo_254.jpg
Any ideas if this is possible without writing a custom plugin?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>/src/main/webapp</directory>
<filtering>true</filtering>
</resource>
</webResources>
...
I've done something similar using the antrun plugin - sometimes you just have to drop back into ant.
pom snippet
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<property name="project.version" value="${project.version}"/>
<property name="all.environs" value="DEV1,DEV2,DEV3,DEV4,UAT,PROD"/>
<property name="application.environments"
value="${application.environments}" />
<ant antfile="${basedir}/build.xml" target="setup" />
<ant antfile="${basedir}/build.xml" target="build"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
build.xml
<property name="ant-contrib-jar" value="${user.home}/.ant/lib/ant-contrib-1.0b3.jar"/>
<target name="setup" unless="ant-contrib.present">
<echo>Getting ant-contrib</echo>
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${ant-contrib-jar}"
src="http://nexus.inhouse.com:8081/nexus/content/repositories/central/ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</target>
<target name="taskdefs">
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${ant-contrib-jar}"/>
</classpath>
</taskdef>
</target>
<target name="build" depends="taskdefs">
<echo message="basedir: ${basedir}"/>
<echo message="project.version: ${project.version}"/>
<foreach list="${application.environments}" target="jar-resources" param="app.env" trim="true">
<param name="basedir" value="${basedir}" />
<param name="project.version" value="${project.version}" />
</foreach>
</target>
<target name="jar-resources">
<mkdir dir="${basedir}/target/${app.env}"/>
<copy todir="${basedir}/target/${app.env}">
<fileset dir="${basedir}/src/main/resources">
<include name="mail_config.properties"/>
<include name="service.properties"/>
</fileset>
</copy>
<filterset id="applicationFilterSet">
<filtersfile file="${basedir}/src/main/filters/filter-${app.env}.properties"/>
<filter token="PROJECT.VERSION" value="${project.version}"/>
</filterset>
<copy file="${basedir}/src/main/resources/coresystem.properties"
tofile="${basedir}/target/${app.env}/coresystem.properties.${app.env}">
<filterset refid="applicationFilterSet"/>
</copy>
<copy file="${basedir}/src/main/resources/extraProps.properties"
tofile="${basedir}/target/${app.env}/extraProps_${app.env}.properties">
<filterset refid="applicationFilterSet"/>
</copy>
<jar destfile="${basedir}/target/MyApp-env-${project.version}-${app.env}.jar"
basedir="${basedir}/target/${app.env}" />
</target>
In my Maven build, I use the antrun plugin to invoke an ant task.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true" failonerror="true">
<classpath>
<pathelement path="${plugin_classpath}" />
</classpath>
</java>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<!-- DEPENDENCIES FROM PROJECT DUPLICATED HERE -->
</dependencies>
</plugin>
I need to duplicate all the project dependencies in the section indicated, so that they are available to the ant task. Is there a way to avoid this duplication, by referring to the project's dependencies instead of copy-pasting them?
Here's how you can do it:
<property name="plugin_classpath" refid="maven.plugin.classpath" />
<property name="compile_classpath" refid="maven.compile.classpath" />
<java classname="org.apache.tools.ant.launch.Launcher"
fork="true" failonerror="true">
<classpath>
<pathelement path="${plugin_classpath}" />
<pathelement path="${compile_classpath}" />
</classpath>
</java>
Reference:
Maven Antrun Plugin > Referencing the Maven Classpaths
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.