service bus maven error - unknown packaging sbar - maven

I am new to maven / pom.xml and am following the below link to create an oracle service bus project and package it into custom packaging type "sbar".
https://docs.oracle.com/middleware/1213/core/MAVEN/osb_maven_project.htm#MAVEN8971
The Project gets generated properly (from the command --> mvn archetype:generate ... ) but when I execute the below command I get an error
mvn package -DoracleHome=/path/to/osbhome
[ERROR] Unknown packaging: sbar # line 16, column 16
project pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.oracle.servicebus.plugin</groupId>
<artifactId>oracle-servicebus-plugin</artifactId>
<version>12.1.3-0-0</version>
</parent>
<groupId>my-servicebus-application</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sbar</packaging> <!--getting error on this line-->
<build>
<plugins>
<plugin>
<groupId>com.oracle.servicebus.plugin</groupId>
<artifactId>oracle-servicebus-plugin</artifactId>
<version>12.1.3-0-0</version>
<executions>
<execution>
<id>package</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
application pom.xml
<project>
...
<modelVersion>4.0.0</modelVersion>
<groupId>my-servicebus-application</groupId>
<artifactId>my-servicebus-application</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>System</module>
<module>my-project</module>
</modules>
...
</project>
system pom.xml
<project>
...
<modelVersion>4.0.0</modelVersion>
<groupId>org.mycompany</groupId>
<artifactId>System</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>sbar</packaging>
<parent>
<groupId>com.oracle.servicebus</groupId>
<artifactId>sbar-system-common</artifactId>
<version>12.1.3-0-0</version>
<relativePath></relativePath>
</parent>
...
</project>
I am using JDeveloper 12.1.3.0.0 and Maven 3.0.5.
(I get the same error if I run it either from JDeveloper or from command promt)
Please help me solve this error.
Thanks in Advance !

I haven't really sat down to work with any of the Maven POM's for OSB, SOA, etc., but I do know that your maven plugin probably isn't on the default M2 repository. It probably can't find your packaging type of sbar because it's not included in your repository. I'm assuming you're using their supplied maven and maven repo following this guide: https://docs.oracle.com/middleware/1213/core/MAVEN/config_maven.htm#MAVEN8853

Related

Maven install-plugin does not use versions-plugin updated version

I use the versions-maven-plugin to update the projects version. I want to install the artifact with this updated version but the maven-install plugin uses the old version. How do I have to configure the project to achieve the described behaviour?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
<configuration>
<propertyPrefix>parsedVersion</propertyPrefix>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<executions>
<execution>
<id>update-version</id>
<phase>validate</phase>
<goals>
<goal>set</goal>
<goal>commit</goal>
</goals>
<configuration>
<newVersion>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${SVN_REVISION}</newVersion>
</configuration>
</execution>
</executions>
</plugin>
Normally I would expect that concerning the maven lifecycle the install plugin should take the new version because the version plugin is executed in the phase validate.
Starting with Maven 3.2.1 there is a possibility to use properties as versions which means you can give things like this in your pom file:
<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>
<parent>
<groupId>com.soebes.smpp</groupId>
<artifactId>smpp</artifactId>
<version>2.2.1</version>
</parent>
<groupId>com.soebes.examples.j2ee</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
Furthermore you can of course us this also in parent element of a multi module build like this:
<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>
<parent>
<groupId>com.soebes.examples.j2ee</groupId>
<artifactId>parent</artifactId>
<version>${revision}</version>
</parent>
<artifactId>service</artifactId>
<packaging>ejb</packaging>
This means in consequence you can run Maven via this:
mvn -Drevision=1.2.3-SNAPSHOT install
Or to do a release simply:
mvn -Drevision=1.2.3 install
The drawback here is that you need to give the revision always on command line or in your CI jobs. Apart from that it is possible to use furthermore other things like ${changelist} or ${sha1} which you can of course use in combination. So you can adopt the suggestions like this:
<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>
<parent>
<groupId>com.soebes.smpp</groupId>
<artifactId>smpp</artifactId>
<version>2.2.1</version>
</parent>
<groupId>com.soebes.examples.j2ee</groupId>
<artifactId>parent</artifactId>
<version>${revision}-${sha1}</version>
<packaging>pom</packaging>
So you can call maven via this:
mvn -Drevision=1.2.3 -Dsha1=SVNRevision-SNAPSHOT clean package

Packaging using Maven

I have a Java web application deployed using Tomcat. I want to package the Tomcat ROOT into .WAR file using Maven. Can someone guide me through the process?
Thank you
Create a pom.xml file in the ROOT directory with the following code.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>package</groupId>
<artifactId>artifactid</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project</name>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then execute the following command in the command line mvn:clean install.
The war file will be generated to the target directory.

Get war module when running the parent maven project

Is there a way to run a war module automatically when I run the parent project?
To make it clear, I did three separate maven project (db, core and presentation), then I made a parent project which include the 3 projects mentioned before.
I'd like to get the presentation module running when I run the parent project.
Also, I want to know if it's possible to save the hole work from the parent project to my git account.
<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>com.project.xxxxxxx</groupId>
<artifactId>parent-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent-project</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<targetJdk>1.7</targetJdk>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<port>8080</port>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${targetJdk}</source>
<target>${targetJdk}</target>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
<modules>
<module>../project-db</module>
<module>../project-core</module>
<module>../project-presentation</module>
</modules>
<dependencies>
</dependencies>
</project>
You need to specify the sub-project under tag.
You may refer http://books.sonatype.com/mvnex-book/reference/multimodule-sect-simple-parent.html for example
Your modules should be unter your parent in the file structure. Like
parent-project
pom.xml
project-db
pom.xml
project-core
pom.xml
project-presentation
pom.xml
Then you have to change the parent pom:
<modules>
<module>project-db</module>
<module>project-core</module>
<module>project-presentation</module>
</modules>

Maven assembly plugin - dependendy on module of type ear in multi module project

My question is whether there is anyway with the maven assembly plugin to reference a dependency of type ear that is not installed in the artefactory/repository.
Consider the multi-module project below with parent:
<?xml version="1.0" encoding="UTF-8"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>parent</name>
<modules>
<module>module1</module>
<module>assembly</module>
</modules>
</project>
with ear module:
<?xml version="1.0"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
</parent>
<groupId>com.test</groupId>
<artifactId>module1</artifactId>
<packaging>ear</packaging>
<name>EAR Module</name>
</project>
and assembly module:
<?xml version="1.0"?>
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test</groupId>
<artifactId>parent</artifactId>
<version>1.0</version>
</parent>
<groupId>com.test</groupId>
<artifactId>assembly</artifactId>
<packaging>jar</packaging>
<name>Assembly Module</name>
<dependencies>
<!-- Note - the dependencies (and their associated dependencies etc) are
subsequently available for assembly dependencySet includes -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>module1</artifactId>
<type>ear</type>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
with an assembly xml :
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bundle</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<!--
Include EAR
-->
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<outputFileNameMapping>xxxxxxxxx.ear</outputFileNameMapping>
<outputDirectory>eardirectory</outputDirectory>
<includes>
<include>${pom.groupId}:module1:ear</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
From a brand new checkout with empty repository, the parent project pom fails when doing a mvn compile with the error
[ERROR] Failed to execute goal on project assembly: Could not resolve dependencies for project com.test:assembly:jar:1.0: Could not find artifact com.test:module1:ear:1.0 ...
Whereas, if I first go to the ear module and do a mvn install, then subsequent mvn compile from the parent module works perfectly.
Additionally, if the ear module was instead the standard jar module, then this issue does not exist. Such that, if the dependency module had been of type jar, there is no need to first install it in to the local repos before doing the initial mvn compile from the parent.
Switching the dependency in the assembly pom to be of scope 'runtime' allows an initial mvn compile to succeed, however a mvn test would fail. Setting the dependency as optional also did not succeed.
Can anyone suggest a potential solution?
I'm hoping I don't need to go down the fileSet path, or utilize the maven-dependency-plugin. This dependency only exists in the pom so that the assembly plugin can package it / reference it. It is not for compilation / runtime / testing. So none of the maven dependency scopes make any sense.

Dependency management does not work for multi-module project

I have a Maven project with multiple modules and I'm trying to set it up so that module dependencies are automatically built to the correct lifecycle phase needed for building depending modules to the requested lifecycle phase.
In the example, the module plugin builds a Maven plugin, which is used to generate source code and is used by the module main. If I just try to use mvn -am -pl main compile, the module plugin is compiled but the process-classes lifecycle phase is not executed (which is necessary for a plugin to be usable). Compiling the module main then fails then with the following error:
[ERROR] Failed to parse plugin descriptor for example:plugin:1.0.0-SNAPSHOT (/Users/ims/Dropbox/IMS/Projects/PARITy_R4/codegen-test-simple/plugin/target/classes): No plugin descriptor found at META-INF/maven/plugin.xml -> [Help 1]
Is Maven, or a plugin for it, capable of resolving the dependencies of modules in a multi-module project and build them to stage necessary by other modules? And if so, how do I need to set up the project for this to work?
These are the POMs of my project:
pom.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>plugin</module>
<module>main</module>
</modules>
</project>
plugin/pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<parent>
<groupId>example</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.2</version>
<configuration>
<goalPrefix>configurator</goalPrefix>
</configuration>
<executions>
<execution>
<id>default-descriptor</id>
<goals>
<goal>descriptor</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
main/pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>main</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>example</groupId>
<artifactId>project</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>example</groupId>
<artifactId>plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>codegen</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
If you look at the reference documentation for the Maven lifecycle, you'll see that compile is before process-classes.
If you want this step to happen, you need to use mvn -am -pl main process-classes instead.
But I suggest that you always use mvn ... install - it also runs the tests and makes sure that the plugin which main uses is actually the one you think it should: Without install, the build will use an old/outdated version from the local repository (Maven will not magically determine "oh, there is a plugin in my reactor, I'll use that instead of the version from the local repo").

Resources