Building docker image for multi module project pushing jars to classpath - dockerfile

I am trying to create docker image for my project which is having multiple modules. The need is to build the image in such a way that the image should contain the child module jar in a given classpath. The structure of my project is
parent_project
|
|
module-1
|
pom.xml
|
module-2
|
pom.xml
|
pom.xml
So ideally when the build happens it the image should have a classpath where both modules jar are to be present. But with the below given pom.xml I am seeing the images when build are overwritten with latter build. So one image is build with first module jar and second image is formed with second module jar thus final image contains only the later jar.
part of pom.xml
<modules>
<module>xxxxxxxxx_m1</module>
<module>xxxxxxxxx_m2</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>1.8.0</version>
<configuration>
<from>
<image>xxxyyyy****_base_image</image>
</from>
<container>
<entrypoint>INHERIT</entrypoint>
<appRoot>/etc/plugin</appRoot>
<environment>
<CLASSPATH>
/etc/plugin/classpath/xxxxxxxxx_m1-SNAPSHOT.jar
/etc/plugin/classpath/xxxxxxxxx_m2-SNAPSHOT.jar
</CLASSPATH>
</environment>
</container>
<containerizingMode>packaged</containerizingMode>
</configuration>
</plugin>
</plugins>
</build>
I am building the image by providing following command :-
mvn package jib:build -Dimage=<base_image>:<tag_name>

Your project setup makes sense only when each of the two modules xxxxx_m1 and xxxxx_m2 is a standalone app that has its own main class and can run independently of each other, each with
java -cp <xxxxx_m1-SNAPSHOT:others...> <main class in xxxxx_m1>
java -cp <xxxxx_m2-SNAPSHOT:others...> <main class in xxxxx_m2>
That is, the setup makes sense only when you intend to create two separate and independent images for two different apps. In this case, Jib is working as intended and you are producing two different container images. It's just that by saying -Dimage (equivalent to -Djib.to.image), you are giving the same target image name for the two images, so one ends up overwriting the other in the end, which doesn't make sense. If this is really the case, you just need to define <to><image> differently in each module. (You can have <pluginManagement> in the root pom.xml to declare Jib version and common Jib <configuration>, and then define module-specific Jib <configuration> in each sub-module pom.xml. I will point you to an example at the end, so keep reading.)
But I am not sure if this is what you intended, because it sounds like you want to see both modules inside a single image. Perhaps it's that _m2 is the app with a main class and _m1 is a JAR library that _m2 depends on? (That is, pom.xml in _m2 defined _m1 as a dependency?) In this case,
root pom.xml: define <pluginManagement> to declare the Jib version
_m1 pom.xml (dependency library): set <skip>true to suppress Jib image building
_m2 pom.xml: optionally define _m2-specific configuration
Take a look at this multi-module example. It has three modules, where Jib runs in hello-service and name-service to build two images, while name-service defines the shared-library module as a dependency.
In either case, I don't see a reason to set <containerizingMode>packaged or <environment><CLASSPATH> unless your app is specifically written to read the environment variable or requires to run inside a JAR (e.g., need to read JAR manifest). The default "exploded" containerizing mode is much more efficient, so just try running Jib without these.

Related

How to skip resolving dependencies of a specific configuration in Ivy?

I have the following problem:
My project (C++) has a dependency to a system library. For that purpose I define in the ivy.xml file a new section within dependencies like this:
<ivy-module version="2.0">
<info organisation="org.acme" module="mymodule">
<configurations>
<conf name="system"/>
</configurations>
[...]
<dependencies>
<dependency name="pthread" rev="*" conf="system"/>
</dependencies>
</ivy>
The problem I am facing is that Ivy tries to resolve the dependency to pthread before publishing mymodule.
The command use for publishing is the following:
java -jar ivy.jar -debug -ivy ivy.xml -publish publish -publishpattern "<ivy-pattern>" -status integration -revision 0.0.1-SNAPSHOT -settings ivysettings.xml -overwrite
I checked the Ivy documentation but cannot find any hint on how to tell Ivy to skip resolving dependencies for a specific configuration.
Has one of you guys maybe a hint or an idea how to configure that?
Thanks a lot in advance.
UPDATE:
I managed to exclude the dependency for a specific configuration by using the following dependencies tag:
<dependencies>
<dependency name="pthread" rev="*" conf="system"/>
<exclude conf="system"/>
</dependencies>
In order to do this you must provide ogranisation, module and revision which is needed for publish task. There reason is that if this is not provided publish will look for it in last resolved module (check the publish task for the attributes).
So when you call publish task, it will require either providing all of these attributes, or call to resolve task beforehand. The attributes that are needed are:
pubrevision
artifactspattern
organisation
module
revision
srcivypattern
You can check the link to see which one is what, even thought it's pretty self explanatory.
Now I don't know how(or if at all) you cann pass all these paramaters when calling ivy as a jar. Maybe use ivyfile as listed here. That's why I gave the answer on how to do it with ant task - well that and because it's usually cleaner and easier to use ivy with ant :)

How to exclude specific unit tests from default "maven test" and eclipse "run as junit test"

In my code I have 2 types of tests: fast unit tests and slow performance tests. I am trying to ensure that the performance tests are never run unless the user explicitly wants to run them (e.g. using the right test suite or maven build profile) because this kicks of a remote process that is computationally-intensive on a grid.
I understand how to create build profiles that exclude (or include) specific tests using maven-surefire-plugin as explained on this site. The problem I have, however, is that I have not found a way to exclude tests from the default run while still providing the option to run the test when needed. By default run I mean:
Right click on the project in eclipse and selects "run as| Maven test"
Right click on src/test/java and select run as junit test
In both cases above it runs all the unit tests (include the slow tests I hope to exclude by default). The same thing happens if there is a typo in the build profile I try to run.
Is there a way I can excluse performance tests from the default run without having to move them to a separate maven module?
What we have done in our projects is to mark the slow unit tests with a special marker interface.
#Cathegory(SlowTest.class) annotation and add them to the failsafe plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<groups>com.whatever.SlowTest</groups>
</configuration>
<executions>
<execution>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
If you don't want to execute them: use the maven option -DskipITs. This will skip them.
Using profiles you can make one active by default that excludes your slow tests and use another one to run all tests.
You have to specify those tags in your fastTestOnly profile :
<profiles>
<profile>
<id>fastTestOnly</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
...
</profile>
</profiles>
This way, when you run a simple mvn install only the profile picked is fastTestOnly.
The native Junit case of your question can AFAIK only be kind of solved by keeping different tests in different source folders (or packages) and go to the run configuration at "Run all tests in ..." and limit the tests to run according to the specific source folder (or package).
I know of no versatile way to make that in a general way, but it's not too burdensome to make a new run configuration set per project (by duplicating an existing one) and remove those that are no longer relevant.

How to consume Amazon SWF [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
Amazon SWF was launched today. How best to consume it with Java / PHP / etc. ?
The current SDK support doesn't appear to include it. I know it's new, but does anyone have any good resources on how to consume it, or what changes I'd need to implement in the any of the following SDK's to get going right away?
AWS SDK for Java
AWS SDK for PHP
AWS SDK for Python
AWS SDK for Ruby
AWS SDK for .NET
Personally, my interest is on the Java & PHP SDK's...
Updated releases are visible at: http://aws.amazon.com/releasenotes Thanks Bjorn!
I'm using Amazon Simple Workflow Service (SWF) to implement asynchronous business processing using the AWS Flow Framework. It was important to me to have my development build setup using Maven, so that I could easily build from my IDE of choice (IntelliJ IDEA) as well as automate my test builds for continuous integration and production builds for release and deploy.
Most of my time was spent trying to get the auto-generated proxy classes created using AspectJ. This was initially a problem for me in Eclipse as I was using version 3.7 (Indigo) and even after following both the load-time and compile-time weaving instructions in the Setting up the Development Environment documentation I was unable to successfully get the classes blown out. On a hunch I remembered that the documentation says they used Eclipse 3.6 (Helios), so I downloaded this specific version of Eclipse and retried using the load-time weaving approach and it worked like a champ. Looking at the Eclipse logs between these two versions I was able to see that Eclipse 3.7 is missing a dependency for log4j and freemarker. I didn't bother going too far down the road to troubleshoot this further with Eclipse as I'm more of an IntelliJ IDEA user, but I'm sure that it's most definitely possible to get Eclipse working properly.
My next effort was to get an IntelliJ IDEA Maven project up and running with the minimum amount of information in my pom.xml to enable the auto-generation of the proxy classes. The clue was the last paragraph of the instructions for load-time weaving in the Setting up the Development Environment documentation, which states:
If you are building your project from the command line, ensure that
aws-java-sdk-flow-build-tools-1.3.3.jar is in the classpath. This jar
file contains the AWS Flow Framework annotation processor that must be
run to generate code. For an example, see the build.xml file included
in the samples folder.
Unless I'm mistaken, the research I've done to date indicates that the aspectj-maven-plugin doesn't not currently support load-time weaving. Breaking away from doing load-time weaving and utilizing an aop.xml file in conjunction with aspectjweaver running as a Java agent, I moved to compile-time weaving supported by this plugin. I can't help but think that when I installed the AWS SDK for Java support directly in Eclipse that it in turn baked in the support found in the aws-java-sdk-flow-build-tools-1.3.3.jar dependency. Taking the aforementioned clue, I was finally able to get the proxy classes blowing out by including a dependency for aws-java-sdk-flow-build-tools-1.3.3.jar in my pom.xml after installing this JAR into my local Maven repository. The rest of this entry outlines the steps taken to make this all happen.
IntelliJ IDEA Project Creation
Start the IntelliJ IDEA application.
Create a New Project.
Input the Project name and Project files location.
Select type should be Maven Module.
Adjust any Maven properties if appropriate on next screen and click Finish.
Follow the Maven instructions below for setting up the pom.xml.
AWS SDK for Java
In order to reference the necessary types for developing workflows and activities, you will need to download the AWS SDK for Java. It is recommended that you use Maven to include a dependency for this library for your project and build, but you should still download this library in order to get the aws-java-sdk-flow-build-tools library which can be found under the lib directory.
SWF Flow Build Tools
The AWS SDK for Java download includes a aws-java-sdk-flow-build-tools-<version>.jar JAR under the lib directory. In order to allow the inclusion of a Maven dependency for this library, you'll need to install the JAR into your local Maven repository. You can achieve this by running the following from the lib directory of the AWS SDK download:
mvn install:install-file
-Dfile=aws-java-sdk-flow-build-tools-<version>.jar
-DgroupId=com.amazonaws
-DartifactId=aws-java-sdk-flow-build-tools
-Dversion=<version>
-Dpackaging=jar
NOTE: Be sure to replace the tokens in the above command with the appropriate version found in your AWS SDK download.
Maven
Your pom.xml file should include the following dependencies. I've included the version numbers I'm using in case you run into breaking changes using different versions:
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.18</version>
</dependency>
</dependencies>
Your pom.xml file should also include the following plugin. I'm using source include patterns that following a packaging and interface naming convention I use in my code, though you don't necessarily need to do things this way:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<complianceLevel>1.5</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<sources>
<source>
<basedir>src/main/java</basedir>
<includes>
<include>*/**/workflow/*Workflow.java</include>
<include>*/**/workflow/activities/*Activities.java</include>
</includes>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
Once you've include the plugin listed above and have at least run a Maven compile, you should notice an aspectj node appear under the Plugins node within the Maven Projects tool window in IntelliJ IDEA. You can also optional add or tweak the elements of the configuration section of the aspectj-maven-plugin plugin if you desire. The various supported settings can be found in the aspectj:compile goal documentation found here. I've haven't tweaked my plugin configuration yet to ensure that the .java files are generated in the proper location under my source directory, though I'm sure this is quite doable.
External Libraries
Once you've include the set of dependencies listed above and have at least run a Maven compile, you should notice at minimum the following set of dependencies listed under the External Libraries node within the Project tool window in IntelliJ IDEA:
com.amazonaws:aws-java-sdk-flow-build-tools
com.amazonaws:aws-java-sdk
commons-codec:commons-codec
commons-logging:commons-logging
org.apache.httpcomponents:httpclient
org.apache.httpcomponents:httpcore
org.aspectj:aspectjrt
org.codehaus.jackson:jackson-core-asl
org.codehaus.jackson:jackson-mapper-asl
org.freemarker:freemarker
Example pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>swf_example</groupId>
<artifactId>swf_example</artifactId>
<version>1.0</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.11</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.18</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<complianceLevel>1.5</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<sources>
<source>
<basedir>src/main/java</basedir>
<includes>
<include>*/**/workflow/*Workflow.java</include>
<include>*/**/workflow/activities/*Activities.java</include>
</includes>
</source>
</sources>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Defining Workflows
To define a workflow you must create a Java interface that meets the following criteria:
The interface is annotated with #Workflow.
A single method is defined for the interface that is annotated with #Execute and has a version property set.
The interface has a name that ends with the string Workflow.
The interface resides under a package that ends with workflow.
The following is an example workflow interface named MyWorkflow, and would be contained a file named MyWorkflow.java, located under the source directory src/main/java, and under the package directory structure com/some/package/workflow. I haven't included the #WorkflowRegistrationOptions annotation or other bells and whistles as these aren't required and are dependent on your particular needs:
package com.some.package.workflow;
import com.amazonaws.services.simpleworkflow.flow.annotations.Execute;
import com.amazonaws.services.simpleworkflow.flow.annotations.Workflow;
#Workflow
public interface MyWorkflow {
#Execute(version="1.0")
void doWorkflow();
}
Defining Activities
To define activities you must create a Java interface that meets the following criteria:
The interface is annotated with #Activities and has a version property set.
The interface has a name that ends with the string Activities.
The interface resides under a package that ends with workflow/activities.
The following is an example activities interface named MyActivities, and would be contained in a file named MyActivities.java, located under the source directory src/main/java, and under the package directory structure com/some/package/workflow/activities. I haven't included the #ActivityRegistrationOptions annotation or other bells and whistles as these aren't required and are dependent on your particular needs:
package com.some.package.workflow.activities;
import com.amazonaws.services.simpleworkflow.flow.annotations.Activities;
#Activities(version="1.0")
public interface MyActivities {
void doActivity1();
void doActivity2();
void doActivity3();
}
Building
In order to ensure that the build process is the same during everyday development as well as for non-development environments (e.g. test, production, etc.), you should run builds in your development tool of choice through Maven. Various aspects have been included in the aws-java-sdk and aws-java-sdk-flow-build-tools JARs which are weaved into your workflows and activities, and the aws-java-sdk-flow-build-tools JAR includes the necessary mechanism to auto-generate the required proxy classes to execute workflows and activities. In order to ensure that you're working with the latest generated proxy classes, you should take care to clean the generated artifacts before a build in order to throw away unneeded and/or old classes. This can be achieved by running the following command or equivalent in your development tool of choice:
mvn clean install
If you keep the showWeaveInfo configuration option enabled in the aspectj-maven-plugin plugin, you should see something like the following snippet in your build output, albeit there are only have a few lines of output here due to only having a single workflow and single activities for this run:
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: AsynchronyDeciderAnnotationProcessor.process() invoked.
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: Processing #Activities for MyActivities
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: Processing #Workflow for MyWorkflow
Mar 12, 2012 5:21:22 PM com.amazonaws.eclipse.simpleworkflow.asynchrony.annotationprocessor.AsynchronyDeciderAnnotationProcessor process
INFO: AsynchronyDeciderAnnotationProcessor.process() invoked.
Auto-Generated Proxies
Once you've compiled your workflows and activities you should find the follow set of auto-generated proxy classes have been created. These proxies are to be used within your workflows to call upon your various activities, execute child workflows within other workflows, and also to execute workflows at a top level. NOTE: The strings "Workflow" and "Activities" in the following bullets would actually be the name of your actual workflow and activities interfaces respectively, and you should see the following set of classes created for each of your defined workflow and activities interfaces:
WorkflowClient.java
WorkflowClientExternal.java
WorkflowClientExternalFactory.java
WorkflowClientExternalFactoryImpl.java
WorkflowClientExternalImpl.java
WorkflowClientFactory.java
WorkflowClientFactoryImpl.java
WorkflowClientImpl.java
WorkflowSelfClient.java
WorkflowSelfClientImpl$1.java
WorkflowSelfClientImpl.java
ActivitiesClient.java
ActivitiesClientImpl.java
I'm also including some background information to help clarify the type of development environment I'm working on and tools I'm using for day to day coding.
OS
Mac OS X version 10.7.3
Java
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50b)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
Maven
Apache Maven 3.0.3 (r1075438; 2011-02-28 12:31:09-0500)
Maven home: /usr/share/maven
Java version: 1.6.0_29, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.7.3", arch: "x86_64", family: "mac"
IntelliJ IDEA (Community Edition)
IntelliJ IDEA 11.0.2
Build #IC111.277
Built on February 1, 2012
Here is a more recent answer that works for Java8 (JDK8) and compile time weaving.
The problem is that the maven compiler can perform annotation processing. If its turned on and aspectj, you will try to double create the same classes.
its better to leave the maven compiler to process the annotations (generate the workflow/activity classes) since aspectJ needs them created so it can then do its weaving (#Retry #Async)
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<goals>
<goal>compile</goal> <!-- use this goal to weave all your main classes -->
<goal>test-compile</goal> <!-- use this goal to weave all your test classes -->
</goals>
</execution>
</executions>
<configuration>
<complianceLevel>1.8</complianceLevel>
<showWeaveInfo>true</showWeaveInfo>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<aspectLibraries>
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-swf-libraries</artifactId>
</aspectLibrary>
</aspectLibraries>
<!-- This is important so we don't double process the annotations -->
<proc>none</proc>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Did you check the updated SDKs today? There was a new release about 10 hours ago (1.4.3 for .NET at least, released on February 21, 2012).
http://aws.amazon.com/releasenotes/.NET/5023081835314406
Several years later, this thread helped me a lot to make AWS SWF Flow work with Maven. However, some aspects are not working out of the box with this approach. I have written an article to concentrate all my findings. PS: would love some tips to make Java 1.8 work as well with this.
I have managed to make JAVA8 / AWS SDK 1.9.x work with Maven and Eclipse following this remarkable examples pedropaulovc/aws-flow-maven-eclipse-samples and tweaking the pom.xml, including the brave Mircea suggestion and other reworks.
you can find the resulting working pom.xml here
Note that i had to add to the aspectj plugin aspect libraries also the updated flow-build-tools, otherwise, the Activity and Workflow impl version number annotations do not work properly
<aspectLibraries>
<!-- for aspect weaving and swf versions -->
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-swf-libraries</artifactId>
</aspectLibrary>
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-flow-build-tools</artifactId>
</aspectLibrary>
</aspectLibraries>
Hope this could be helpful!
For the brave souls that read this:
Most of the stuff still applies. To make it work with Java 1.8, you need to use the following aspect library with AspectJ:
<aspectLibraries>
<aspectLibrary>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-swf-libraries</artifactId>
</aspectLibrary>
</aspectLibraries>
For a full sample look at:
https://github.com/mirceal/swf-flow-java18-sample

Hudson build fail: Non-resolvable parent POM

I used to work with Hudson on my project, and lately I had to move it to a new server.
I configured it the exact same way it use to be (for all I can tell) but when I try to launch a build, it fails and I get the following error:
Démarré par l'utilisateur anonymous
Checking out http://[...]/trunk/MyProject/ear
A .classpath
A .project
A target
AU target/ear-1.0-SNAPSHOT.ear
A target/application.xml
A target/ear-1.0-SNAPSHOT
A target/ear-1.0-SNAPSHOT/META-INF
A target/ear-1.0-SNAPSHOT/META-INF/application.xml
AU target/ear-1.0-SNAPSHOT/web-1.0-SNAPSHOT.war
AU target/ear-1.0-SNAPSHOT/business-1.0-SNAPSHOT.jar
A pom.xml
A .settings
A .settings/org.eclipse.jdt.core.prefs
A .settings/org.maven.ide.eclipse.prefs
At revision 136
no change for http://[...]/trunk/MyProject/ear since the previous build
Found mavenVersion 3.0.2 from file jar:file:/usr/share/maven/apache-maven-3.0.2/lib/maven-core-3.0.2.jar!/META-INF/maven/org.apache.maven/maven-core/pom.properties
Parsing POMs
ERROR: Echec à la lecture des POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Could not find artifact com.rha:MyProject:pom:1.0-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 9, column 10
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:325)
at hudson.maven.MavenEmbedder.buildProjects(MavenEmbedder.java:360)
at hudson.maven.MavenEmbedder.readProjects(MavenEmbedder.java:330)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1148)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:991)
at hudson.FilePath.act(FilePath.java:756)
at hudson.FilePath.act(FilePath.java:738)
at hudson.maven.MavenModuleSetBuild$RunnerImpl.parsePoms(MavenModuleSetBuild.java:698)
at hudson.maven.MavenModuleSetBuild$RunnerImpl.doRun(MavenModuleSetBuild.java:531)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:420)
at hudson.model.Run.run(Run.java:1362)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:405)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:145)
Finished: FAILURE
The pom.xml file when I got to Hudson "workspace" looks like this:
[...]
<parent>
<groupId>com.rha</groupId>
<artifactId>MyProject</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
[...]
<dependencies>
<dependency>
<groupId>com.rha</groupId>
<artifactId>business</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.rha</groupId>
<artifactId>web</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
[Edit]
Actually I forgot some important informations:
My project is divided into 3 parts:
business (packaged into .jar)
web (packaged into a .war)
ear (packaged the .war and .jar into a .ear)
I'm using Subversion, and under my "trunk" folder I got a "MyProject" folder including:
.project
.settings/
business/
ear/
pom.xml
src/
web/
what happens is:
in my Hudson job configuration, I filled the SVN field "repository URL" with:
http://[...]/trunk/MyProject/ear
and here is the "pom.xml" from "MyProject" folder:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
[...]
<modules>
<module>business</module>
<module>web</module>
<module>ear</module>
</modules>
[...]
so the parent "pom.xml" is actually located at "../pom.xml" on my SVN repository, under "trunk/MyFolder".
But Hudson can't see it for some reason (but like I said, it used to work on the previous server).
Any clue ?
[/Edit]
I guess this is a rookie mistake, I'm a total beginner on Maven, but I just can't figure out why it's not working anymore ...
Any help will be greatly appreciated !
Nicolas
relativePath (of the parent) defaults to ../pom.xml. It looks like it is not present in there. You could set it to an empty value so that maven downloads it as a dependency.
<relativePath/>
This link discusses this.
[Edit: based on the edits to the question]
Hudson only sees the source code inside ear folder. Though the parent pom is present in SVN, it is not available to Hudson. Missing parent pom was aa warning in Maven 2 but strict in Maven 3.
There are two ways to solve this.
One is to specify to hudson, the url http://[...]/trunk/MyProject/. You can then chose to build all the modules or still choose to build the pom.xml of ear project alone.
The other is to manually run mvn install on the hudson system so that the parent pom gets deployed once and thereafter used by hudson. However, this will not get updated if parent pom is subsequently changed.
Retrieving the Root-POM from the Maven-REPO should usually also work (like you do), but I would expect you havn't triggered the root pom to be installed into the REPO on the new hudson site so far.
To avoid this use the relativePath property, e.g. something like this:
<relativePath>../pom.xml</relativePath>
in your <parent> tag which will tell maven to look for the root pom in your module structure.
I had the same problem with Hudson, Sonar plugin and a multi-module Maven project: "Non-resolvable parent POM" when Hudson tried to run sonar:sonar. The solution was to specify the Root POM location in the Hudson job configuration under the Sonar section.
The project structure in SVN (each one is a Maven project with pom.xml in the project root):
foo-parent
+- foo-ui-module
+- bar-other-module
I have individual Hudson jobs for each project, "foo-parent", "foo-ui-module" and "bar-other-module". The Sonar run in a Hudson job could not find the parent POM even though the build was successful until that point. Maybe the Sonar plugin doesn't use the same Maven settings as the rest of the job because it didn't try to look for the parent POM from our Artifactory repository, not even with <relativePath/> in the project POM.
The place for the Root POM setting was under the job's Configure -> Sonar -> Advanced -> Root POM: ../foo-parent/pom.xml (I have foo-parent job at this path)
We managed to get this working by simply deleting the relevant pom file, plus some sort of metadata file with a similar name in the same folder, from the .m2/repository/a/b/c folder on our jenkins server.
Rerunning the jenkins build after doing this worked just fine.
Hope this helps someone...

OC4J Problem: global-web-application.xml Works, orion-web.xml Doesn't

I recently "solved" a somewhat common problem in OC4J regarding the use of Xerces rather than OC4J's built-in parser. The problem was solved by adding this line to global-web-application.xml:
<web-app-class-loader search-local-classes-first="true"/>
Unfortunately, this was too much of a big-hammer approach that could cause problems on the app server, so I tried to resolve it via creating the following orion-web.xml file in the WEB-INF directory of the app:
<?xml version="1.0"?>
<orion-web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-web-10_0.xsd">
<web-app-class-loader search-local-classes-first="true" include-war-manifest-class-path="true"/>
<web-app/>
</orion-web-app>
Unfortunately, it turns out that using global-web-application.xml worked, using orion-web.xml didn't
OC4J version is 10.1.3.5.
Can anyone advise?
Another way is specify at Deploy Time. Take a look:
Specifying search-local-classes-first at Deployment Time
The following example illustrates how to set the search-local-classes-first attribute in the orion-web.xml file generated for the Web module at deployment time, with Application Server Control.
Select Applications>Deploy to launch the Application Server Control deployment wizard.
Supply the path to the application in the first page of the wizard.
Specify the application name and supply any context URI mappings in the second page.
Click Configure Class Loading in the third page of the wizard (Deploy: Deployment Settings).
Under Configure Web Module Class Loaders, check the Search Local Classes First checkbox next to the name of the Web module containing the local JAR file to use.
Optionally click the Save Deployment Plan button, and save the plan for reuse.
I think you could solve this in a different manner. Using properties, and removing libraries.
There are two properties:
xml.driver.property
xml.driver.impl
One define the parser interface and the other the implementation. You can switch this from one implementation from another.
for example we have:
xml.driver.property=org.xml.sax.driver
xml.driver.impl=org.apache.xerces.parsers.SAXParser
As this is a system properties you can load it in many different ways. We use a special servlet installed in all OC4J instances (containers) that loads this an other properties at runtime.
A "little" bit late but hope it helps.
Finally I'm abble run JAXB2 (used by Spring WS 2.1.4) on my OC4J 10.13 (and 10.13.50). JAXB needs xalan lib.
orion-web.xml
<?xml version="1.0"?>
<!DOCTYPE orion-web-app PUBLIC "-//Evermind//DTD Orion Web Application 2.3//EN"
"http://xmlns.oracle.com/ias/dtds/orion-web.dtd">
<orion-web-app
persistence-path=""
jsp-cache-directory="./persistence"
jsp-cache-tlds="standard"
simple-jsp-mapping="false"
temporary-directory="./temp"
servlet-webdir="/servlet/"
>
<web-app-class-loader search-local-classes-first="true"/>
</orion-web-app>
maven pom.xml
<!-- JAXB implemetation by EclipseLink MOXy-->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.1</version>
<scope>compile</scope>
</dependency>
<!-- Specific dependencies for OC4J v1013 -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
</exclusions>
</dependency>