Error while integrating swagger with Spring 3.0 by using jersey

108 views
Skip to first unread message

Sumit Sharma

unread,
Apr 20, 2016, 7:25:13 AM4/20/16
to Swagger
    **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 java.util.List** 
    
    com.org.testing.controller.getSentInviteList(com.org.testing.domain.FriendshipInvitee$Status,com.org.testing.domain.ext.RequestBounds,javax.servlet.http.HttpServletResponse,org.springframework.security.core.Authentication) throws java.lang.IllegalAccessException,com.org.testing.exception.BusinessException at index 0.; source='ResourceMethod{httpMethod=POST, consumedTypes=[application/json], producedTypes=[application/json], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class com.org.testing.controller, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@190e93e3]}, definitionMethod=public java.util.List com.org.testing.controller.getSentInviteList(com.org.testing.domain.FriendshipInvitee$Status,com.org.testing.domain.ext.RequestBounds,javax.servlet.http.HttpServletResponse,org.springframework.security.core.Authentication) throws java.lang.IllegalAccessException,com.org.testing.exception.BusinessException, parameters=[Parameter [type=class com.org.testing.domain.FriendshipInvitee$Status, source=status, defaultValue=null], Parameter [type=class com.org.testing.domain.ext.RequestBounds, source=null, defaultValue=null], Parameter [type=interface javax.servlet.http.HttpServletResponse, source=null, defaultValue=null], Parameter [type=interface org.springframework.security.core.Authentication, source=null, defaultValue=null]], responseType=java.util.List<com.org.testing.domain.LeaderboardInvitation>}, nameBindings=[]}']
    
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:467)
            at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:163)
            at org.glassfish.jersey.server.ApplicationHandler$3.run(ApplicationHandler.java:323)
            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:320)
            at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
            at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:311)
            at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
            at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
            at javax.servlet.GenericServlet.init(GenericServlet.java:244)
            at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1274)
            at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1186)
            at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081)
            at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5033)
            at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5320)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
            at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
            at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
            at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
            at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:125)
            at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:109)
            at org.eclipse.virgo.web.core.internal.WebBundleLifecycleListener.onStarted(WebBundleLifecycleListener.java:122)
            at org.eclipse.virgo.kernel.install.artifact.internal.StandardArtifactStateMonitor.onStarted(StandardArtifactStateMonitor.java:271)
            at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.asyncStartSucceeded(AbstractInstallArtifact.java:319)
            at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact.access$0(AbstractInstallArtifact.java:316)
            at org.eclipse.virgo.kernel.install.artifact.internal.AbstractInstallArtifact$StateMonitorSignal.signalSuccessfulCompletion(AbstractInstallArtifact.java:252)
            at org.eclipse.virgo.nano.core.internal.BundleStartTracker$1.run(BundleStartTracker.java:140)
            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:744)

I am having a spring-mvc restfull webservice project, I am quite new for Jersey and swagger. I have given my most efforts to create documentation for api's using swagger.but at last moments i saw some limitation of jersey with swagger.

I have covered most api's in documentation but there are following cases which is creating issue for documentation using swagger. Cases are listed below:- 

 1. If Endpoint have multiple input parameter (Request Params), Jersey uses only path params , it doesn’t support Request params.
 2. If Response type is based on collection , then apis throwing exception.
 3. If Request params have any collection type input parameter.

I am using spring 3.x framework in my project and i have added jersey 2.12 version and using swagger 1.0.

**I am looking for help to troubleshoot this error.**

Here is my code

@Path("/invite/sent/list")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
    @ApiOperation(
            value = "get List", response=LBTest.class,
            responseContainer="List",
            notes = "API to get list.")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "Successful retrieval of resource options"), @ApiResponse(code = 500, message = "Internal server error"), @ApiResponse(code = 403, message = "Illegal Access of Resource") })
    @RequestMapping(value = "/v2/lb/invite/sent/list", method = RequestMethod.POST)
    @PreAuthorize("hasRole('ROLE_USER')")
    @ResponseBody
    public List<LBTest> getSentInviteList(@ApiParam(value = "status", required = false) @RequestParam(value = "status", required = false) Invitee.Status status, @RequestBody RequestBounds requestBounds,
    @Context HttpServletResponse response, @Context Authentication auth) throws IllegalAccessException, BusinessException
    {
        
       //Bussiness logic here
    }

Ron Ratovsky

unread,
Apr 20, 2016, 7:32:17 AM4/20/16
to swagger-sw...@googlegroups.com
Hi Sumit,

Something here doesn’t quite make sense.
You mention you use Jersey, but the code snippet you share clearly shows usage of SpringMVC and not Jersey.
You also mention Swagger 1.0 – such a version doesn’t really exist anymore (maybe 4 years ago, no longer supported).
Not sure how to proceed from here.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sumit Sharma

unread,
Apr 21, 2016, 2:35:15 AM4/21/16
to Swagger
Ho Ron,
Actually for enabling swagger in my application. i have used jersey ,Jersey provide some more annontation to help swagger in documenatation.
Swagger has an higher version which is called as spring-fox but spring-fox is asking me to upgrade my spring 3.x project to spring 4.x which is not do-able for me as of now. 
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Ron Ratovsky

unread,
Apr 21, 2016, 3:04:48 AM4/21/16
to swagger-sw...@googlegroups.com
Swagger-core does not support Spring MVC and will not work with it. Using the swagger-jessey module will simply not work.
You have to use springfox for it. Springfox has older versions that should support spring 3.x but those produce an old version of Swagger which is unwise to use.

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages