Can't build working Java app with gRPC, Protobuf and BoringSSL to JAR using Maven - maven

I have problem with building my Java app to jar file using Maven.
Application is using gRPC and Protobuf.
When I start my app in IntelliJ everything work just fine, problem is when I want to build jar with Maven... I don't have much experience with creating pom files.
I tried to find some solution but nothing works and I ended up with pom.xml as below:
[...]
<properties>
<grpc.version>1.17.1</grpc.version>
<protoc.version>3.5.1-1</protoc.version>
<netty.tcnative.version>2.0.13.Final</netty.tcnative.version>
[...]
</properties>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${netty.tcnative.version}</version>
<scope>runtime</scope>
</dependency>
[...]
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireUpperBoundDeps/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>pl.test.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
And this is the exception when I try to start gRPC server with SSL context:
Exception in thread "Thread-2" java.lang.UnsatisfiedLinkError: failed to load the required native library
at io.netty.handler.ssl.OpenSsl.ensureAvailability(OpenSsl.java:346)
at io.netty.handler.ssl.ReferenceCountedOpenSslContext.<init>(ReferenceCountedOpenSslContext.java:202)
at io.netty.handler.ssl.OpenSslContext.<init>(OpenSslContext.java:43)
at io.netty.handler.ssl.OpenSslServerContext.<init>(OpenSslServerContext.java:347)
at io.netty.handler.ssl.OpenSslServerContext.<init>(OpenSslServerContext.java:335)
at io.netty.handler.ssl.SslContext.newServerContextInternal(SslContext.java:422)
at io.netty.handler.ssl.SslContextBuilder.build(SslContextBuilder.java:447)
at pl.test.grpc.GrpcServer.start(GrpcServer.java:80)
at pl.test.app.Main.lambda$new$0(Main.java:80)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: io.netty.internal.tcnative.SSL
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:85)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:194)
at pl.test.grpc.GrpcServer.getSslContextBuilder(GrpcServer.java:72)
... 3 more
I'm building it using command:
mvn clean compile assembly:single
Can someone help with creating working pom file? The result doesn't have to be single jar file, it might be multiple jars.

I found solution, maybe it will help someone deal with the same problem.
We have to add dependency io.netty.netty-handler and set compatible versions of io.grpc.grpc-netty, io.netty.netty-tcnative-boringssl-static and io.netty.netty-handler as it is described in table over here https://github.com/grpc/grpc-java/blob/master/SECURITY.md#netty.
Here's my current pom.xml
[...]
<properties>
<grpc.version>1.17.1</grpc.version>
<protoc.version>3.5.1-1</protoc.version>
<netty.tcnative.version>2.0.17.Final</netty.tcnative.version>
<netty.handler.version>4.1.30.Final</netty.handler.version>
[...]
</properties>
<dependencies>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${grpc.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${netty.handler.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative-boringssl-static</artifactId>
<version>${netty.tcnative.version}</version>
<scope>runtime</scope>
</dependency>
[...]
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}
</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}
</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireUpperBoundDeps/>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>pl.test.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
And now I can build jar using command:
mvn clean compile assembly:assembly

Related

How to Create Spring Boot Thin and Fat Jar in Same Spring Boot Maven Project

I am having a need to build my spring boot project as both fat and thin jar,
Expected output: one fat jar and one thin jar
Actual output: both are fat jars. I extracted and checked, it contains BOOT-INF/lib having jars
Following is my build plugin configuration
spring boot version 2.4.3
spring boot thin version 1.0.25.RELEASE
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>create-fat-jar</id>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
<configuration>
<mainClass>com.mycomp.ExampleApplication</mainClass>
<addResources>true</addResources>
<finalName>${project.artifactId}-fat-${project.version}</finalName>
</configuration>
</execution>
<execution>
<id>create-thin-jar</id>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
<configuration>
<executable>false</executable>
<addResources>true</addResources>
<finalName>${project.artifactId}-thin-${project.version}</finalName>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>${springboot.thin.version}</version>
</dependency>
</dependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Please help me to resolve this issue.
There is an experimental thin layout project from Spring, try to use the below and it will help you.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>1.0.28.BUILD-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
https://github.com/spring-projects-experimental/spring-boot-thin-launcher
I think creating a Fat jar in spring boot is very easy. The part of creating a Thin jar requires special changes in pom.xml file. Let me describe both scenarios here:
In both cases, the top part will be same:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.package</groupId>
<artifactId>YourApplication</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>YourApplication</name>
<description>Your description</description>
<properties>
<java.version>1.8</java.version>
<mainClass>com.package.YourApplication.Main</mainClass>
</properties>
pom.xml for fat jar:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
...
your other dependencies as well...
</dependencies>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.7.1</version>
<configuration>
<executable>true</executable>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugins>
The plugins are important. Because they provide specific build commands to maven.
Now, for thin jar creation:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!-- <scope>provided</scope>-->
</dependency>
...
your other dependencies as well...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.2</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>${mainClass}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
Here, you can see that in dependencies, tomcat provided scope is removed. Also, the plugins have changed. Executing mvn package then mvn install will generate the thin jar and copy all the dependencies outside the jar file in lib/ folder.
I hope this helps you. :)

Scala version error with Spark 2 & ElasticSearch 5.4.2

I'm using Spark 2.2 (build with Scala 2.11.8) to index my data into ElasticSearch 5.4.2.
ElasticSearch :
My project spark use this pom.xml :
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-hadoop</artifactId>
<version>5.4.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch-spark-20_2.11</artifactId>
<version>5.4.2</version>
</dependency>
When I run my job, I get this exception :
Caused by: java.lang.NoSuchMethodError: scala.reflect.api.JavaUniverse.runtimeMirror(Ljava/lang/ClassLoader;)Lscala/reflect/api/JavaMirrors$JavaMirror;
at org.elasticsearch.spark.serialization.ReflectionUtils$.org$elasticsearch$spark$serialization$ReflectionUtils$$checkCaseClass(ReflectionUtils.scala:42)
at org.elasticsearch.spark.serialization.ReflectionUtils$$anonfun$checkCaseClassCache$1.apply(ReflectionUtils.scala:84)
at org.elasticsearch.spark.serialization.ReflectionUtils$$anonfun$checkCaseClassCache$1.apply(ReflectionUtils.scala:83)
I know my problem is Scala version (build/run) ...
Thanks for your help
EDIT BUILD POM :
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<argLine>-J-Xms128m</argLine>
<argLine>-J-Xmx512m</argLine>
<argLine>-J--XX:MaxPermSize=300m</argLine>
<argLine>-Djava.net.preferIPv4Stack=true</argLine>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>UBER</shadedClassifierName>
<artifactSet>
<includes>
<include>com.databricks:spark-csv_${scala.compact.version}</include>
<include>org.apache.commons:commons-csv</include>
<include>org.elasticsearch:elasticsearch-hadoop</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Spring Boot jar executable - How to generate files to different directory similar as maven-dependency-plugin does

As straich question, why spring-boot-maven-plugin works but maven-assembly-plugin not in the pom below?
I have googled few hours and I red somewhere that we don't need maven-assembly-plugin if we use spring-boot-maven-plugin. It doesn't answer my question since I want to have more control in which folder my files are genereated. Along that, if I "mvn clean compile package assembly:single" I get two executable jars, one outcome of spring-boot-maven-plugin and another outcome of maven-assembly-plugin in my project target folder. The one generated by spring-boot-maven-plugin runs as expected when I start via command line (java -jar aws.scheduller-1.jar. On the opposite, if I try java -jar aws.scheduller-1-jar-with-dependencies.jar I get a message complaining that it wasn't possible to load ...config.BootApp (I googled a bit and I guess it is something related to certain default profile in Spring Boot).
That said, how can I use maven to package Spring-boot dependency in different folder than default target directory?
Main Class
#SpringBootApplication
#EnableScheduling
#ComponentScan({ "br.com.mycompany.tasks","br.com.mycompany.utils" })
#PropertySource("file:C:/temp/application.properties")
//#PropertySource("file:/home/ec2-user/JOBs/application.properties")
public class BootApp {
public static void main(String[] args) {
SpringApplication.run(new Object[] { BootApp.class }, args);
}
}
pom.xml
<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>grpAwsScheduller</groupId>
<artifactId>aws.scheduller</artifactId>
<version>1</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceencoding>UTF-8</project.build.sourceencoding>
<logback.version>1.1.9</logback.version>
<logstash-logback-encode.version>4.8</logstash-logback-encode.version>
<spring-boot-starter.version>1.4.3.RELEASE</spring-boot-starter.version>
<aws-java-sdk.version>1.11.73</aws-java-sdk.version>
<jdk.version.version>1.7</jdk.version.version>
<project.build.directory>C:/temp</project.build.directory>
<!-- Maven versions -->
<!-- https://maven.apache.org/plugins/ -->
<maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
<maven-dependency-plugin.version>3.0.0</maven-dependency-plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>${aws-java-sdk.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.73</version>
</dependency>
<!-- <dependency> <groupId>com.amazonaws</groupId> <artifactId>aws-java-sdk-sqs</artifactId>
<version>${aws-java-sdk.version}</version> </dependency> <dependency> <groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sns</artifactId> <version>${aws-java-sdk.version}</version>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback-encode.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<mainClass>br.com.MyCompany.config.BootApp</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>br.com.MyCompany.config.BootApp</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- <excludes> <exclude>**/log4j.properties</exclude> </excludes> -->
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>br.com.MyCompany.config.BootApp</mainClass>
<classpathPrefix>dependency-jars/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven-dependency-plugin.version}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/dependency-jars/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Error using perf4j with aspectj (NoSuchMethodError)

I'm trying to use CTW with aspectj to profile my application (cumulusrdf) with perf4j.
I can compile everything with maven just fine. The console output contains the entry for the method I'm using for getting the profiling to work:
[INFO] --- aspectj-maven-plugin:1.5:compile (default-cli) # cumulusrdf ---
[INFO] Join point 'method-execution(void edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector.bulkLoad(java.io.File, java.lang.String, int))' in Type 'edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector' (AbstractCassandraRdfHector.java:373) advised by around advice from 'org.perf4j.log4j.aop.TimingAspect' (perf4j-0.9.16-log4jonly.jar!AbstractTimingAspect.class(from AbstractTimingAspect.java))
I'm using the goals aspectj:compile package for building. When I try to run the generated one-jar, I get the following exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at edu.kit.aifb.cumulus.cli.Main.main(Main.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.simontuffs.onejar.Boot.run(Boot.java:340)
at com.simontuffs.onejar.Boot.main(Boot.java:166)
Caused by: java.lang.NoSuchMethodError: org.perf4j.log4j.aop.TimingAspect.aspectOf()Lorg/perf4j/log4j/aop/TimingAspect;
at edu.kit.aifb.cumulus.store.AbstractCassandraRdfHector.bulkLoad(AbstractCassandraRdfHector.java:373)
at edu.kit.aifb.cumulus.cli.Load.main(Load.java:161)
... 11 more
I don't use any parameters, except the ones for my application.
In my pom.xml, I have the following related sections:
The definition of the aspectj plugin:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.5</version>
<configuration>
<aspectLibraries>
<aspectLibrary>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<classifier>log4jonly</classifier>
</aspectLibrary>
</aspectLibraries>
<source>1.6</source>
<target>1.6</target>
<complianceLevel>1.6</complianceLevel>
<verbose>true</verbose>
<showWeaveInfo>true</showWeaveInfo>
<weaveMainSourceFolder>true</weaveMainSourceFolder>
</configuration>
<!--<executions>
<execution>
<goals>
<goal>compile</goal> <! use this goal to weave all your main classes >
</goals>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
</configuration>
</execution>
</executions>-->
</plugin>
<!-- ... -->
</plugins>
The dependencies of the related artifacts:
<dependencies>
<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<version>0.9.16</version>
<classifier>log4jonly</classifier>
</dependency>
<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<version>0.9.16</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>commons-jexl</groupId>
<artifactId>commons-jexl</artifactId>
<version>1.1</version>
</dependency>
<!-- ... -->
</dependencies>
The definition of the one-jar plugin:
<plugins>
<plugin>
<groupId>org.dstovall</groupId>
<artifactId>onejar-maven-plugin</artifactId>
<version>1.4.4</version>
<executions>
<execution>
<configuration>
<mainClass>edu.kit.aifb.cumulus.cli.Main</mainClass>
<onejarVersion>0.97</onejarVersion>
<attachToBuild>true</attachToBuild>
<classifier>onejar</classifier>
</configuration>
<goals>
<goal>one-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- ... -->
</plugins>
Does someone know what I'm doing wrong?
Try
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<complianceLevel>1.6</complianceLevel>
<verbose>true</verbose>
<showWeaveInfo>true</showWeaveInfo>
<weaveMainSourceFolder>true</weaveMainSourceFolder>
<weaveDependencies>
<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<classifier>log4jonly</classifier>
</dependency>
</weaveDependencies>
</configuration>
<executions>
<execution>
<id>aspectj-compile</id>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>

Maven ftp site plugin

I want to upload my site directly into my ftp server. I'm tring to configure my pom.xml but I've some problem with plugin. I've read many guides on-line but none is unique, or at least there are strong differences.
Have you any tip or trick?
<profile>
<id>deploy</id>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<configuration>
<target>
<ftp action="send" server="server"
remotedir="/a/b" userid="usr"
password="pw" depends="no"
verbose="yes" binary="yes">
<fileset dir="modules/my-module/target">
<include name="my-static-file.zip" />
</fileset>
</ftp>
<taskdef name="ftp" classname="org.apache.tools.ant.taskdefs.optional.net.FTP"
classpathref="maven.plugin.classpath" />
</target>
</configuration>
<dependencies>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-commons-net</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.6.5</version>
</dependency>
<dependency>
<groupId>jsch</groupId>
<artifactId>jsch</artifactId>
<version>0.1.29</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
Now this is my pom.xml.
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>2.2</version>
</extension>
</extensions>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-4</version>
<configuration>
<skip>false</skip>
<serverId>ftpserver</serverId>
<url>ftp://---.---.----.---/var/www/html</url>
</configuration>
<executions>
<execution>
<id>upload</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>${project.basedir}/target/${project.artifactId}-${project.version}/</fromDir>
<includes>*</includes>
<toDir></toDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
I'm using Eclipse 3.7, when I use Run As -> Maven Install all go in right way, but I would like to launch deploy phase for upload all into my ftp server.
How I configure Eclipse? My POM is correct for this task now?
Instead of maven-antrun-plugin it is better to use upload goal of maven-wagon-plugin. Here is an example project demonstrating uploading multiple files to ftp.

Resources