Newbie: trouble with eclipse dynamic web project and javax.ws.rs dependency

eclipse
plugins

(Davidson) #1

I have found a lot of articles that talk about how to set up a new gradle project so that i can use it with tomcat with in eclipse. Basically they suggest you start by creating a new dynamic web project and then write a small build.gradle file. following this approach I re-import my project into eclipse and index.jsp it works as expected.

Now when I try to create a restful service, eclipse can not compile it complains ’the import javax.ws.rs.GET can not be found’

I have tried a ton of different dependencies. I think the problem is when I look at the libraries in eclipse I do not see my added dependencies. When I look at regular gradle projects in eclipse I see ‘projects and external dependencies’ folder. My dynamic web project does not seem to have anything like that

$ gradlew clean war

works how ever eclipse still complains? I have tried deleting and re-importing several times

here are the plugins I am using

apply plugin: 'java’
apply plugin: ‘war’
//‘com.bmuschko.tomcat’ supports deploying to tomcat
apply plugin: ‘com.bmuschko.tomcat’

//eclipse-wtp provides support for dynamic web projects in eclipse
apply plugin: ‘eclipse-wtp’

Here are the various dependency combinations I have tried
the always complile from the command line.

// dependencies to run on tomcat, are mandatory for tomcat plugin
dependencies {
def tomcatVersion = '8.0.18’
tomcat “org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}”,
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat(“org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}”) {
exclude group: ‘org.eclipse.jdt.core.compiler’, module: ‘ecj’
}

compile project(':kRank')

// // mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-common
// compile group: ‘org.glassfish.jersey.core’, name: ‘jersey-common’, version: ‘2.23.2’
//
// // mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client
// compile group: ‘org.glassfish.jersey.core’, name: ‘jersey-client’, version: ‘2.23.2’
//
// // TODO do we need jersery-server?
// //mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server
// compile group: ‘org.glassfish.jersey.core’, name: ‘jersey-server’, version: ‘2.23.2’

// // mvnrepository.com/artifact/com.sun.jersey/jersey-bundle
// compile group: ‘com.sun.jersey’, name: ‘jersey-bundle’, version: ‘1.19.2’

// /blog.lick-me.org/2015/02/getting-started-with-jax-rs-gradle/
// //mvnrepository.com/artifact/javax.ws.rs/javax.ws.rs-api

// compile group: ‘javax.ws.rs’, name: ‘javax.ws.rs-api’, version: ‘2.0.1’
//
// // //mvnrepository.com/artifact/org.glassfish.jersey.containers/jersey-container-servlet
// compile group: ‘org.glassfish.jersey.containers’, name: ‘jersey-container-servlet’, version: ‘2.23.2’
//
// // ://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
// compile group: ‘javax.servlet’, name: ‘javax.servlet-api’, version: ‘3.1.0’

// //relishcode.com/jax-rs-eclipse-gradle/
compile "javax.ws.rs:javax.ws.rs-api:2.0.1"
compile "org.glassfish.jersey.core:jersey-server:2.23.2"
compile "org.glassfish.jersey.containers:jersey-container-servlet:2.23.2"
compile "org.glassfish.jersey.media:jersey-media-json-jackson:2.23.2"
//providedCompile "javax.servlet:javax.servlet-api:3.1.0"
compile "javax.servlet:javax.servlet-api:3.1.0"

}

$ …/gradlew --version


Gradle 2.12

Build time: 2016-03-14 08:32:03 UTC
Build number: none
Revision: b29fbb64ad6b068cb3f05f7e40dc670472129bc0

Groovy: 2.4.4
Ant: Apache Ant™ version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_66 (Oracle Corporation 25.66-b17)
OS: Mac OS X 10.11.6 x86_64

Any suggestions would be greatly appreciated