The source code at https://github.com/salimane/java-jersey2 is basically a slighly modified version of the sample java-jersey2 sample in swagger-core. The relevant change is here. But I'm getting the following error when trying to run :
SEVERE: Following issues have been detected:
WARNING: No injection source found for a parameter of type public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) at index 1.
WARNING: A resource model has ambiguous (sub-)resource method for HTTP method POST and input mime-types as defined by @Consumes and @Produces annotations at Java methods public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) and public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser(com.salimane.swagger.api.model.User) at matching regular expression /v1/user. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.
Mar 24, 2014 3:29:50 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) at index 1.; source='ResourceMethod{httpMethod=POST, consumedTypes=[], producedTypes=[application/json, application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.salimane.swagger.api.resource.v1.UserResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@1cab6b8]}, handlingMethod=public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List), parameters=[Parameter [type=class java.lang.String, source=username, defaultValue=null], Parameter [type=class com.salimane.swagger.api.model.User, source=Created user object, defaultValue=null], Parameter [type=interface java.util.List, source=List of user object, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method POST and input mime-types as defined by @Consumes and @Produces annotations at Java methods public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) and public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser(com.salimane.swagger.api.model.User) at matching regular expression /v1/user. 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@23a1eaf3']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:427)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:287)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:284)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:302)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Any idea what I'm doing wrong ?
Thanks
I believe the solution for your issue can be found here -
http://stackoverflow.com/questions/14288856/jersey-2-injection-source
On Tue, Mar 25, 2014 at 12:47 AM, Salimane Adjao Moustapha <
[email protected]> wrote:
The source code at https://github.com/salimane/java-jersey2 is basically
a slighly modified version of the sample java-jersey2 sample in
swagger-core. The relevant change is herehttps://github.com/salimane/java-jersey2/blob/master/src/main/java/com/salimane/swagger/api/resource/v1/UserResource.java#L50.
But I'm getting the following error when trying to run :SEVERE: Following issues have been detected:
WARNING: No injection source found for a parameter of type public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) at index 1.
WARNING: A resource model has ambiguous (sub-)resource method for HTTP method POST and input mime-types as defined by @Consumes and @Produces annotations at Java methods public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) and public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser(com.salimane.swagger.api.model.User) at matching regular expression /v1/user. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.Mar 24, 2014 3:29:50 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] No injection source found for a parameter of type public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) at index 1.; source='ResourceMethod{httpMethod=POST, consumedTypes=[], producedTypes=[application/json, application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.salimane.swagger.api.resource.v1.UserResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@1cab6b8]}, handlingMethod=public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List), parameters=[Parameter [type=class java.lang.String, source=username, defaultValue=null], Parameter [type=class com.salimane.swagger.api.model.User, source=Created user object, defaultValue=null], Pa
rameter [type=interface java.util.List, source=List of user object, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}', [FATAL] A resource model has ambiguous (sub-)resource method for HTTP method POST and input mime-types as defined by @Consumes and @Produces annotations at Java methods public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser2(java.lang.String,com.salimane.swagger.api.model.User,java.util.List) and public javax.ws.rs.core.Response com.salimane.swagger.api.resource.v1.UserResource.createUser(com.salimane.swagger.api.model.User) at matching regular expression /v1/user. 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@23a1eaf3']
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:427)
at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:162)
at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:287)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:289)
at org.glassfish.jersey.internal.Errors$2.call(Errors.java:286)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.processWithException(Errors.java:286)
at org.glassfish.jersey.server.ApplicationHandler.(ApplicationHandler.java:284)
at org.glassfish.jersey.servlet.WebComponent.(WebComponent.java:302)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1088)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5176)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5460)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)Any idea what I'm doing wrong ?
Thanks
—
Reply to this email directly or view it on GitHubhttps://github.com/wordnik/swagger-core/issues/507
.
@webron I've already checked that and tried some of the snippets but I'm still getting the same error. In my case I'm not really uploading a file or consuming xml. You can check https://github.com/salimane/java-jersey2/blob/master/src/main/java/com/salimane/swagger/api/resource/v1/UserResource.java#L50
If you're not uploading files, try removing the jersey-media-multipart dependency (that is, make sure it's not pulled in by any of the other dependencies as well).
@webron I've just pushed to https://github.com/salimane/java-jersey2. No more jersey-media-multipart but still having the same error.
please see comments here:
https://github.com/salimane/java-jersey2/pull/1
Then running mvn clean package tomcat7:run will work fine.
@fehguy thanks
Remove all Jersey 1.X libraries and move them to 2.x (glassfish ones)
Also make sure you have this web.xml in spring. MultiPartFeature param value is what you need to add.
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.xyz.app</param-value>
</init-param>
<init-param>
<param-name>jersey.config.server.provider.classnames</param-name>
<param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
more details @here
I found some relevance to this issue mentioned here : http://stackoverflow.com/questions/39405067/org-glassfish-jersey-server-model-modelvalidationexception-validation-of-the-ap
Could you please guide on how to fixed this issue ?
Most helpful comment
Remove all Jersey 1.X libraries and move them to 2.x (glassfish ones)
Also make sure you have this web.xml in spring. MultiPartFeature param value is what you need to add.
more details @here