如何解析 rg.glassfish.jersey.server.model.ModelValidationExcepti



我们正在尝试编写一个接受文件上传和xml有效负载的REST服务。

以下是方法签名:

@POST
    @Path("/upload")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.APPLICATION_XML)
    public Response upload(@HeaderParam("appName") String appName
            , @FormDataParam("payloadXML") String s, @FormDataParam("file") InputStream in) {
         .... java code ...
}

网络.xml

<servlet>
        <servlet-name>ServletName</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>        
        <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>

我们在构建路径中包含以下 jar:泽西-媒体-多部分-2.17.jar油印-1.9.3.jar

我们将使用 Post 测试此服务

当我们启动应用程序时,我们得到以下异常:

org.glassfish.jersey.internal.Errors logErrors
SEVERE: Following issues have been detected: 
WARNING: Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.
<Feb 7, 2019 2:14:33 PM IST> <Error> <org.glassfish.jersey.internal.Errors> <BEA-000000> <Following issues have been detected: 
WARNING: Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.
> 
<Feb 7, 2019 2:14:33 PM IST> <Error> <HTTP> <BEA-101216> <Servlet: "ServletName" failed to preload on startup in Web application: "/appUrl".
org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    Truncated. see log file for complete stacktrace
> 
<Feb 7, 2019 2:14:33 PM IST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "611766299216730" for task "2". Error is: "weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']"
weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
    at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
    Truncated. see log file for complete stacktrace
Caused By: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    Truncated. see log file for complete stacktrace
> 
<Feb 7, 2019 2:14:33 PM IST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 7 task for the application "_auto_generated_ear_".> 
<Feb 7, 2019 2:14:33 PM IST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating start task for application "_auto_generated_ear_".> 
<Feb 7, 2019 2:14:33 PM IST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']:org.glassfish.jersey.server.model.ModelValidationException:Validation of the application resource model has failed during application initialization.
[[FATAL] Method public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream) on resource class org.company.rs.resource.AppResource contains multiple parameters with no annotation. Unable to resolve the injection source.; source='ResourceMethod{httpMethod=POST, consumedTypes=[multipart/form-data], producedTypes=[application/xml], suspended=false, suspendTimeout=0, suspendTimeoutUnit=MILLISECONDS, invocable=Invocable{handler=ClassBasedMethodHandler{handlerClass=class org.company.rs.resource.AppResource, handlerConstructors=[org.glassfish.jersey.server.model.HandlerConstructor@40a0aadd]}, definitionMethod=public javax.ws.rs.core.Response org.company.rs.resource.AppResource.upload(java.lang.String,java.lang.String,java.io.InputStream), parameters=[Parameter [type=class java.lang.String, source=appName, defaultValue=null], Parameter [type=class java.lang.String, source=null, defaultValue=null], Parameter [type=class java.io.InputStream, source=null, defaultValue=null]], responseType=class javax.ws.rs.core.Response}, nameBindings=[]}']
    at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:555)
    at org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
    at org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
    Truncated. see log file for complete stacktrace
> 

请指教。

此问题

已通过使用所有球衣罐的相同版本得到解决。

相关内容

  • 没有找到相关文章

最新更新