WebSphere V7中JAX-RS服务访问出现Error 404: SRVE0190E错误求助
Let’s break down why you’re hitting that Error 404: SRVE0190E: File not found when accessing your REST endpoints. Here are the most common fixes to try:
1. Add Proper JAX-RS Annotations to Your Resource Class
Your Conference class as shown doesn’t include any JAX-RS annotations—this is a critical missing piece. For WebSphere to recognize it as a REST resource, you need to add:
@Pathat the class level to map to/Conference- HTTP method annotations (like
@GET) on methods that handle requests @PathParamif you’re capturing path variables (like the1in your second URL)
Example corrected class:
package co.ma.jaxrs; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @Path("/Conference") public class Conference { public final String name; public final String date; // Add your constructor(s) here @GET public String getAllConferences() { // Replace with your logic to return all conferences return "All conferences list"; } @GET @Path("/{id}") public String getConferenceById(@PathParam("id") String id) { // Replace with your logic to fetch a single conference by ID return "Conference details for ID: " + id; } }
2. Fix Your web.xml Configuration
WebSphere Application Server V7 uses Jersey 1.4 as its default JAX-RS implementation, so your web.xml needs to correctly map the Jersey servlet to your /resources/* path. Here’s a working configuration example:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5"> <servlet> <servlet-name>JAX-RS Servlet</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <!-- Tell Jersey which packages to scan for resource classes --> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>co.ma.jaxrs</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>JAX-RS Servlet</servlet-name> <url-pattern>/resources/*</url-pattern> </servlet-mapping> </web-app>
Double-check that:
- The
url-patternmatches/resources/*(to align with your endpoint URLs) - The
param-valuefor package scanning points to your resource class’s package (co.ma.jaxrs)
3. Avoid JAR Conflicts
If you’ve included external Jersey JARs in your WEB-INF/lib folder, this will conflict with WebSphere’s built-in Jersey implementation. Remove any Jersey-related JARs (like jersey-server.jar, jersey-core.jar) from your application—WAS 7 provides these out of the box.
4. Confirm Application Deployment Details
- Make sure your app’s context root is set to
Conference(this matches thehttp://localhost:9080/Conference/part of your URLs). You can verify this in the WebSphere Administrative Console under Applications > Application Types > WebSphere enterprise applications > [Your App] > Context Root for Web Modules. - Restart the application after making configuration changes—WAS sometimes requires a restart to pick up JAX-RS updates.
Once you’ve applied these fixes, test your endpoints again. If you still run into issues, check the WebSphere SystemOut.log for more detailed error messages (they’ll often point to missing annotations or configuration mistakes).
内容的提问来源于stack exchange,提问作者S.Yassine

