对于IBM,使用Java-ee-7.0从Jax-rs 1.1迁移到2.0的问题是9

时间:2019-05-07 20:51:30

标签: java json rest jax-rs websphere-9

我正在开发一个项目,以升级我的现有应用程序,该应用程序是在JAX-RS 1.1中开发并在WebSphere 8.5中运行的。现在,我将其升级为使用IBM的Java-ee-7.0从Jax-rs 1.1迁移到2.0,是

当我从邮递员打来时     https://abczyz.com/rest/Services_V1/SubmitM     “ {” mID“:” XYZ654546“,” barcID“:”“,” ID“:” 118“,”名称“:” JACKS“,” CDefectArray“:[],” BDefectArray“:[]}”

@POST
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Path("/SubmitM")
public JSONObject submitM(JSONObject jsonObjectRequest) {

}

预期它可以像JAX RS 1.1一样工作,但不起作用,

5/7/19 14:11:53:571 EDT] 0000013d 0(id=120)]    E   Error occurred during error handling, give up!
                                 org.apache.cxf.interceptor.Fault: Invalid type of value.  Type: [java.util.ArrayList] with value: [[]]
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:76)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:371)
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
    at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:256)
    at com.ibm.ws.jaxrs20.endpoint.AbstractJaxRsWebEndpoint.invoke(AbstractJaxRsWebEndpoint.java:147)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.handleRequest(IBMRestServlet.java:187)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.doPost(IBMRestServlet.java:145)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at com.ibm.websphere.jaxrs.server.IBMRestServlet.service(IBMRestServlet.java:133)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1235)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:779)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
    at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:178)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.invokeTarget(WebAppFilterChain.java:143)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:78)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:969)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1109)
    at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4198)
    at com.ibm.ws.webcontainer.webapp.WebAppImpl.handleRequest(WebAppImpl.java:2208)
    at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1030)
    at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
    at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:382)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:532)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:318)
    at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:289)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
    at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
    at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
    at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
    at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
    at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
    at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
    at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
    at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
    at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1909)
Caused by: java.lang.IllegalArgumentException: Invalid type of value.  Type: [java.util.ArrayList] with value: [[]]
    at com.ibm.json.java.JSONObject.put(JSONObject.java:241)
    at org.codehaus.jackson.map.deser.MapDeserializer._readAndBind(MapDeserializer.java:244)
    at org.codehaus.jackson.map.deser.MapDeserializer.deserialize(MapDeserializer.java:166)
    at org.codehaus.jackson.map.deser.MapDeserializer.deserialize(MapDeserializer.java:24)
    at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:1961)
    at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:889)
    at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:410)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils$2.run(JAXRSUtils.java:1362)
    at java.security.AccessController.doPrivileged(AccessController.java:696)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1358)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1308)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:847)
    at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:810)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:267)
    at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:98)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
    ... 35 more 

编辑-1

尝试添加

<dependency>
  <groupId>com.fasterxml.jackson.jaxrs</groupId>
  <artifactId>jackson-jaxrs-json-provider</artifactId>
  <version>2.9.7</version>
</dependency>

我还扩展了Application类

import javax.ws.rs.core.Application;

public class MyClass extends Application {

    @Override
    public Set<Object> getSingletons() {
        Set<Object> singletons = new HashSet<Object>();
        singletons.add(new JacksonJaxbJsonProvider());
        return singletons;
    }
}

编辑2

我们正在使用com.ibm.ws.prereq.jaxrs20.jar

import com.ibm.json.java.JSONArray;
import com.ibm.json.java.JSONObject;

1 个答案:

答案 0 :(得分:0)