问题描述:

I have Glassfish Jersey project which I created 3 months ago. I can request it from my localhost but I am facing problem to get it to work after renaming the package from org.busTracker.serverSide to 'org.busTracker.trackingService'. I renamed it after pressing the F2 button but I am not getting the request through with the chrome postmann plugin.

Where else have I do rename to get it to work?

error message after renaming the package:

<!DOCTYPE html>

<html>

<head>

<title>Apache Tomcat/8.0.22 - Error report</title>

<style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style>

</head>

<body>

<h1>HTTP Status 404 - Not Found</h1>

<div class="line"></div>

<p>

<b>type</b> Status report

</p>

<p>

<b>message</b>

<u>Not Found</u>

</p>

<p>

<b>description</b>

<u>The requested resource is not available.</u>

</p>

<hr class="line">

<h3>Apache Tomcat/8.0.22</h3>

</body>

</html>

pom.xml file:

**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>

<groupId>org.busTracker</groupId>

<artifactId>serverSide</artifactId>

<packaging>war</packaging>

<version>0.0.1-SNAPSHOT</version>

<name>serverSide</name>

<build>

<finalName>serverSide</finalName>

<plugins>

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>2.5.1</version>

<inherited>true</inherited>

<configuration>

<source>1.7</source>

<target>1.7</target>

</configuration>

</plugin>

</plugins>

</build>

<dependencyManagement>

<dependencies>

<dependency>

<groupId>org.glassfish.jersey</groupId>

<artifactId>jersey-bom</artifactId>

<version>${jersey.version}</version>

<type>pom</type>

<scope>import</scope>

</dependency>

</dependencies>

</dependencyManagement>

<dependencies>

<dependency>

<groupId>org.glassfish.jersey.containers</groupId>

<artifactId>jersey-container-servlet-core</artifactId>

<!-- use the following artifactId if you don't need servlet 2.x compatibility -->

<!-- artifactId>jersey-container-servlet</artifactId -->

</dependency>

<dependency>

<groupId>org.glassfish.jersey.media</groupId>

<artifactId>jersey-media-json-jackson</artifactId>

<version>2.16</version>

</dependency>

<!-- uncomment this to get JSON support <dependency> <groupId>org.glassfish.jersey.media</groupId>

<artifactId>jersey-media-moxy</artifactId> </dependency> -->

</dependencies>

<properties>

<jersey.version>2.16</jersey.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

</properties>

</project>

screen shot

网友答案:

Look in your web.xml file. You will see

<init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>org.busTracker.serverSide</param-value>
</init-param>

This property tells Jersey to scan the org.busTracker.serverSide package for your resource classes. If you change the package of the resources then Jersey can't find them. So just change the package in the web.xml

相关阅读:
Top