0

I have done all I can to fix this error, added some exclusions in my pom file, but still not able to figure out why am I getting this error.

pom.xml

<?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/xsd/maven-4.0.0.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.demo.project</groupId>
    <artifactId>demoApi</artifactId>
    <version>4.3.0.BUILD-SNAPSHOT</version>
    <name>demoApi</name>
    <description>HTTP REST WebService</description> 
    <properties>
        <spring.version>4.2.5.RELEASE</spring.version>
        <spring.integration.version>4.2.5.RELEASE</spring.integration.version>
        <spring.security.version>4.0.4.RELEASE</spring.security.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-core</artifactId>
            <version>${spring.integration.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-http</artifactId>
            <version>${spring.integration.version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-webmvc</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jasypt</groupId>
            <artifactId>jasypt</artifactId>
            <version>1.7</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.security.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.security.version}</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-webmvc</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-web</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-beans</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-core</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>org.springframework</artifactId>
                    <groupId>spring-context</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.2</version>
            <scope>compile</scope>
        </dependency> -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
    </dependencies> 
    <packaging>war</packaging>
    <build>
        <finalName>demoApi</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Code where I get this error

package org.springframework.integration.samples.rest.json.view;

import java.util.Map;

import org.springframework.web.servlet.view.json.MappingJackson2JsonView;

/**
 * ExtendedMappingJacksonJsonView.java: This class extends the Spring's MappingJacksonJsonView
 * <p>
 * Note: The source code for this class is taken from the forum posted by AhungerArtist
 *       at http://forum.springsource.org/archive/index.php/t-84006.html
 * <p>
 * @author Vigil Bose
 * @author Gary Russell
 */
public class ExtendedMappingJacksonJsonView extends MappingJackson2JsonView {

    @SuppressWarnings({"rawtypes" })
    @Override
    protected Object filterModel(Map<String, Object> model){
        Object result = super.filterModel(model);
        if (!(result instanceof Map)){
            return result;
        }

        Map map = (Map) result;
        if (map.size() == 1){
            return map.values().toArray()[0];
        }
        return map;
    }
}

EDIT : Dependency Tree output

[INFO]com.demo.project:demoApi:war:4.3.0.BUILD-SNAPSHOT
[INFO] +- org.springframework:spring-oxm:jar:4.2.5.RELEASE:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] +- org.springframework:spring-test:jar:4.2.5.RELEASE:test
[INFO] +- org.springframework.integration:spring-integration-core:jar:4.2.5.RELE
ASE:compile
[INFO] +- org.springframework.integration:spring-integration-http:jar:4.2.5.RELE
ASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.2.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.5.RELEASE:compile
[INFO] +- org.hamcrest:hamcrest-all:jar:1.3:test
[INFO] +- org.jasypt:jasypt:jar:1.7:compile
[INFO] +- org.springframework:spring-tx:jar:4.2.5.RELEASE:compile
[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.0.4.RELEASE:
compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.4.RELEASE:com
pile
[INFO] +- org.mockito:mockito-core:jar:1.9.5:test
[INFO] +- org.springframework:spring-jdbc:jar:4.2.5.RELEASE:compile
[INFO] +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] +- com.oracle:ojdbc6:jar:11.2.0:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- javax.ws.rs:javax.ws.rs-api:jar:2.0.1:compile
[INFO] \- javax.inject:javax.inject:jar:1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 11.143 s
[INFO] Finished at: 2016-05-04T13:44:59+05:30
[INFO] Final Memory: 14M/197M
[INFO] ------------------------------------------------------------------------

EDIT 2: Forgot to mention an important thing. We are not using Maven repo, but instead our own private repo. I have downloaded all jars and imported in our repo. I repeatedly ran mvn clean -U install to see if any errors are there and fix it.

Thanks for all who answered. Since I had to finish up things soon, I decided to go with Spring WS instead of JAX-RS! We already have working Spring REST WS and so decided to use it further. If only my organization drop the idea of using private repo, I never would have been in this mess.

halfer
  • 19,824
  • 17
  • 99
  • 186
Rajkumar
  • 440
  • 7
  • 31
  • 1
    For starters post the full stack trace and the output of `mvn dependency:tree`. Suggestion instead of hunting for compatible versions I suggest the use of the [Spring IO Platform bom](http://platform.spring.io/platform/) that will save you some headaches. – M. Deinum May 04 '16 at 07:43
  • 1
    Try maven clean install and from eclipse project>clean... – Aurasphere May 04 '16 at 08:20

1 Answers1

2

These errors sometimes happened because some interface/class in the hierarchy cannot be resolved. For example: the error is in your class - class X, X inherits Y, and in turn, Y inherits Z. However, the compiler cannot resolve z (in above error), because z is belong to a library that is not included. Therefore, you have to add package containing z to the classpath/ or project's Java Build Path (if you are using eclipse). hope it may help.

suulisin
  • 1,414
  • 1
  • 10
  • 17