Migrate existing Maven Project into an OSGI Bundle - java

i am new to the whole OSGi stuff and my task is to create an OSGi Bundle out from an exisitng maven project.
To get started i decided to pick the smallest part and starting with it:
Here is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>cross</artifactId>
<groupId>net.sf.maltcms</groupId>
<version>1.2.12-SNAPSHOT</version>
</parent>
<artifactId>cross-main</artifactId>
<packaging>jar</packaging>
<name>cross-main</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-event</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-tools</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-exception</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-main-api</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-asm</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.0.6.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.4.6</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cross-math</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-all</artifactId>
<version>8.0.249</version>
</dependency>
<dependency>
<groupId>net.sf.mpaxs</groupId>
<artifactId>mpaxs-spi</artifactId>
<version>1.6.10</version>
</dependency>
<dependency>
<groupId>net.sf.mpaxs</groupId>
<artifactId>mpaxs-server</artifactId>
<version>1.6.10</version>
</dependency>
</dependencies>
I did some research and found the Apache Bundle Plugin for maven and changed the pom to this
<packaging>bundle</packaging>
and added
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
mvn clean install went fine and i got a jar file containing the manifest, but of course the bundle could not be resolved
BundleException: The bundle "cross-main_1.2.12.SNAPSHOT [30]" could not be resolved. Reason: Missing Constraint: Import-Package: com.db4o; version="[8.0.0,9.0.0)
To make a long story short: What are the possibiliteis to migrate a maven application into an OSGi Bundle?
Espacially how to manage the dependencys

Probably all went well in the build. The maven bundle plugin automatically creates import package statements for all packages your bundle accesses. It even looks into blueprinnt and spring configs.
So the error message you get
could not be resolved. Reason: Missing Constraint:
Import-Package: com.db4o; version="[8.0.0,9.0.0)"
simply means that you need to install a bundle in your container that exports these packages. So ideally the db4o jar is already a bundle. Then you can simply install it. If not then you will have to create a bundle for it.
If you use apache karaf then you can make bundles on the fly by using the wrap: protocol from pax url which works for simple cases. If you need more then you can create a maven project to wrap the jar into a bundle. In most cases this is not necessary though.
I just checked the db4o download. It contains a db4o osgi bundle that you can install in your container.

Your maven file seems to be correct. This BundleException your'e getting:
BundleException: The bundle "cross-main_1.2.12.SNAPSHOT [30]" could not be resolved. Reason: Missing Constraint: Import-Package: com.db4o; version="[8.0.0,9.0.0)
Is because you have to import the appropriate packages in the bundle. For e.g. I have the bundle plugin:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<archive>
<manifestEntries>
<Build-Change-Set>${changeSet}</Build-Change-Set>
<Build-Change-Set-Date>${changeSetDate}</Build-Change-Set-Date>
<Build-Location>${basedir}</Build-Location>
<Build-Machine>${env.COMPUTERNAME}</Build-Machine>
<Build-Date>${maven.build.timestamp}</Build-Date>
</manifestEntries>
</archive>
<instructions>
<Export-Package>my.bundle.main.package.*,
</Export-Package>
<Import-Package>
org.springframework.context.weaving,
org.springframework.aop,
org.springframework.aop.framework,
org.aopalliance.aop,
org.apache.cxf.bus.spring,
com.mycompany.mypackage.that.i.am.using.classess.from,
*
</Import-Package>
</instructions>
</configuration>
</plugin>
In your bundle plugin configuration add this section:
<instructions>
<Export-Package>your.bundle.main.package.*,
</Export-Package>
<Import-Package>com.db4o,
*
</Import-Package>
</instructions>
You can get more errors like this with the different packages missing. So make sure you add them all to your Import-Package section.
The other thing to notice is: You have to export your bundle's package if your'e using it in other bundles, and in those other bundles you have to import the package of your bundle.

Related

Maven missing artifacts but files are in place - Eclipse

I am getting two errors in eclipse(2020-03) in my maven project as,
The container 'Maven Dependencies' references non existing library 'C:\Users\Shavindi\.m2\repository\javax\servlet\jsp\javax.servlet.jsp-api\4.0.1\javax.servlet.jsp-api-4.0.1.jar' ```
Missing artifact javax.servlet.jsp:javax.servlet.jsp-api:jar:4.0.1 pom.xml /ContactManager line 47 Maven Dependency Problem
I have followed the answers in this question Maven2: Missing artifact but jars are in place . But it didn't work.
My javax.servlet.jsp-api:jar:4.0.1 files are already in place as shown below.
The pom.xml file is also atttached.
<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>net.codejava.contact</groupId>
<artifactId>ContactManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>13</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring.version>5.9.1.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
</dependencies>
</project>
Remove the unnecessary javax.servlet.jsp-api dependency from pom.xml.
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>4.0.1</version>
</dependency>
Also, do Project -> Clean to check whether the error still persists or not ? If yes, then Right Click on project -> Maven -> Update Project -> Select update of snapshot and also enable Project -> Build automatically.
Moreover, they have moved the artifact as well. If you write the code later, you can use the dependency below.
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
Your pom.xml is not proper. So, I have updated your pom.xml as well.
<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>net.codejava.contact</groupId>
<artifactId>ContactManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>13</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring.version>4.2.2.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
</dependencies>
</project>
I noticed your POM.xml has wrong version of javax.servlet.jsp. Try replacing it with the following which is the latest version.
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
If the issue doesn't get resolved after the changes have taken place, follow the steps mentioned below and see if it helps.
Right click your Spring MVC project, choose Run As -> Maven install. Observe the output console to see the installation progress. After the installation is finished, you can continue to the next step
Right click your Spring MVC project, choose Maven -> Update Project.
Choose your project and click OK. Wait until update process is finished.
The error still yet, then do Project->Clean and then be sure you have selected our project directory and then do the follow Project->Build.

Error when deploying to WildFly: "Caused by: java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory"

I keep seeing this error when I try to deploy my Java EE application to WildFly 15.0.1.Final.
I see that org.apache.directory.api::api-all depends on org.apache.servicemix.bundles::org.apache.servicemix.bundles.dom4j, and the latter dependency depends on org.dom4j::dom4j. On the other hand, my WildFly installation has dom4j-2.1.1.jar in modules/system/layers/base/org/dom4j/main/
I tried various things in my pom.xml, for example with org.apache.servicemix.bundles::org.apache.servicemix.bundles.dom4j and org.dom4j::dom4j, excluding each of them and specifying the "provoided" scope. Nothing worked.
Here is the snippet from my pom.xml:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<finalWarName>ldapuserimport</finalWarName>
</properties>
<dependencies>
<!-- Java EE 7 dependency -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<version>1.0.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.3_spec</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.directory.api</groupId>
<artifactId>api-all</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.1-jre</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>2.0.1.Final</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</build>
Could you suggest how to solve this issue please?
One of your dependencies has dom4j old version and server uses that version. Try this command for your dependencies to see which one uses old dom4j version
mvn dependency:tree -Dverbose -Dincludes=commons-collections
After that exclude dom4j from that dependency in your dependency tag.
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
Or try to use newer version of the dependency that has old version dependency of dom4j
I have solved this issue by deleting these 2 lines
<deployments>
</deployments>
in standalone.xml in WildFly. This version of standalone.xml was created from standalone.xml from the previous installation of WildFly, in which things worked ealier, by deleting everything except what is necessary (namely, datasource- and driver- sections).
Weird.

"Full Publish" does not work for publishing Dynamic Web Project on wildfly since using Maven

Since i am using maven in my JSF Project it seems that eclipse does not support "Full publish" Button correctly anymore. I was adding maven support with right-click on Project > Configure > Convert to Maven Project...
After importing required dependencies and updating Project from pom.xml Server runs correctly but publishing changes (Java Code) takes no effect. Just cleaning whole Project and Server takes effect.
Eclipse Neon.3 Release (4.6.3)
Wildfly Full Profile 10.1.0.Final
JBoss Tools 4.4.4.Final
with Embedded Maven installation (3.3.9) and m2e-wtp
I tried solutions like:
How to configure deployment from Eclipse to Wildfly or Hot deploy on JBoss - how do I make JBoss "see" the change? but none of these changes have helped.
Here is 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>Test</groupId>
<artifactId>Test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.2_spec</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.0</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.10</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>
Is there a mistake e.g. in my pom.xml or any solution to restore Pulish function?

Java Spring (Maven) REST API using OAuth2

Please help me with details given at article Secure Spring REST API using OAuth2.
How to run the SpringRestClient from the given source code?
Here's the pom.xml, what is missing?
<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.websystique.springmvc</groupId>
<artifactId>SpringSecurityOAuth2Example</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>SpringSecurityOAuth2Example</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>4.3.1.RELEASE</springframework.version>
<springsecurity.version>4.1.1.RELEASE</springsecurity.version>
<springsecurityoauth2.version>2.0.10.RELEASE</springsecurityoauth2.version>
<jackson.library>2.7.5</jackson.library>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<!-- Spring Security OAuth2-->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${springsecurityoauth2.version}</version>
</dependency>
<!-- Jackson libraries -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.library}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.library}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>SpringSecurityOAuth2Example</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>SpringSecurityOAuth2Example</finalName>
</build>
Please note that the Postman Client works fine. What is the Maven command to run the SpringRestClient Class? The SpringSecurityOAuth2Example.war is generated from mvn package.
Thanks
Consider your pom.xml is inside SpringSecurityOAuth2Example folder so from that folder you can run below command. Please make sure your war file is deployed in tomcat and server is running as SpringRestClient will look for service at http://localhost:8080/SpringSecurityOAuth2Example. Please restart you tomcat before running this command otherwise it might throw error.
mvn -Dexec.mainClass=com.websystique.springmvc.SpringRestClient -Dexec.classpathScope=test test-compile exec:java

Conflict of Jackson dependencies / Tomcat

My java class throws this error when deployed on tomcat:
org.apache.jasper.JasperException:
javax.servlet.ServletException: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonParser.getValueAsString()Ljava/lang/String;
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:556)
When tested locally the class runs perfectly well. I understand that there might be a conflict of Jackson version, but I can't find out.
Here is an extract of 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.skylads.skott.webapp</groupId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Skylads CRM App</name>
<description>CRM App integrating various features</description>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<artifactId>crm</artifactId>
<dependencies>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<exclusions>
<exclusion>
<artifactId>jackson-core</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
</exclusions>
<version>v2-rev98-1.20.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-plus</artifactId>
<version>v1-rev323-1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client-java6</artifactId>
<version>1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.20.0</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.21.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
<version>7.0.35</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.scribe</groupId>
<artifactId>scribe</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
App runs on Tomcat 7.0.
Edit: Full pom.xml added
Any help very much appreciated.
OK guys, i'm out of this nightmare. I used http://jhades.org/ to identify the overlapping jars, went into web-inf and removed old jars that were conflicting and creating the issue.
Maven is very cool but doesn't solve everything, I lost 3hours+ on this issue...
Thanks again for your contribution that were very helpful.
Soufian
As you said on tomcat you are using a different version of jackson-core than in your build.
Find out what you use in maven with mvn help:effective-pom
Than have a look what you have packaged in your war.
Its also possible,that tomcat uses its own jackson library that makes the problem.
You have not provided extensive information about your question but I can tell you that version 2.1.0 is the first version to have the getValueAsString method. The version in your pom.xml also does have it. Older versions do not have it and this where your problem is. So according to my experience, this is clearly a problem that you have two jackson-core jar versions running and the class loaders are getting the older version first. You need to do something like:
$ find . -name "*jackson*"
in your tomcat 7 directory. Find the older version and remove it from your integration. Read the tomcat 7 webpage to know more about classloaders for your tomcat version.

Categories