Jersey: org.glassfish.jersey.server.mvc cannot be resolved

你离开我真会死。 提交于 2019-12-13 08:14:16

问题


I want to use Jersey MVC in my project. I've never used Jersey MVC before.

I'm working in:

  • Eclipse (Version: Neon.1a Release (4.6.1))

, using:

  • Jersey 2.25.1

  • Apache Tomcat 7.0.76.


Here's the example I'm trying to run:

Hello.java

MyApp.java

NewFile.jsp

I have downloaded jersey 2.25.1 from here

and added all jar files in

Here's how I call my web service:


The underlined import line tells:

So this is the problem I want to solve.


Because I have not found any information related to this problem I searched for jersey mvc related jar file. I found it here.

I added jersey-mvc-2.25.1.jar in lib folder.

So the package (and Viewable class) was found.

But when I run on server I get the following stack trace:

Thank you in advance.


回答1:


Here's how I solved the problem:

First of all, jersey-mvc-2.25.1.jar is not enough to use MVC Jersey.

I downloaded the file jersey-mvc-jsp-2.25.jar.

I put both jars in lib


Now here's my working basic example:

The structure of my project is:

The source code is:

MyApp.java

Hello.java

NewFile.jsp

To see the result I started the Tomcat server, then:

It worked!


Related to classpath/buildpath setting in Eclipse:

I didn't Add Jars (jersey-mvc-2.5.1.jar and jersey-mvc-2.5.1.jar) in classpath or buildpath. It worked anyway.


What really helped to understand all this is:

Absolute vs. Relative template reference

Annotations



来源:https://stackoverflow.com/questions/43500856/jersey-org-glassfish-jersey-server-mvc-cannot-be-resolved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!