gpt4 book ai didi

java - 带有 Angular api请求的tomcat服务器问题

转载 作者:行者123 更新时间:2023-11-28 22:24:42 24 4
gpt4 key购买 nike

这是我从 angular 收到的正文消息。想了解这是这个问题的根本原因。我不太确定是 tomcat 还是 angular 的哪一部分造成了这个问题。有什么猜测吗?

</style></head><body><h1>HTTP Status 500 – Internal Server Error</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> java.lang.NullPointerException</p><p><b>Description</b> The server encountered an unexpected condition that prevented it from fulfilling the request.</p><p><b>Exception</b></p><pre>javax.servlet.ServletException: java.lang.NullPointerException
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:432)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1232)
org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:271)
org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:158)
</pre><p><b>Root Cause</b></p><pre>java.lang.NullPointerException
com.mysql.cj.jdbc.result.ResultSetImpl.findColumn(ResultSetImpl.java:577)
com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:915)
com.idem.api.SampleService.getSampleList(SampleService.java:263)
com.idem.api.SampleService.getAllSamples(SampleService.java:147)
sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:76)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:148)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:191)
org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:200)
org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:103)
org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:493)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:415)
org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:104)
org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:277)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:272)
org.glassfish.jersey.internal.Errors$1.call(Errors.java:268)
org.glassfish.jersey.internal.Errors.process(Errors.java:316)
org.glassfish.jersey.internal.Errors.process(Errors.java:298)
org.glassfish.jersey.internal.Errors.process(Errors.java:268)
org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:289)
org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:256)
org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:703)
org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:416)
org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:370)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:389)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:342)
org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:229)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.apache.catalina.filters.ExpiresFilter.doFilter(ExpiresFilter.java:1232)
org.apache.catalina.filters.CorsFilter.handleSimpleCORS(CorsFilter.java:271)
org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:158)
</pre><p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p><hr class="line" /><h3>Apache Tomcat/8.5.33</h3></body></html>

编辑:我似乎能够解决问题。问题是我对我的所有 API 请求都使用 JDBC 单例,但 JDBC 的设置方式是数据库连接使用语句对象来运行其查询。因此,当我尝试使用多个请求时,当语句仍在使用时,请求有时会发生冲突,但另一个请求却想捕获它。

最佳答案

根据所提供的信息,很难判断真正的根本原因。从数据库读取时,显示的跟踪显示 NullPointerException。该调用似乎来自 com.idem.api.SampleService.getAllSamples。我假设这是您的 Java 代码的一部分(部署到 Tomcat)。

在接口(interface)级别(Angular/后端之间),您应该引入一些验证,例如对于从 Angular 前端传递到后端的意外空值。这将有助于澄清真正的根本原因在哪里。

关于java - 带有 Angular api请求的tomcat服务器问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52523504/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com