Java/Swing/Maven: no main manifest attribute - java

When I'm in NetBeans environment, I run my Jasper report normally. But when I try the command line:
java -jar C: \ ... \ mySwingProject.jar
I am getting the following error message:
no main manifest attribute in C: \ ... \ mySwingProject.jar
My pom.xml follows:
<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>br.jus.tjmg</groupId>
<artifactId>RhServidoresDesligados</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>RhServidoresDesligados</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>br.jus.tjmg.rhservidoresdesligados.JFramePrincipal</mainClass>
</manifest>
</archive>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<url>http://download.eclipse.org/rt/eclipselink/maven.repo/</url>
<id>eclipselink</id>
<layout>default</layout>
<name>Repository for library EclipseLink (JPA 2.1)</name>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>11.2.0</version>
</dependency>
</dependencies>
</project>
What could be wrong?

To create executable jar file use maven-jar-plugin instead. Seems you mistyped.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>br.jus.tjmg.rhservidoresdesligados.JFramePrincipal</mainClass>
</manifest>
</archive>
</configuration>
</plugin>

Works fine! 'artifactId' tag value was incorrect!

Related

Spring jar versions are not compatible and therefore I am getting compiler errors. Need help in identifying which dependency is causing the issue

I have the following pom file:
<?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>
<parent>
<groupId>com.cnt.orchtn</groupId>
<artifactId>orchtn-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../orchtn-parent/pom.xml</relativePath>
</parent>
<groupId>com.dsfsdaf.orchtn</groupId>
<artifactId>orchen-con-service</artifactId>
<version>1.0-RELEASE</version>
<name>OrchServi</name>
<description>Orch</description>
<packaging>jar</packaging>
<properties>
<java.version>11</java.version>
<camel.version>3.1.0</camel.version>
<jackson.version>1.9.13</jackson.version>
<kafka.version>2.6.0</kafka.version>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-kafka-starter</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http</artifactId>
<version>3.1.0</version>
<!-- use the same version as your Camel core version -->
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<!-- <version>2.10.0</version> -->
<version>2.11.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20200518</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<!-- This dependency is for WebClient implementation -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>jolt-core</artifactId>
<version>0.0.17</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.11.3</version>
</dependency>
<dependency>
<groupId>com.bazaarvoice.jolt</groupId>
<artifactId>json-utils</artifactId>
<version>0.0.10</version>
</dependency>
<!-- <dependency>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>3.0.0</version>
</dependency>
-->
</dependencies>
<repositories>
<repository>
<id>cnc-clg-srd-cbf-artifactory--cnc-clg-srd-cbf-artifactory</id>
<name>cnc-clg-srd-cbf-artifactory--cnc-clg-srd-cbf-artifactory</name>
<url>https://cnc-clg-srd-cbf-artifactory-255474220078.d.codeartifact.us-east
1.amazonaws.com/maven/cnc-clg-srd-cbf-artifactory/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>Maven-Artifactory-Plugin</id>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</id>
<name>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</name>
<url>https://cnc-clng-srd-cbf-artifactory-255474220078.d.codeartifact.us-east
1.amazonaws.com/maven/cnc-clng-srd-cbf-artifactory/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<goals>
<goal>jar</goal>
</goals>
</plugin>
<!-- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
I have the following parent 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>
<groupId>com.cnt.orctr</groupId>
<artifactId>orctr-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>Orch Parent</description>
<packaging>pom</packaging>
<url>http://maven.apache.org</url>
<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.3.4.RELEASE</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<profile>
<id>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</id>
<name>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</name>
<url>https://cnc-clng-srd-cbf-artifactory-255474220078.d.codeartifact.us-east
1.amazonaws.com/maven/cnc-clng-srd-cbf-artifactory/</url>
</repository>
</profile>
</profiles>
<pluginRepositories>
<pluginRepository>
<id>Maven-Artifactory-Plugin</id>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</id>
<name>cnc-clng-srd-cbf-artifactory--cnc-clng-srd-cbf-artifactory</name>
<url>https://cnc-clng-srd-cbf-artifactory-255474220078.d.codeartifact.us-east
1.amazonaws.com/maven/cnc-clng-srd-cbf-artifactory/</url>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
<!--<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>3.0.0</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<artifactory>
<includeEnvVars>true</includeEnvVars>
<envVarsExcludePatterns>*password*,*secret*,*key*,*token*,*passphrase*</envVarsExcludePatterns>
<timeoutSec>60</timeoutSec>
</artifactory>
<publisher>
<contextUrl>https://cnc-clng-srd-cbf-artifactory-255474220078.d.codeartifact.us-east-1.amazonaws.com/maven/cnc-clng-srd-cbf-artifactory/</contextUrl>
<username>aws</username>
<password>${env.CODEARTIFACT_AUTH_TOKEN}</password>
<repoKey>libs-release-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
<!-- <buildInfo> <buildName>centene-framework</buildName> <buildNumber>${buildnumber}</buildNumber>
<buildUrl>http://build-url.org</buildUrl> </buildInfo> -->
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
I am able to compile and deploy the parent project into the repository. The problem is with the child project which I am not able to compile, it is throwing build failures. It is not able to resolve any dependencies which are referenced in the parent project.
Could anyone let me know what I am missing and how I can reference the parent pom in the child pom, and have all the dependencies resolved in the child project.
Note: I have seen all the child pom being referenced in many web sites. I dont see any difference in any way that I am doing it. Maybe noticing something here. Could some one point out...

Sure-fire plugin error (even though i have it in my pom.xml) when i do "maven install" on my java project in eclipse

I am new to using Maven, so i might be missing something. I keep getting the below error, every time i run "maven install" or "maven test". I have already tried adding the sure-fire plugin to my pom.xml file. Which i have added below. What else could be causing the problem?
Here is the error that keeps popping up in my console every time i run the command
Here is the pom.xml for my project, where i have added the sure-fire plugin:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.company.Project</groupId>
<artifactId>myprofile</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>myprofile</name>
<description>Service to retrieve my profile</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<vertx.version>3.6.0</vertx.version>
<junit-jupiter.version>5.1.0</junit-jupiter.version>
<assertj-core.version>3.8.0</assertj-core.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-dependencies</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web-client</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-junit5</artifactId>
<version>${vertx.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.23.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.0.3</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>io.vertx.core.Launcher</Main-Class>
<Main-Verticle>com.company.Project.myProfileVerticle</Main-Verticle>
</manifestEntries>
</transformer>
</transformers>
<artifactSet/>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Deploy to Nexus -->
<distributionManagement>
<repository>
<id>Projectreleases</id>
<url>http://artifactory.company.local/artifactory/ProjectReleases/</url>
</repository>
<snapshotRepository>
<id>Projectsnapshots</id>
<url>http://artifactory.company.local/artifactory/ProjectSnapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
The problem is because dependency junit-jupiter-engine inside build plugin is different from dependency declared on dependencies (5.0.3 versus 5.1.0).

Maven: Why do I need to mention classpath if the code if already compiled into the jar?

This question follows Maven: What does the following pom.xml file gives empty jar?.
Let's say this is my pom.xml 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.earnix.eo</groupId>
<artifactId>EOParent</artifactId>
<version>8.8.4.0-SNAPSHOT</version>
<relativePath>../EOParent/pom.xml</relativePath>
</parent>
<artifactId>PricingBatch</artifactId>
<name>PricingBatch</name>
<properties>
<websphere.folder>C:\ibm\WebSphere\AppServer</websphere.folder>
</properties>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.earnix.eo</groupId>
<artifactId>Tools</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earnix.eo</groupId>
<artifactId>EarnixShared</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earnix.eo</groupId>
<artifactId>EOGUI</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earnix.eo</groupId>
<artifactId>EOSessions</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.earnix.eo</groupId>
<artifactId>EOUtils</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>sample1</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${websphere.folder}\lib\bootstrap.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>sample2</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${websphere.folder}\runtimes\com.ibm.ws.webservices.thinclient_8.5.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>sample3</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${websphere.folder}\java\jre\lib\xml.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>sample4</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${websphere.folder}\java\jre\lib\ibmorb.jar</systemPath>
</dependency>
</dependencies>
<build>
<finalName>PricingBatch</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.earnix.tools.batchpricing.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
</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>
</plugins>
</build>
</project>
As you can see it has 9 dependencies. Since I used maven-assembly-plugin I expect that all dependencies will be packed inside the output jar (named PricingBatch.jar). However, when I run the output jar, it cannot run if I don't mention 3 of the 9 dependencies in the classpath.
I must run is as:
java -Xmx300M -classpath
"C:\IBM\WebSphere\AppServer\runtimes\com.ibm.ws.webservices.thinclient_8.5.0.jar;"C:\Repositories\EO_Websphere\PricingBatch\target\PricingBatch.jar";C:\Repositories\EO_Websphere\EOGUI\target\EOGUI.jar"
com.earnix.tools.batchpricing.Main %*
My question is why when I mention only the PricingBatch.jar in the classpath,
java -classpath PricingBatch.jar com.earnix.tools.batchpricing.Main -Xmx300M %*
I get an error?

Maven upgraded DROOLS version and now can no longer build

I am new to maven and java. I am working on a Java/DROOLS project. I was experiencing errors which seemed to be fixed with the next version of DROOLS. I changed the version in my pom.xml and then did mvn package.
The files were downloaded but every line of code that references DROOLS throws a compile error of package org.drools does not exist.
[ERROR] /C:/Dev/src/main/java/com/company/project/drools/client/DroolsRulesRunner.java:[11,18] package org.drools does not exist
[ERROR] /C:/Dev/src/main/java/com/company/project/drools/client/DroolsRulesRunner.java:[12,29] package org.drools.definition does not exist
Any help would be greatly appreciated.
Edit
Here is my pom.xml.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bericotechnologies</groupId>
<artifactId>sbt-rules</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>my-app</name>
<url>http://maven.apache.org</url>
<properties>
<drools.version>7.6.0.Final</drools.version>
<jbpm5.version>7.6.0.Final</jbpm5.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.12</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow</artifactId>
<version>${jbpm5.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>${jbpm5.version}</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-flow-builder</artifactId>
<version>${jbpm5.version}</version>
</dependency>
<dependency>
<groupId>pl.maciejwalkowiak</groupId>
<artifactId>junit-drools</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.core</artifactId>
<version>2.6.3</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc4</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.rzo.yajsw</groupId>
<artifactId>wrapper</artifactId>
<version>11.11</version>
</dependency>
<dependency>
<groupId>org.rzo.yajsw</groupId>
<artifactId>wrapperApp</artifactId>
<version>11.11</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jboss</id>
<name>jboss</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>maciejwalkowiak.pl</id>
<url>https://github.com/maciejwalkowiak/maven-repo/raw/releases/</url>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/main/rules</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.sortpom</groupId>
<artifactId>maven-sortpom-plugin</artifactId>
<version>2.3.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sort</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.berico.psip.run.RunDroolsService</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
The only thing that I changed is
<properties>
<drools.version>5.6.0.Final</drools.version>
<jbpm5.version>5.5.0.Final</jbpm5.version>
</properties>
to
<properties>
<drools.version>7.6.0.Final</drools.version>
<jbpm5.version>7.6.0.Final</jbpm5.version>
</properties>
If I change it back everything works fine. I can see the 7.6.0.Final jars in the repository.
You have broken imports and you have to fix them.
There's changes in the package structure of Drools between versions 5.6.0.Final and 7.6.0.Final. The package "definitions" is now under org.drools.core.definitions (v7.6.0.Final) and not under org.drools.definitions (5.6.0.Final).
You need to remove all imports beginning with org.drools in your classes and re-import the missing Drools classes again with the new package locations - those from version 7.6.0.Final.

Why I am getting NoClassDefFoundError even after I have included right dependencies in POM?

I am trying to build my application and ship the jar file to users. It is bulding fine, but it is giving problem when I am trying to run the jar.
I am trying to run jar file compiled from mvn package command. After that, I am running java -jar ApplicationRunner.jar, but I am getting below exception. Note that when I am running through Intellij Idea IDE - it works fine
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/JsonProcessingException
at cs550.pa3.ApplicationRunner.<init>(ApplicationRunner.java:27)
at cs550.pa3.ApplicationRunner.main(ApplicationRunner.java:39)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.core.JsonProcessingException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
My pom.xml file -
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>FileSharingSystem</groupId>
<artifactId>FileSharingSystem-1</artifactId>
<version>3.1-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Make this jar executable -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<archive>
<manifest>
<mainClass>cs550.pa3.ApplicationRunner</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-all -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.1</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<!--<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.4</version>
</dependency>-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.6.5</version>
</dependency>
</dependencies>
</project>
If you want to provide an executable jar to the client you should add the required dependencies in the jar.
You could use the maven-assembly-plugin to create a jar including dependencies :
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>cs550.pa3.ApplicationRunner</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
As #davidxxx mentioned, we need to build it with dependencies. For future reference it 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>FileSharingSystem</groupId>
<artifactId>FileSharingSystem</artifactId>
<version>3.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>File Sharing System</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.8</jdk.version>
<jodatime.version>2.5</jodatime.version>
<junit.version>4.12</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.6.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>FileSharingSystem</finalName>
<plugins>
<!-- download source code in Eclipse, best practice -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
</configuration>
</plugin>
<!-- Set a compiler level -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- Maven Assembly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- MainClass in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>cs550.pa3.ApplicationRunner</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Categories