gpt4 book ai didi

使用 Jackson Core Streaming API 时出现 java.lang.NoSuchMethodError

转载 作者:行者123 更新时间:2023-12-02 14:43:40 28 4
gpt4 key购买 nike

我正在使用 Jackson Core 版本 2.8.3,但为什么我不断收到 java.lang.NoSuchMethodError ?我没有使用 Jackson 的任何其他模块,仅使用核心(流媒体)API

Object[] result = imageGenerator.generate(lowerBound, upperBound, fileNames);
MWNumericArray array = (MWNumericArray)result[0];
try (Writer writer = response.getWriter();
JsonGenerator generator = res.getJsonFactory().createGenerator(writer)) {

generator.writeStartObject();
generator.writeFieldName("dimension");
generator.writeArray(array.getDimensions(), 0, 2); // java.lang.NoSuchMethodError: com.fasterxml.jackson.core.JsonGenerator.writeArray([III)V

int[] pixels = array.getIntData();
generator.writeFieldName("pixels");
generator.writeArray(pixels, 0, pixels.length);
generator.writeEndObject();
}

堆栈跟踪

at servlet.IonImageGeneratorServlet.processRequest(IonImageGeneratorServlet.java:48)
at servlet.IonImageGeneratorServlet.doGet(IonImageGeneratorServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.glassfish.tyrus.servlet.TyrusServletFilter.doFilter(TyrusServletFilter.java:305)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
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:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
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:745)

最佳答案

此错误几乎总是(99% 的时间)表明您针对一个库版本构建了代码,但部署环境有一个缺少该方法的不同版本。您的代码已正确编译,但在部署环境中加载时,JVM 尝试将其与其可用的库类版本链接,但找不到该方法。

解决方案是确保您的开发环境和部署服务器中具有相同版本的库。

关于使用 Jackson Core Streaming API 时出现 java.lang.NoSuchMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40051253/

28 4 0