Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7 - maven

I was developing a project on JBoss-Fuse from Create a Router Project.
While running mvn -install , I am getting following error:
[ERROR] Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7:bundle (default-bundle) on project camel-basic: Error calculating classpath for project MavenProject: org.fusesource.example:camel-basic:1.0-SNAPSHOT # /home/pr.singh/Gemini/Java-General/Workspace/fuse/camel-basic/pom.xml: The JAR/ZIP file (/home/pr.singh/.m2/repository/org/apache/camel/camel-jetty/2.17.0.redhat-630187/camel-jetty-2.17.0.redhat-630187.jar) seems corrupted, error: invalid END header (bad central directory offset) -> [Help 1]
I exactly following the redhat tutorial, I am unable to debug the problem. Please help.
My pom.xml is :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.fusesource.example</groupId>
<artifactId>camel-basic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>JBoss Fuse Quickstart: camel-cbr</name>
<description>Camel Content-Based Router Example</description>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<distribution>repo</distribution>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
</license>
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.compiler.plugin>2.3.1</version.compiler.plugin>
<version.maven-bundle-plugin>2.3.7</version.maven-bundle-plugin>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<!-- the version of the BOM, defining all the dependency versions -->
<fabric8.bom.version>1.2.0.redhat-630187</fabric8.bom.version>
<fabric.version>1.2.0.redhat-630187</fabric.version>
<!-- fabric8 deploy profile configuration -->
<fabric8.profile>camel-basic-profile</fabric8.profile>
<fabric8.parentProfiles>feature-camel</fabric8.parentProfiles>
<fabric8.features/>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.fabric8.bom</groupId>
<artifactId>fabric8-bom</artifactId>
<version>${fabric8.bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!--
For this example, we will be using the OSGi Blueprint XML syntax for Apache Camel.
-->
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-blueprint</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jetty</artifactId>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${version.compiler.plugin}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${version.maven-bundle-plugin}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<!--
this plugin will use the fabric.* properties to configure its behaviour
see the Properties section here: http://fabric8.io/gitbook/mavenPlugin.html
-->
<groupId>io.fabric8</groupId>
<artifactId>fabric8-maven-plugin</artifactId>
<version>${fabric.version}</version>
</plugin>
</plugins>
</build>
</project>

After digging a bit about the issue, I found the solution to it.
After reading the line of error code that says:
Failed to execute goal org.apache.felix:maven-bundle-plugin:2.3.7:bundle
I thought there is some issue with org.apace.felix, but later I paid attention to the line of error that was stating :
The JAR/ZIP file (/home/pr.singh/.m2/repository/org/apache/camel/camel-jetty/2.17.0.redhat-630187/camel-jetty-2.17.0.redhat-630187.jar) seems corrupted
Issue:
So the issue was that my camel-jetty jar was corrupted.
Solution:
I simple navigated to /home/pr.singh/.m2/repository/org/apache/camel and deleted camel jetty.
Run mvn clean install on project and new file with name camel jetty was created (maven installed this plugin). And error was gone.

Related

Managing Maven plugin versions with Spring Boot BOM

I have a Maven POM for a Spring Boot project. The POM imports the Spring Boot BOM. Now I want to customize the configuration of a Maven plugin, say, mvn-compiler-plugin. I'd like to use the plugin version maven-compiler-plugin.version dictated by the spring-boot-dependencies BOM.
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.ge.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<spring-boot.version>2.4.2</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- Spring Boot BOM -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
</plugins>
</build>
</project>
But this does work: I come up with a Maven error:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin must be a valid version but is '${maven-compiler-plugin.version}'. # line 31, column 26
So I have to explicitly specify the version of the Maven plugin, which I want to avoid.
In summary:
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
yields a Maven error.
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
works, but prevents me from using the version (3.8.1) dictated by the Spring Boot BOM.
Using
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
works, but uses an old version (3.1) of the plugin.
How can I avoid to explicitly specify the plugin version and instead implicitly use the plugin version provided in the Spring Boot BOM?
If you want to override Spring Boot dependencies by simply updating properties, you have to specify the parent POM instead of importing:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.ge.mygroup</groupId>
<artifactId>myartifact</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.2</version>
<relativePath/>
</parent>
<properties>
<spring-boot.version>2.4.2</spring-boot.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!-- some particular config here -->
</configuration>
</plugin>
</plugins>
</build>
</project>

Plugin org.apache.maven.plugins: dependencies could not be resolved

I am trying to build a simple web API using dynamic web maven project.
When I run my project as maven project with the goals of clean install. I get this error:
Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Cannot access https://repo.maven.apache.org/maven2 with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access https://repo.maven.apache.org/maven2 using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
role: org.apache.maven.wagon.Wagon
Here is my POM file, it might be useful as it is where the dependencies are stated:
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>group5</groupId>
<artifactId>studentService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<maven.compiler.source>7</maven.compiler.source>
<maven.compiler.target>7</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.axis/axis -->
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.xml.rpc/javax.xml.rpc-api -->
<dependency>
<groupId>javax.xml.rpc</groupId>
<artifactId>javax.xml.rpc-api</artifactId>
<version>1.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt -->
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.6</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am aware of this question: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved
However the proxy solution did not work for me. (I have never made a proxy before).
Any help appreciated.

Cannot include project artifact: com.test.mmm.jar:1.0; it doesn't have an associated file or directory

I'm pretty lost with maven and I can't seem to find a solution for my problem. When I try to generate the jar file with all the dependencies of my project to execute it on another computer I find this warning when I execute sudo mvn clean compile assembly:single:
[WARNING] Cannot include project artifact: com.test:mmm:jar:1.0; it doesn't have an associated file or directory.
Also, when I try to execute the .jar with java -jar target/test.jar this error appears:
Error: Unable to access jarfile target/test.jar
here's my 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>com.test</groupId>
<artifactId>mmm</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>mmm</name>
<url>http://maven.apache.org</url>
<properties>
<nd4j.backend>nd4j-cuda-8.0-platform</nd4j.backend>
</properties>
<dependencies>
<dependency>
<groupId>org.jblas</groupId>
<artifactId>jblas</artifactId>
<version>1.2.4</version>
</dependency>
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-platform</artifactId>
<version>0.8.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.deeplearning4j</groupId>
<artifactId>deeplearning4j-core</artifactId>
<version>0.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<archive>
<manifest>
<mainClass>com.test.mmm.Main</mainClass>
</manifest>
</archive>
<finalName>test</finalName>
<descriptorRefs>jar-with-dependencies</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
The main class is located in src/
I've tried many solutions from stack overflow but had no success, can someone help me?
Thank you!
Use mvn package first to build your module classes then assembly:single.
mvn package assembly:single
From the warning you've included in your question:
[WARNING] Cannot include project artifact: Amjar:amjar:pom:0.2; it doesn't have an associated.
I'd guess that you've got the packaging in your pom.xml set to pom.
This is fine if your module is simply packaging a set of dependencies or resource files, however, if you also want Maven to create a jar containing the classes in you module you will need to set the packaging to jar.
make sure that your atrifact produced is matching with <finalName>
i.e.
<groupId>com.rocket</groupId>
<artifactId>myapp</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>myapp</name>
produces myapp-1.0.jar
and provide same here
<finalName>myapp-1.0</finalName>
and run then execute:
mvn package assembly:single

Compile MPAndroidChart lib with jar output instead of aar

How do I compile the MPAndroidChart library as jar instead of an aar? If I run gradle assembleDebug it will generate me an aar, but I see in the old MPAndroidChart distributions that they already provided a jar dependency.
I didn't find anything realted to gradle compile instructions in the readme file. Also "gradle tasks" didn't help me.
Any help here?
Thanks.
This question has been asked a while ago, but this is a reference for future developers.
Create an eclipse project, with the exact package structure that you see on the Android MPAndroidChartLib (https://github.com/PhilJay/MPAndroidChart/releases)
convert the project to a Maven project (right-click, configure, convert to maven project.
replace the generated pom.xml with the following :
<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.github.mikephil</groupId>
<artifactId>MPAndroidChart</artifactId>
<version>1.4.2-SNAPSHOT</version>
<name>MPAndroidChart</name>
<description>A simple Android chart view/graph view library, supporting line- bar- and piecharts as well as scaling, dragging and animations</description>
<url>https://github.com/PhilJay/MPAndroidChart</url>
<packaging>jar</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jdk.version>1.7</jdk.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<scope>provided</scope>
<version>4.1.1.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
</dependency>
</dependencies>
<issueManagement>
<url>https://github.com/PhilJay/MPAndroidChart/issues</url>
<system>GitHub Issues</system>
</issueManagement>
<licenses>
<license>
<name>Apache License Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>https://github.com/PhilJay/MPAndroidChart</url
<connection>scm:git:git://github.com/PhilJay/MPAndroidChart.git</connection>
<developerConnection>scm:git:git#github.com:PhilJay/MPAndroidChart.git</developerConnection>
</scm>
<developers>
<developer>
<name>Philipp Jahoda</name>
<email>philjay.librarysup#gmail.com</email>
<url>http://stackoverflow.com/users/1590502/philipp-jahoda</url>
<id>PhilJay</id>
</developer>
</developers>
</project>
right-click on the pom and click on maven install
you'll find the jar under : /target

maven-schemaspy-plugin doesn't work (maybe it's a repository issue)

I want to generate a er-diagram from a database integrated in the maven lifecycle.
SchemaSpy generates the er-diagram and with the maven-schemaspy-plugin it should be possible to integrate this in the lifecyle-process.
(If anyone has a better idea for this please let me know)
I tried it with the following simple pom.xml (which only should generate the er-diagram); but the plugin doesn't start; it couldn't even be downloaded:
<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>test.schemaspy</groupId>
<artifactId>SchemaSpyGenerateDB_02</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SchemaSpyGenerateDB_02</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<type>plugin</type>
</dependency>
</dependencies>
<!-- To use the report goals in your POM or parent POM -->
<reporting>
<plugins>
<plugin>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.1</version>
<configuration>
<databaseType>derby</databaseType>
<database>JPACertifiaction_Relationship</database>
<host>localhost</host>
<port>1527</port>
<user>user</user>
<password>password</password>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
The command
mvn site:site
causes the message
The POM for maven-plugins:maven-schemaspy-plugin:jar:1.0 is missing, no dependency information available
The POM for maven-plugins:maven-schemaspy-plugin:plugin:1.0 is missing, no dependency information available
I've also tried it with the following settings with no success:
<dependency>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>5.0.1</version>
</dependency>
....
<reporting>
<plugins>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>5.0.1</version>
....
<repository>
<id>Wakaleo Repository</id>
<url>http://maven.wakaleo.com/mojo/maven-schemaspy-plugin/</url>
</repository>
What me also confuses is that there are different reposititories with different versions 1.0 / 5.0.1 so what is really the official one ?
You don't need the entries
<dependencies>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>maven-plugins</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0</version>
<type>plugin</type>
</dependency>
</dependencies>
delete them. When you define a plugin (plugin section later) it gots downloaded by maven automatically. Your error message says that 1.0 is missing, but your plugin is 1.1, so it doesn'T fit to your dependencies anyway.
The maven-schemaspy-plugin and the com.wakaleo.schemaspy plugin are different plugins from different authors. None of them is the "official schemaspy" maven plugin. I was only able to solve it with the wakaleo plugin (with maven 3). The other plugin seams not to be available any more.
With Maven 3 the site generation changed, see site generation in Maven 3. As mentioned in this blog entry you have to include the plugin in this way (note that the versioning has changed):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.1</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>com.wakaleo.schemaspy</groupId>
<artifactId>maven-schemaspy-plugin</artifactId>
<version>1.0.4</version>
<configuration>
<databaseType>derby</databaseType>
<database>JPACertifiaction_Relationship</database>
<host>localhost</host>
<port>1527</port>
<user>user</user>
<password>password</password>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
and you need the link to the repository:
<pluginRepositories>
<pluginRepository>
<id>Wakaleo Repository</id>
<url>http://www.wakaleo.com/maven/repos/</url>
</pluginRepository>
</pluginRepositories>
Then the plugin starts. The rest is up to you :-)

Resources