Just to give you a hint:
Find out the difference between <scope>provided</scope> and <scope>runtime</scope>

And know that Eclipse can't distinguish scopes, test-scoped dependencies like junit ends on the one and only classpath of eclipse.

Robert

Op Thu, 04 Oct 2012 20:24:36 +0200 schreef Davis Ford <davisf...@gmail.com>:

Appending this as well:

$ mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /home/ubuntu/apache-maven-3.0.4
Java version: 1.7.0_07, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.0.0-23-virtual", arch: "i386", family: "unix"

On Thu, Oct 4, 2012 at 2:22 PM, Davis Ford <davisf...@gmail.com> wrote:

This doesn't make a whole lot of sense to me.  Any idea what the problem
is here?

[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2.944s
[INFO] Finished at: Thu Oct 04 17:54:16 UTC 2012
[INFO] Final Memory: 9M/23M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile
(default-compile) on project example-server: Compilation failure:
Compilation failure:
[ERROR]
/home/ubuntu/git/example-server/src/main/java/com/example/m2m/service/DeviceService.java:[17,25]
error: package com.sun.jersey.api does not exist
[ERROR]
/home/ubuntu/git/my-server/src/main/java/com/example/m2m/service/DeviceService.java:[33,11]
error: cannot find symbol
[ERROR] symbol:   class JResponse
[ERROR] location: class DeviceService

The class I wrote DeviceService.java has this import:

import com.sun.jersey.api.JResponse;

pom.xml snipped:

<dependencies>
   <dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-server</artifactId>
    <version>${jersey.version}</version>
    <scope>runtime</scope>
  </dependency>
   etc...
</dependencies>

Ok, the compiler can't find it -- works fine in Eclipse - I built the
eclipse project with mvn eclipse:eclipse, it resolves to the
jersey-server-1.14.jar - in Eclipse, I expand the jar, and see the class
is indeed in there.  dependency:tree shows it is in the classpath, and
scope is runtime =>

ubuntu@$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]

[INFO]
------------------------------------------------------------------------
[INFO] Building Example Webapp 1.0-SNAPSHOT
[INFO]
------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ example-server
---
[INFO] com.example:example-server:war:1.0-SNAPSHOT
[INFO] +- org.zeromq:jzmq:jar:1.0:compile
 [INFO] +- com.google.protobuf:protobuf-java:jar:LATEST:compile
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.14:runtime
[INFO] |  +- asm:asm:jar:3.1:runtime
[INFO] |  \- com.sun.jersey:jersey-core:jar:1.14:runtime
[INFO] +- com.sun.jersey:jersey-json:jar:1.14:runtime
[INFO] |  +- org.codehaus.jettison:jettison:jar:1.1:runtime
[INFO] |  |  \- stax:stax-api:jar:1.0.1:runtime
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:runtime
[INFO] |  |  \- javax.xml.bind:jaxb-api:jar:2.2.2:runtime
[INFO] |  |     +- javax.xml.stream:stax-api:jar:1.0-2:runtime
[INFO] |  |     \- javax.activation:activation:jar:1.1:runtime
[INFO] |  +- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:runtime
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:runtime
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:runtime
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.9.2:runtime
[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.14:runtime
[INFO] |  +- com.sun.jersey:jersey-servlet:jar:1.14:runtime
[INFO] |  +- org.springframework:spring-core:jar:3.0.0.RC3:runtime
[INFO] |  |  \- org.springframework:spring-asm:jar:3.0.0.RC3:runtime
[INFO] |  +- org.springframework:spring-beans:jar:3.0.0.RC3:runtime
[INFO] |  +- org.springframework:spring-context:jar:3.0.0.RC3:runtime
[INFO] |  |  +- aopalliance:aopalliance:jar:1.0:runtime
[INFO] | | \- org.springframework:spring-expression:jar:3.0.0.RC3:runtime
[INFO] |  +- org.springframework:spring-web:jar:3.0.0.RC3:runtime
[INFO] |  \- org.springframework:spring-aop:jar:3.0.0.RC3:runtime
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.5.8:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.5.8:compile
[INFO] +- org.slf4j:slf4j-log4j12:jar:1.5.8:compile
[INFO] +- log4j:log4j:jar:1.2.14:compile
[INFO] \- junit:junit:jar:4.8.2:test

Let's validate that the class does indeed exist in that jarfile...and it
does =>

ubuntu@$ jar tf
~/.m2/repository/com/sun/jersey/jersey-server/1.14/jersey-server-1.14.jar
META-INF/MANIFEST.MF
META-INF/
META-INF/jersey-module-version
META-INF/maven/
META-INF/maven/com.sun.jersey/
META-INF/maven/com.sun.jersey/jersey-server/
META-INF/maven/com.sun.jersey/jersey-server/pom.properties
META-INF/maven/com.sun.jersey/jersey-server/pom.xml
META-INF/services/
META-INF/services/com.sun.jersey.spi.StringReaderProvider
META-INF/services/com.sun.jersey.spi.container.ContainerProvider
META-INF/services/com.sun.jersey.spi.container.ContainerRequestFilter

META-INF/services/com.sun.jersey.spi.container.ResourceMethodCustomInvokerDispatchProvider

META-INF/services/com.sun.jersey.spi.container.ResourceMethodDispatchProvider
META-INF/services/com.sun.jersey.spi.container.WebApplicationProvider
META-INF/services/javax.ws.rs.ext.MessageBodyWriter
META-INF/services/javax.ws.rs.ext.RuntimeDelegate
META-INF/taglib.tld
com/
com/sun/
com/sun/jersey/
com/sun/jersey/api/
com/sun/jersey/api/ConflictException.class
com/sun/jersey/api/JResponse$AJResponseBuilder.class
com/sun/jersey/api/JResponse$JResponseBuilder.class
com/sun/jersey/api/JResponse.class

Class is there.  Why, why, why?

I'm not doing anything fishy with maven settings like setting a different directory path for the repository -- everything is setup with the defaults.
 MAVEN_REPO is in ~/.m2/repository




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
For additional commands, e-mail: users-h...@maven.apache.org

Reply via email to