I have 2 maven projects: 1 a jar with different dependencies and a war that include all that jar.
When I look inside the created Jar I dont see any library folder. And when I look in to the War I only see the libs that the war is using and not the libraries that the jar is using.
So where those libs come from during execution? Am I missing something about the execution phase?
This is my Jar 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>utils</groupId>
<artifactId>configureUtils</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>configureUtils</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
</project>
This is the War 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.mkyong</groupId>
<artifactId>CounterWebApp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>CounterWebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.8</jdk.version>
<spring.version>4.1.1.RELEASE</spring.version>
<jstl.version>1.2</jstl.version>
<junit.version>4.11</junit.version>
<logback.version>1.0.13</logback.version>
<jcl-over-slf4j.version>1.7.5</jcl-over-slf4j.version>
</properties>
<dependencies>
<!-- Unit Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
</dependency>
<!-- Spring Core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${jcl-over-slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>${jstl.version}</version>
</dependency>
<dependency>
<groupId>utils</groupId>
<artifactId>configureUtils</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>CounterWebApp</finalName>
<plugins>
<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>
<!-- For Tomcat -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/CounterWebApp</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
Libs that are being used in the jar are managed by the parent container and should not be part of the Jar it self. This insures that Jars staying small and we can link to the same library if we used it in 2 different jars.
When installing the Jar to your local repository 2 files are being created - The Jar it self and a pom file which describes the Jar dependencies. That file was empty due to a bad maven execution.
The best way to install a jar is using:
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>
This command. - Check how different the POM is. More info can be found here
Related
I'm trying to run an appliaction using spring framework, but an exception is always raised :
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/unit/DataSize
at org.springframework.boot.convert.StringToDataSizeConverter.getConvertibleTypes(StringToDataSizeConverter.java:40)
at org.springframework.core.convert.support.GenericConversionService$Converters.add(GenericConversionService.java:507)
at org.springframework.core.convert.support.GenericConversionService.addConverter(GenericConversionService.java:105)
at org.springframework.boot.convert.ApplicationConversionService.addApplicationConverters(ApplicationConversionService.java:107)
at org.springframework.boot.convert.ApplicationConversionService.configure(ApplicationConversionService.java:91)
at org.springframework.boot.convert.ApplicationConversionService.<init>(ApplicationConversionService.java:52)
at org.springframework.boot.convert.ApplicationConversionService.<init>(ApplicationConversionService.java:45)
at org.springframework.boot.convert.ApplicationConversionService.getSharedInstance(ApplicationConversionService.java:71)
at org.springframework.boot.SpringApplication.configureEnvironment(SpringApplication.java:472)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:340)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at fr.edf.as.meteo.MeteoedfApp.main(MeteoedfApp.java:67)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.unit.DataSize
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)
... 12 more
There are 2 modules : commons and editic, both of them has a pom.xml file :
commons 'pom :
<?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">
<parent>
<artifactId>meteoedf</artifactId>
<groupId>fr.edf.as.meteo</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>commons</artifactId>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.1.8.RELEASE</version>
</dependency>
<dependency>
<groupId>fr.edf.as.meteo</groupId>
<artifactId>editic</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>5.2</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster-framework</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>5.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>5.2.17.Final</version>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
<version>3.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem</artifactId>
<version>0.21.0</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-violations</artifactId>
<version>0.24.0-RC.0</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
<version>0.24.0-RC.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>3.5.3</version>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-spring-service-connector</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate5</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-afterburner</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>5.0.11.RELEASE</version>
</dependency>
<dependency>
<groupId>io.undertow</groupId>
<artifactId>undertow-core</artifactId>
<version>1.4.26.Final</version>
</dependency>
<dependency>
<groupId>io.github.jhipster</groupId>
<artifactId>jhipster-framework</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
**editic's pom : **
<?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">
<parent>
<groupId>fr.edf.as.meteo</groupId>
<artifactId>meteoedf</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>fr.edf.as.meteo</groupId>
<artifactId>editic</artifactId>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.12.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.12.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.2.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.13.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.0.12.RELEASE</version>
</dependency>
</dependencies>
</project>
**And the main pom : **
<?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>fr.edf.as.meteo</groupId>
<artifactId>meteoedf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>editic</module>
<module>commons</module>
</modules>
<packaging>pom</packaging>
<name>Meteoedf</name>
<repositories>
<!-- more information at https://blogs.oracle.com/dev2dev/entry/how_to_get_oracle_jdbc -->
<repository>
<id>maven.oracle.com</id>
<name>oracle-maven-repo</name>
<url>https://maven.oracle.com</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</repository>
<!-- jhipster-needle-mafr.edf.as.meteo.editic.repositorytory -->
</repositories>
<pluginRepositories>
<!-- jhipster-needle-maven-plufr.edf.as.meteo.editic.repositorytory -->
</pluginRepositories>
<!-- jhipster-needle-distribution-management -->
<properties>
<!-- Build properties -->
<maven.version>3.0.0</maven.version>
<java.version>1.8</java.version>
<scala.version>2.12.6</scala.version>
<node.version>v10.15.0</node.version>
<npm.version>6.4.1</npm.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<project.testresult.directory>${project.build.directory}/test-results</project.testresult.directory>
<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>
<argLine>-Djava.security.egd=file:/dev/./urandom -Xmx256m</argLine>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
<run.addResources>false</run.addResources>
<!-- These remain empty unless the corresponding profile is active -->
<profile.no-liquibase />
<profile.swagger />
<profile.tls />
<!-- Dependency versions -->
<jhipster-dependencies.version>2.1.1</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>2.1.8.RELEASE</spring-boot.version>
<!-- The hibernate version should match the one managed by
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} -->
<hibernate.version>5.2.17.Final</hibernate.version>
<!-- The javassist version should match the one managed by
https://mvnrepository.com/artifact/org.hibernate/hibernate-core/${hibernate.version} -->
<javassist.version>3.22.0-GA</javassist.version>
<!-- The liquibase version should match the one managed by
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies/${spring-boot.version} -->
<liquibase.version>3.5.5</liquibase.version>
<liquibase-hibernate5.version>3.6</liquibase-hibernate5.version>
<validation-api.version>2.0.1.Final</validation-api.version>
<mapstruct.version>1.2.0.Final</mapstruct.version>
<!-- Sonar properties -->
<sonar.host.url>http://localhost:9001</sonar.host.url>
<sonar.exclusions>commons/src/main/webapp/content/**/*.*, commons/src/main/webapp/i18n/*.js, commons/target/www/**/*.*</sonar.exclusions>
<sonar.issue.ignore.multicriteria>S3437,S4684,UndocumentedApi,BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria>
<!-- Rule https://sonarcloud.io/coding_rules?open=Web%3ABoldAndItalicTagsCheck&rule_key=Web%3ABoldAndItalicTagsCheck is ignored. Even if we agree that using the "i" tag is an awful practice, this is what is recommended by http://fontawesome.io/examples/ -->
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>src/main/webapp/app/**/*.*</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.resourceKey>
<sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>Web:BoldAndItalicTagsCheck</sonar.issue.ignore.multicriteria.BoldAndItalicTagsCheck.ruleKey>
<!-- Rule https://sonarcloud.io/coding_rules?open=squid%3AS3437&rule_key=squid%3AS3437 is ignored, as a JPA-managed field cannot be transient -->
<sonar.issue.ignore.multicriteria.S3437.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S3437.resourceKey>
<sonar.issue.ignore.multicriteria.S3437.ruleKey>squid:S3437</sonar.issue.ignore.multicriteria.S3437.ruleKey>
<!-- Rule https://sonarcloud.io/coding_rules?open=squid%3AUndocumentedApi&rule_key=squid%3AUndocumentedApi is ignored, as we want to follow "clean code" guidelines and classes, methods and arguments names should be self-explanatory -->
<sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.UndocumentedApi.resourceKey>
<sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>squid:UndocumentedApi</sonar.issue.ignore.multicriteria.UndocumentedApi.ruleKey>
<!-- Rule https://sonarcloud.io/coding_rules?open=squid%3AS4684&rule_key=squid%3AS4684 -->
<sonar.issue.ignore.multicriteria.S4684.resourceKey>src/main/java/**/*</sonar.issue.ignore.multicriteria.S4684.resourceKey>
<sonar.issue.ignore.multicriteria.S4684.ruleKey>squid:S4684</sonar.issue.ignore.multicriteria.S4684.ruleKey>
<sonar.jacoco.reportPaths>${project.testresult.directory}/coverage/jacoco/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
<sonar.typescript.lcov.reportPaths>${project.testresult.directory}/lcov.info</sonar.typescript.lcov.reportPaths>
<sonar.sources>${project.basedir}/src/main/</sonar.sources>
<sonar.junit.reportsPath>${project.testresult.directory}</sonar.junit.reportsPath>
<sonar.tests>${project.basedir}/src/test/</sonar.tests>
<!-- jhipster-needle-maven-property -->
</properties>
</project>
I searched on the Internet but it seems like this error isn't common, and might be linked with dependencies' version ?
Thank you
Problem is mismatching Spring Boot (2.1.8.RELEASE) and Spring Core (5.0.12) versions. Core is 5.0.12, because it is transitive dependency of spring-beans 5.0.12.
DataSize is part Spring Core since 5.1. Boot version 2.1.x expects Core 5.1, as one can see from release notes. Exact version one can found from pom.xml.
One can of course define versions manually, but that is lot of works - especially when Spring Boot version changes:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
Because it is rather tedious (though doable) to match versions manually, one should use spring-boot-dependencies in depencyManagement (link to documentation):
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.8.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
And remove version from dependencies such as spring-beans and spring-context etc.:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
Version should be defined (instead of inheriting from spring-boot-dependencies) only if there is valid reason to use some other version.
So here is the scenario,
I am trying to compile a maven project which have some persistent classes. I have persistence.xml under src\main\resources\. This compiles fine, but I get run-time error for persistence not found which can be easily resolved if I manually move persistence.xml under META-INF dir of jar(xml file is packaged under root of the jar).
Now if I move persistence.xml under src\main\resources\META-INF I get weird compile-time error of
Fatal error compiling: java.lang.RuntimeException:
javax.annotation.processing.FilerException: Attempt to recreate a file
for type my.package.EntityClassName_
This EntityClassName can be any one of my Entity class.
I just want to package persistence.xml under META-INF directory of jar.
Can someone point out what am I missing?
I am using maven compiler source and target as 1.6 if it matters.
EDIT: This project have a parent maven project.
<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.some.domain</groupId>
<artifactId>p-parent</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modules>
<module>m1</module>
<module>m2</module>
<module>m3</module>
</modules>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<scm>
<connection>scm:git:https://some.place/project.git</connection>
</scm>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.6.0</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
pom of this project
<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.some.domain</groupId>
<artifactId>p-parent</artifactId>
<version>1.0.0</version>
</parent>
<artifactId>m2</artifactId>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
</dependency>
</dependencies>
</project>
It was solved bu using -proc:none as compiler argument.
I have project with two modules: 1) Midtier & 2) webapp.
My mid-tier has beans configuration file that does the component scan for the specified packages to load beans. One of such class I have created is ApplicationContextUtils which extends ApplicationContextAware interface which is in the jar SPRING-CONTEXT. (Yes I have tagged the class ApplicationContextUtils with annotation #Component). The pom of this project has declared spring-context-3.2.4.RELEASE as the dependent jar & I can see it in the maven dependencies. I tested this class alone by running a test which loads all the beans & it ran well.
Now, moving onto webapp, webapp's pom describes the midtier as its dependency. I can see this mid-tier project is listed as maven dependency in webapps. Deploying this project from eclipse to Tomcat I got following error:
org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [com.jms.testjms.ApplicationContextUtils] for bean with name 'applicationContextUtils' defined in file [F:\Projects\ActiveMQ\JMSProject\target\classes\com\jms\testjms\ApplicationContextUtils.class]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
.
.
.
Caused by: java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContextAware
(& lot of error chains ..)
The only reasoning I can get is the jar spring-context is not in the class path. But, when I checked in the WEB-INF/lib, of course there is the jar spring-context-3.2.4.RELEASE which is the source for interface ApplicationContextAware. I am not sure why spring cannot find this interface.
I am using spring 3.2.4. My web.xml is using ContextLoaderListener for loading resources during the start up. The project is build using maven.
Any insights would be greatly appreciated.
POM from mid-tier:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jms.test</groupId>
<artifactId>JmsTest</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>Spring Utility</name>
<url>http://www.springframework.org</url>
<description>
<![CDATA[
This project is a minimal jar utility with Spring configuration.
]]>
</description>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>3.2.4.RELEASE</spring.framework.version>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.7.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-spring</artifactId>
<version>5.8.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
<version>5.8.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
pom from webapp:
<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>JmsProtoWebApp</groupId>
<artifactId>JMSWebApp</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<name>JMSWebApp Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<spring.framework.version>3.2.4.RELEASE</spring.framework.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.framework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>6.0.37</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jms.test</groupId>
<artifactId>JmsTest</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<build>
<finalName>JMSWebApp</finalName>
</build>
</project>
project structure & deployment assembly:
http://imgur.com/zydcqSm
Your webapp application have [activemq-spring:5.8.0] dependency, which include also [org.springframework:stuff:3.1.3.RELEASE].
As you include [org.springframework:stuff:3.2.4.RELEASE], you may have some conflict in your classpath.
You should use in you pom depdendency while including [activemq-spring] to drop unwanted spring.
I am trying to test my java MVC application and using eclipse tomcat server integration, but having problems with the deployment. When I use the convenient run on server option in eclipse, It opens a webpage browser in eclipse and is showing a 404 page. I dont know much about the pom file, it might be the issue. I dont see the war file deployed to the webapps folder in tomcat either. Firstly, where in eclipse can I see the warfile, secondly, why is it not being copied to the tomcat webapps folder. Below is my 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>SpringChartsterMVC</groupId>
<artifactId>SpringChartsterMVC</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring.version>3.2.4.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<packaging>war</packaging>
</project>
I am building android project with maven. But I found when I call getChildFragmentManager in v4.Fragment, it shows an error that this method is not found. I doubt that the support-v4 package is not newer enough because if I using ant to build my project everything works just fine.
However I can't get the newer support-v4 to be included into my project.
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.meishixing</groupid>
<artifactid>crazysight</artifactid>
<version>1.0.0-snapshot</version>
<packaging>apk</packaging>
<name>crazysight</name>
<properties>
<project.build.sourceencoding>utf-8</project.build.sourceencoding>
<fest-assert.version>1.0.4</fest-assert.version>
<junit.version>4.10</junit.version>
<robolectric.version>2.0</robolectric.version>
<intellij.annotations.version>12.0</intellij.annotations.version>
</properties>
<dependencies>
<dependency>
<groupid>com.google.android</groupid>
<artifactid>android</artifactid>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupid>com.viewpagerindicator</groupid>
<artifactid>library</artifactid>
<version>2.4.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupid>com.tjerkw</groupid>
<artifactid>slideexpandablelistview-library</artifactid>
<version>1.1.0-snapshot</version>
<type>apklib</type>
</dependency>
<dependency>
<groupid>com.meishixing</groupid>
<artifactid>android-async-http</artifactid>
<version>1.4.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupid>com.meishixing</groupid>
<artifactid>baidu-locationp</artifactid>
<version>3.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupid>com.google.code.gson</groupid>
<artifactid>gson</artifactid>
<version>2.2.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupid>org.apache.commons</groupid>
<artifactid>commons-lang3</artifactid>
<version>3.1</version>
</dependency>
<dependency>
<groupid>com.github.chrisbanes.pulltorefresh</groupid>
<artifactid>library</artifactid>
<version>2.1.1</version>
<type>apklib</type>
</dependency>
<dependency>
<groupid>com.novoda.imageloader</groupid>
<artifactid>imageloader-core</artifactid>
<version>1.5.8</version>
</dependency>
</dependencies>
<build>
<finalname>${project.artifactid}</finalname>
<sourcedirectory>src</sourcedirectory>
<plugins>
<plugin>
<groupid>com.jayway.maven.plugins.android.generation2</groupid>
<artifactid>android-maven-plugin</artifactid>
<version>3.6.2-snapshot</version>
<configuration>
<sdk>
<platform>17</platform>
</sdk>
<manifest>
<debuggable>true</debuggable>
</manifest>
</configuration>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</project>
I've been stumped by this for hours (which is why I also added a bounty), but here's how I finally resolved it.
First of all, check your project's classpath dependancies using
mvn dependency:build-classpath
I could immediately see the problem in the output:
<home>/.m2\repository\android\extras\android-support\v4\android-support-v4.jar
<home>/.m2\repository\android\platforms\android\android-18\android-android-18.jar
<home>/.m2\repository\com\actionbarsherlock\actionbarsherlock\4.4.0\actionbarsherlock-4.4.0.apklib
<home>/.m2\repository\com\google\android\support-v4\r7\support-v4-r7.jar
<... more jars>
There are two support jars included, and the support-v4-r7.jar overrides my newer android-support-v4.jar.
The older one was being loaded by ActionBarSherlock in my project (in your project the culprit might be any of the apklib dependencies), so I excluded it in my project pom:
<dependency>
<groupId>com.actionbarsherlock</groupId>
<artifactId>actionbarsherlock</artifactId>
<version>4.4.0</version>
<type>apklib</type>
<exclusions>
<exclusion>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
</exclusion>
</exclusions>
</dependency>
Hopefully this helps someone.