我使用以下代码反序列化JSON对象:
Trying to deserialize the following string: { "start_time":"2015-10-19T13:00:00.000+02:00", "interval":900,"unit":"kW","target_values": [50.3253179, 45.15539599955082, 56.13061499595642, 68.14941400289536, 65.17419399321079, 63.140625, 47.14074699580669, 28.16027800738811, 61.14758299291134],"prosumers_primary":[ "Pr_1","Pr_4","Pr_7","Pr_1"],"prosumers_secondary":[ "Pr_2","Pr_3","Pr_8","Pr_11","Pr_16"]}
Done, the resulting object is: com.wattics.vimen.DSSdata.DRRequest@5ae50ce6
当我从测试中调用代码时,它正常工作,我得到以下输出:
Info: Trying to deserialize the following string: { "start_time":"2015-10-19T13:00:00.000+02:00", "interval":900,"unit":"kW","target_values": [50.3253179, 45.15539599955082, 56.13061499595642, 68.14941400289536, 65.17419399321079, 63.140625, 47.14074699580669, 28.16027800738811, 61.14758299291134],"prosumers_primary":[ "Pr_1","Pr_4","Pr_7","Pr_1"],"prosumers_secondary":[ "Pr_2","Pr_3","Pr_8","Pr_11","Pr_16"]}
Warning: StandardWrapperValve[DSSRequest]: Servlet.service() for servlet DSSRequest threw exception
java.lang.NoSuchMethodError: com.fasterxml.jackson.datatype.joda.deser.JodaDateDeserializerBase.findFormatOverrides(Lcom/fasterxml/jackson/databind/DeserializationContext;Lcom/fasterxml/jackson/databind/BeanProperty;Ljava/lang/Class;)Lcom/fasterxml/jackson/annotation/JsonFormat$Value;
at com.fasterxml.jackson.datatype.joda.deser.JodaDateDeserializerBase.createContextual(JodaDateDeserializerBase.java:35)
at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:653)
at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:408)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.findDeserializer(StdDeserializer.java:881)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:436)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:293)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:242)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:143)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:439)
at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3666)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3558)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2578)
at com.wattics.vimen.DSSdata.DSSRequestsJsonMapper.readValueFromJson(DSSRequestsJsonMapper.java:37)
at com.wattics.vimen.DSSdata.DSSRequestsJsonMapper.deserialiseDRRequest(DSSRequestsJsonMapper.java:19)
at com.wattics.vimsen.GDRMmanager.DRPostRequestManager.storeJsonDRRequest(DRPostRequestManager.java:60)
at com.wattics.vimsen.GDRMmanager.DRPostRequestManager.storeJsonDRRequestReturnJsonAck(DRPostRequestManager.java:35)
at com.wattics.vimsen.GDRMmanager.DSSManager.storeDRRequestReturnAck(DSSManager.java:33)
at com.wattics.vimsen.webapi.DSSRequest.doPost(DSSRequest.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)
但是当我尝试使用servlet中的代码时,我收到以下错误:
package com.wattics.vimen.DSSdata;
import org.joda.time.DateTime;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class DRRequest {
public DateTime start_time;
public String start_time_text;
public int interval;
public String unit;
public Double[] target_values;
public String[] prosumers_primary;
public String[] prosumers_secondary;
public String type;
}
任何人都可以帮助我了解导致异常的原因,如何修复它?
关联类的代码如下所示:
pom.xml
在文件<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<!-- Note: core-annotations version x.y.0 is generally compatible with
(identical to) version x.y.1, x.y.2, etc. -->
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.wattics</groupId>
<artifactId>vimsenGDRMdb</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
中,存在以下依赖项:
const ItemsToSell = [{"Name":"Cup","Price":"99.99"},{"Name":"IPhone","Price":"99.99"},{
"Name":"Pen","Price":"99.99"}]
function ListItem(props) {
return <li>{props.value}</li>;
}
function NumberList(props) {
const a = props.numbers;
return (
<ul>
{a.map((number) =>
<ListItem value={ItemsToSell[number].Name} />
)}
</ul>
);
}
const numbers = [0,1, 2];
ReactDOM.render(
<NumberList numbers={numbers} />,
document.getElementById('root')
);
答案 0 :(得分:0)
事实证明,Glassfish的配置存在问题。我在tomcat8上部署并正常工作。