Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization. [[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String jersey.JerseyTesting.getName() and public java.lang.String jersey.JerseyTesting.getPassword() at matching regular expression /jerseytesting. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.; source='org.glassfish.jersey.server.model.RuntimeResource@4d73a7a'] org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555) org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184) org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350) org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347) org.glassfish.jersey.internal.Errors.process(Errors.java:315) org.glassfish.jersey.internal.Errors.process(Errors.java:297) org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255) org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:347) org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:392) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177) org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Unknown Source)

Mine Class:
@Path("/JerseyTesting")
public class JerseyTesting {
String name = "Maks";
String password = "pl000pl";
@Produces(MediaType.TEXT_PLAIN)
public String getName() {
    return name;
@Produces(MediaType.TEXT_PLAIN)
public String getPassword() {
    return password;
Mine web.xml page!
<display-name>JerseyTesting</display-name>  
    <servlet>   
    <servlet-name>JerseyTesting</servlet-name> 
    <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> 
    <init-param>
    <param-name>jersey.config.server.provider.packages</param-name>
    <param-value>jersey</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>JerseyTesting</servlet-name>
    <url-pattern>/RestTesting</url-pattern> 
    </servlet-mapping>
  

[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public java.lang.String jersey.JerseyTesting.getName() and public java.lang.String jersey.JerseyTesting.getPassword() at matching regular expression /jerseytesting. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.;

Your resource methods are ambiguous

@Produces(MediaType.TEXT_PLAIN) public String getName() { return name; @Produces(MediaType.TEXT_PLAIN) public String getPassword() { return password;

Jersey will not know which one to pick. You will need to either change the path on one or both of them or the media type. Most likely you will want to change the path for this particular case. Something like

@Path("/name") @Produces(MediaType.TEXT_PLAIN) public String getName() { return name; @Path("/password") @Produces(MediaType.TEXT_PLAIN) public String getPassword() { return password; Also <url-pattern>/RestTesting</url-pattern> should be <url-pattern>/RestTesting/*</url-pattern> – Paul Samsotha Apr 18, 2016 at 18:33 You might need to go through a good tutorial. Your original question is about the ModelValidationException. And I have answered that question. The 404 is unrelated to this. If you have a different question, please post another question. But any decent tutorial should get you started so you won't get a 404. If you were able to get the app running before, then making the changes I suggested broke it, then that it a different story. – Paul Samsotha Apr 18, 2016 at 18:46

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.