当前位置: 首页 > 知识库问答 >
问题:

由于Sybase JDBC驱动程序,Charset.AvailableCharsets引发的NullPointerException

蒋哲
2023-03-14
10:19:17.548 [main] ERROR o.s.t.w.s.TestDispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]: Constructor threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:289) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.createDefaultStrategy(DispatcherServlet.java:810) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.getDefaultStrategies(DispatcherServlet.java:779) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.initHandlerAdapters(DispatcherServlet.java:587) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:444) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:432) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:525) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:459) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) [spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at javax.servlet.GenericServlet.init(GenericServlet.java:160) [tomcat-servlet-api-7.0.37.jar:3.0.FR]
    at org.springframework.test.web.servlet.MockMvcBuilderSupport.createMockMvc(MockMvcBuilderSupport.java:53) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.web.servlet.setup.DefaultMockMvcBuilder.build(DefaultMockMvcBuilder.java:207) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at com.mycompany.ui.controller.ConnectionInfosControllerTest.setup(ConnectionInfosControllerTest.java:41) [test-classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_21]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_21]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_21]
    at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_21]
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) [junit-4.11.jar:na]
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) [junit-4.11.jar:na]
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) [junit-4.11.jar:na]
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24) [junit-4.11.jar:na]
    at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) [junit-4.11.jar:na]
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) [junit-4.11.jar:na]
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) [junit-4.11.jar:na]
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) [junit-4.11.jar:na]
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) [junit-4.11.jar:na]
    at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309) [junit-4.11.jar:na]
    at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) [spring-test-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) [.cp/:na]
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) [.cp/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter]: Constructor threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    ... 44 common frames omitted
Caused by: java.lang.NullPointerException: null
    at java.nio.charset.Charset.put(Charset.java:550) ~[na:1.7.0_21]
    at java.nio.charset.Charset.access$300(Charset.java:276) ~[na:1.7.0_21]
    at java.nio.charset.Charset$4.run(Charset.java:593) ~[na:1.7.0_21]
    at java.nio.charset.Charset$4.run(Charset.java:585) ~[na:1.7.0_21]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_21]
    at java.nio.charset.Charset.availableCharsets(Charset.java:584) ~[na:1.7.0_21]
    at org.springframework.http.converter.StringHttpMessageConverter.<init>(StringHttpMessageConverter.java:66) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.http.converter.StringHttpMessageConverter.<init>(StringHttpMessageConverter.java:56) ~[spring-web-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.<init>(AnnotationMethodHandlerAdapter.java:201) ~[spring-webmvc-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.7.0_21]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) ~[na:1.7.0_21]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.7.0_21]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525) ~[na:1.7.0_21]
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) ~[spring-beans-3.2.3.RELEASE.jar:3.2.3.RELEASE]
    ... 46 common frames omitted
package pack;

import java.nio.charset.Charset;
import java.util.Iterator;
import java.util.Set;

public class TestCase {
    public static void main(String[] args) {
        Set set = Charset.availableCharsets().keySet();
        for (Iterator iterator = set.iterator(); iterator.hasNext();) {
            String s = (String) iterator.next();
            System.out.println(s);
        }
    }
}
Exception in thread "main" java.lang.NullPointerException
    at java.nio.charset.Charset.put(Charset.java:550)
    at java.nio.charset.Charset.access$300(Charset.java:276)
    at java.nio.charset.Charset$4.run(Charset.java:593)
    at java.nio.charset.Charset$4.run(Charset.java:585)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.nio.charset.Charset.availableCharsets(Charset.java:584)
    at pack.TestCase.main(TestCase.java:9)

编辑4:我设法找出了有问题的依赖关系。在这里:

<dependency>
    <groupId>com.sybase</groupId>
    <artifactId>jconn4</artifactId>
    <version>7.07.GA</version>
    <scope>runtime</scope>
</dependency>

通过移除此依赖项,TestCase将正确执行并打印出所有可用的字符集。然而,我们确实需要一个数据库驱动程序为我们的应用程序。有人知道sybase jdbc驱动程序出了什么问题吗?

共有1个答案

西门经国
2023-03-14

它原来是Sybase JDBC驱动程序中的一个bug,可以在这里看到。引用上面链接中不满的Sybase JDBC驱动程序用户的话:

没有什么应该让我感到惊讶,因为目前的Sybase驱动程序完全坏了,已经超过一年了!它包含一个CharsetProvider,返回一个null迭代器,导致Charset.AvailableCharsets()抛出一个nullpointer异常。很多框架,比如Spring调用charset.availableCharsets()。

我不知道如何向Sybase/SAP报告这个bug...

 类似资料:
  • 问题内容: 在硒测试中出现以下错误 我所做的是 环境: Firefox v47.0 Webdriver 3.0.0-beta2 问题答案: 这是完全可以预期的。没有GeckoDriver(木偶)的发行版支持该类。这是Mozilla团队开发Marionette的首要任务之一。

  • 在进行大容量数据加载、根据日志数据递增计数器时,我遇到了超时异常。我使用DataStax2.0-RC2 java驱动程序。 这是服务器无法跟上的问题(即服务器端配置问题),还是客户端在等待服务器响应时感到厌烦的问题?不管怎样,我能做一个简单的配置更改来解决这个问题吗? 其中一个节点大致在它发生的时间报告这一点:

  • 问题内容: 我有一个包含用户信息的数据库,我想创建一个公共静态变量,以便在任何给定时间返回数据库整数,而不必为每个整数都做一个空,但这给了我这个错误: 这是我的代码: 有人知道我在做什么错吗?我尝试使用Google的东西,但是更改代码将我从一个错误转移到了另一个错误…因此,我现在还不确定。 我正在运行JDBC驱动程序sqlite-jdbc-3.8.11.2.jar 问题答案: 未实现。我想你只是想

  • 我正试图使用IntelliJ IDE从Spark连接到老虎机数据库。有人能帮助jdbc驱动程序(。jar)文件吗?我正在寻找“com.tigergraph.jdbc.驱动程序”。 我确实找到了下面的gitHub存储库,其中包含了所有必需的信息。java文件。但是,我不知道如何在我的spark项目中使用它。https://github.com/tigergraph/ecosys/tree/maste

  • 问题内容: 美好的一天, 你们知道GBQ的任何JDBC接口或驱动程序吗? 请只使用Java-Python库已经完成。 预先感谢,祝您有美好的一天,迈克 问题答案: 有一个第三方JDBC驱动程序,可以从以下位置获得: http://code.google.com/p/starschema-bigquery- jdbc/ 它支持与原始Google BigQuery相同的SQL SELECT语法,并且不

  • 问题内容: 我在用于SQLite的JDBC驱动程序中有问题。 我正在用SELECT语句执行查询。 如果我得到一个空(0行),则在调用时会抛出“ Closed ResultSet”异常。 没有大量的JDBC经验,我的理论(我无法通过JavaDocs确认)是 对空(零行)结果集不起作用(通过设计或由于错误) 的“打开”标志设置为零行(同样是设计或错误) 我看到了此错误报告,但不确定是否相关。 我的要求