How can I pack switchyard application with has dependencies to my another project with Maven? Currently I'm trying to make things work as explained here
official dock.
But with no result, on startup of application in log file I see
Caused by: java.lang.NoClassDefFoundError: com/aspiderngi/common/switchyard/InventoryRequest
Caused by: java.lang.ClassNotFoundException: com.aspiderngi.common.switchyard.InventoryRequest from...
Is it possible to achieve anyways?
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.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>
<groupId>com.example.switchyard</groupId>
<version>0.0.1-SNAPSHOT</version>
<name>com.example.switchyard:sy-example</name>
<artifactId>sy-example</artifactId>
<properties>
<switchyard.version>2.0.0.Final</switchyard.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<packaging>war</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-bom</artifactId>
<version>${switchyard.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.aspiderngi</groupId>
<artifactId>artifacts-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.switchyard.components</groupId>
<artifactId>switchyard-component-camel</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard.components</groupId>
<artifactId>switchyard-component-camel-jms</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard.components</groupId>
<artifactId>switchyard-component-resteasy</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-api</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-transform</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-validate</artifactId>
</dependency>
<dependency>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.switchyard.components</groupId>
<artifactId>switchyard-component-test-mixin-cdi</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.switchyard.components</groupId>
<artifactId>switchyard-component-bean</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-plugin</artifactId>
<version>${switchyard.version}</version>
<executions>
<execution>
<goals>
<goal>configure</goal>
</goals>
</execution>
</executions>
<configuration>
<scannerClassNames>
<param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
</scannerClassNames>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<packagingExcludes>
WEB-INF/lib/*.jar,
WEB-INF/classes/META-INF/switchyard.xml
</packagingExcludes>
<webResources>
<resource>
<directory>target/classes/META-INF</directory>
<targetPath>WEB-INF</targetPath>
<includes>
<include>switchyard.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
</project>
You can use Maven Shade plugin:
https://maven.apache.org/plugins/maven-shade-plugin/
example:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jackofall</shadedClassifierName> <!-- Any name that makes sense -->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
Please try this out. The dependent project must have its own pom.xml(child)
Include this child pom to the parent pom. And include the below code in the parent pom.xml
This would directly deploy the application in the server
From project root in cmd execute the below commands:
1. mvn clean
2. mvn dependency:resolve
3. mvn install
if you are using Eclipse, use maven update. then Run As maven install
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<debug>true</debug>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.switchyard</groupId>
<artifactId>switchyard-plugin</artifactId>
<version>${switchyard.version}</version>
<executions>
<execution>
<goals>
<goal>configure</goal>
</goals>
</execution>
</executions>
<configuration>
<scannerClassNames>
<param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
</scannerClassNames>
</configuration>
</plugin>
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
if you are using Bean then include
<scannerClassNames>
<param>org.switchyard.transform.config.model.BeanSwitchYardScanner</param>
</scannerClassNames>
Related
attempting to build [RedFX-Quantum/Strange][1]. When running mvn package, I get "Fatal error compiling: invalid flag: --release". the pom.xml file is below:
<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>org.redfx</groupId>
<artifactId>strange</artifactId>
<packaging>jar</packaging>
<version>0.1.3</version>
<name>Strange</name>
<description>Strange Quantum Simulator</description>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<javadoc.plugin.version>3.2.0</javadoc.plugin.version>
<gpg.plugin.version>1.6</gpg.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
</dependency>
<!--
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native</artifactId>
<version>1.0.0-beta7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.26</version>
</dependency>
-->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<release>10</release>
</configuration>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>6.1.1</version> <!-- Use newer version of ASM -->
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.redfx.strange.demo.Demo</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-no-snapshots</id>
<phase>install</phase>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireReleaseDeps>
<message>Snapshot dependencies are not allowed for release project version!</message>
<onlyWhenRelease>true</onlyWhenRelease>
</requireReleaseDeps>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<organizationName>Johan Vos</organizationName>
<inceptionYear>2020</inceptionYear>
<licenseName>bsd_3</licenseName>
<addJavaLicenseAfterPackage>false</addJavaLicenseAfterPackage>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<profiles>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${javadoc.plugin.version}</version>
<configuration>
<detectJavaApiLink>false</detectJavaApiLink>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${gpg.plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- This is necessary for gpg to not try to use the pinentry programs -->
<!-- Only required for GPG >= 2.2 -->
<!--
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
-->
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<scm>
<connection>scm:git:git://github.com/redfx-quantum/strange.git</connection>
<developerConnection>scm:git:git#github.com:redfx-quantum/strange.git</developerConnection>
<url>https://github.com/redfx-quantum/strange</url>
<tag>HEAD</tag>
</scm>
</project>
running mvn package -e didn't give any noticeably different output and mvn package -X didn't give me anything I could understand. How would I go about fixing it? Looking in the pom.xml file, the only release related thing I could see was the <release>10<\release> but idk what to change that to if that is the problem. I'm assuming I have to change things in the file to fit what versions of java and maven I have but I'm pretty new to the both of them and don't really know what I'm looking for.
[1]https://github.com/redfx-quantum/strange
I am having a NoClassDefFoundError exception when I execute a jndi lookup for an API in an EJB. Here is what my project looks like :
java project
In my project I have 2 APIs, 2 EJBs and 2 Clients. Both my clients work. What I am trying to do is make a function of EJB ejb-admin-bean call ejb-31-entity-bean-exemple-bean by calling ejb-31-entity-bean-exemple-api.
Here is the code that :
package admin.entity_bean_ejb;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import admin.entity_bean_api.StatelessSessionAdmin;
import enterprise.entity_bean_api.StatelessSessionLocal;
/**
* The stateless session bean.
*/
#Stateless
public class StatelessSessionAdminBean implements StatelessSessionAdmin {
#Override
public String helloWorld() {
return "the room is called " + getShowRoomName();
}
//test d'appel de l'api d'encheres
public String getShowRoomName() {
StatelessSessionLocal sb;
try {
InitialContext ic = new InitialContext();
sb = (StatelessSessionLocal) ic.lookup("java:global/ejb-31-entity-bean-example-bean/StatelessSessionBean!enterprise.entity_bean_api.StatelessSessionLocal");
final String roomName = sb.getShowRoomName(1);
return roomName;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
The class not found is StatelessSessionLocal from ejb-31-entity-bean-example-api
Here is the stackTrace :
javax.ejb.EJBException
at com.sun.ejb.containers.EJBContainerTransactionManager.processSystemException(EJBContainerTransactionManager.java:752)
Caused by: java.lang.ClassNotFoundException: enterprise.entity_bean_api.StatelessSessionLocal
at com.sun.enterprise.loader.ASURLClassLoader.findClassData(ASURLClassLoader.java:865)
at com.sun.enterprise.loader.ASURLClassLoader.findClass(ASURLClassLoader.java:742)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 52 more
I use Eclipse, glassfish and maven. Here are the POMs of my project :
Here is the parent pom :
<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>org.glassfish-samples</groupId>
<artifactId>ejb-31-entity-bean-example</artifactId>
<packaging>pom</packaging>
<name>ejb-31-entity-bean-example</name>
<version>4.0-SNAPSHOT</version>
<!-- repositories for the checkstyle configuration TSP CSC -->
<pluginRepositories>
<pluginRepository>
<id>tsp-csc-checkstyle-config-stable</id>
<name>TSP CSC Checkstyle configuration, stable</name>
<url>http://www-inf.telecom-sudparis.eu/COURS/CSC4102/maven-repository/stable/</url>
</pluginRepository>
<pluginRepository>
<id>tsp-csc-checkstyle-config-snapshot</id>
<name>TSP CSC Checkstyle configuration, snapshot</name>
<url>http://www-inf.telecom-sudparis.eu/COURS/CSC4102/maven-repository/snapshot/</url>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<glassfish.version>4.1</glassfish.version>
</properties>
<build>
<plugins>
<!-- maven-eclipse configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.10</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
<!-- java compiler configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- surefire configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<enableAssertions>true</enableAssertions>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<!-- source packaging configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- javadoc packaging in jar configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<docfilessubdirs>true</docfilessubdirs>
<detectOfflineLinks>false</detectOfflineLinks>
<detectJavaApiLink>false</detectJavaApiLink>
</configuration>
</execution>
</executions>
</plugin>
<!-- checkstyle configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>eu.telecomsudparis.csc</groupId>
<artifactId>tsp-csc-config-checkstyle</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<configuration>
<checkstyle.config.location>config/checkstyle/sun_checks_adapted_to_tsp_csc.xml</checkstyle.config.location>
<configLocation>config/checkstyle/sun_checks_adapted_to_tsp_csc.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
<!-- site configuration -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.6</version>
<configuration>
<locales>fr</locales>
</configuration>
</plugin>
</plugins>
</build>
<!-- reports in the maven site -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.4</version>
<configuration>
<dependencyDetailsEnabled>false</dependencyDetailsEnabled>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<configuration>
<configLocation>config/checkstyle/sun_checks_adapted_to_tsp_csc.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
</plugin>
</plugins>
</reporting>
<modules>
<module>ejb-31-entity-bean-example-entity</module>
<module>ejb-31-entity-bean-example-api</module>
<module>ejb-31-entity-bean-example-bean</module>
<module>ejb-31-entity-bean-example-client</module>
<module>ejb-admin-bean</module>
<module>ejb-admin-api</module>
<module>ejb-admin-entity</module>
<module>ejb-admin-client</module>
</modules>
</project>
And here is the POM of the bean that wants to call the api :
<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>
<parent>
<groupId>org.glassfish-samples</groupId>
<artifactId>ejb-31-entity-bean-example</artifactId>
<version>4.0-SNAPSHOT</version>
</parent>
<groupId>org.glassfish-samples.entity-bean-example2</groupId>
<artifactId>ejb-admin-bean</artifactId>
<packaging>ejb</packaging>
<name>The EJB 3.2 Entity Bean Sample Application</name>
<version>4.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-shade-plugin -->
<!-- <dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
</dependency>
-->
<dependency>
<groupId>org.glassfish-samples.entity-bean-example2</groupId>
<artifactId>ejb-admin-entity</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.glassfish-samples.entity-bean-example2</groupId>
<artifactId>ejb-admin-api</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<!-- embedded glassfish for JUnit tests -->
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1.1</version>
<scope>test</scope>
</dependency>
<!-- JUnit tests -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!--interaction entre les modules de l'appli. ajout perso-->
<dependency>
<groupId>org.glassfish-samples.entity-bean-example</groupId>
<artifactId>ejb-31-entity-bean-example-api</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>entity-bean2</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.glassfish-samples.entity-bean-example2</groupId>
<artifactId>ejb-admin-entity</artifactId>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</artifactItem>
<artifactItem>
<groupId>org.glassfish-samples.entity-bean-example2</groupId>
<artifactId>ejb-admin-api</artifactId>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<!-- build the ejb jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<jarName>entity-bean2</jarName>
<ejbVersion>3.2</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thank you for your help!
I am currently working on a project where I want to generate an ANTLR parser from a grammar and continue working with that parser inside my Scala code.
For this, I set up a new project with the following 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>Foo</description>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.11.5</scala.version>
<scala.compat.version>2.11</scala.compat.version>
<antlr.version>4.7</antlr.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>${antlr.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2-core_${scala.compat.version}</artifactId>
<version>2.4.16</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.compat.version}</artifactId>
<version>2.2.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>${antlr.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<executions>
<execution>
<id>antlr</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
<configuration>
<visitor>true</visitor>
</configuration>
</plugin>
</plugins>
</build>
</project>
Compiling a project with a grammar file in the default location works just fine - Java sources are generated to target/generated-sources/antlr as expected.
However, I can not import the generated parser (let's call it FooParser) inside my Scala code - IntelliJ recognizes that there is something called
FooParser but when I try to auto-import it, it fails.
Also, building from the command line with mvn compile with source code
depending on the FooParser fails.
Resolution of the whole thing was rather dumb:
My file structure was wrong:
src/
main/
antlr/
Foo.g4
You have to put your grammars into proper packages, otherwise
the whole thing wont be properly 'importable'.
src/
main/
antlr/
packagename/
Foo.g4
I have a maven project and jni4net is one of the dependency and it's running fine in Netbeans. But when i package it into a jar i get the error java.lang.UnsatisfiedLinkError: no jni4net.n-0.8.8.0 in java.library.path. I solved this problem in Netbenas by setting Working directory and VM Options in Project Properties -> Run. Now is there a way to include these configurations while packaging it as jar, or any other solution.
Thanks in advance...
Here is my pom
<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>com.base</groupId>
<artifactId>base</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>BASE</name>
<repositories>
<repository>
<id>repo</id>
<url>file://${project.basedir}/./temp-repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jni4net</groupId>
<artifactId>jni4net.j</artifactId>
<version>0.8.8.0</version>
</dependency>
<dependency>
<groupId>customId</groupId>
<artifactId>customId</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.0.0-beta2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.0.0-beta2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>com.mysite.myproject.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<resources>
<resource>
<directory>lib</directory>
<!--<filtering>true</filtering>-->
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
While running the executing the maven main class using below command:
mvn exec:java -Dexec.mainClass="com.xoxo.amqtest.SubscriberDriver"
I assumed that all the jars must be picked up from the maven repo. But instead it throws below exception.
java.lang.NoClassDefFoundError: com/xoxo/infra/protectedpkg/ProtectedPackageLoadException
This maven project runs fine in eclipse. Is there any way to specify maven to pick all the dependencies from maven repo instead of adding all the dependencies like below
java -cp ./:./target/amq-subscriber-1.0.0-SNAPSHOT-jar-with-dependencies.jar:/x/home/stvu/.m2/repository/com/xoxo/submodule/infra-jsse-2.0.1.jar com.xoxo.amqtest.SubscriberDriver
Edit:
<?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>
<parent>
<groupId>com.xoxox.infra</groupId>
<artifactId>infra-parent</artifactId>
<version>13.2.3</version>
<relativePath />
</parent>
<groupId>com.xoxox.amqtest</groupId>
<artifactId>amqsubscriber</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>amq_sub_test</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.xoxox.infra</groupId>
<artifactId>infra</artifactId>
</dependency>
<dependency>
<groupId>com.xoxox.kernel</groupId>
<artifactId>KernelDAL</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.11</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.xoxox.infra.maven.plugins
</groupId>
<artifactId>
infra-codegenerator-maven-plugin
</artifactId>
<versionRange>
[13.3.0,)
</versionRange>
<goals>
<goal>generate-code</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I've done this in the past using exec-maven-plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>execute-your-main</id>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>com.xoxo.amqtest.SubscriberDriver</mainClass>
<arguments>
<argument>ADD_YOUR_ARGUMENTS_IF_NEEDED</argument>
</arguments>
</configuration>
</execution>
</plugin>
take look at appassembler plugin.
http://mojo.codehaus.org/appassembler/appassembler-maven-plugin/
Configuration will look like
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
<configuration>
<programs>
<program>
<mainClass>fun.Tester</mainClass>
<id>app</id>
</program>
</programs>
</configuration>
</plugin>
it will create directory name 'appassembler' in you target directory which will have all dependent jars and executable according to platform in 'bin' directory