环境:

  • 电脑:win 10

  • IDE:

    • Eclipse Java EE IDE for Web Developers.
    • Version: Luna Service Release 2 (4.4.2)
    • Build id: 20150219-0600
1、properties读取配置文件,报空指针异常错误
  • 错误信息:
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at com.javasm.util.JdbcUtils.getConnection(JdbcUtils.java:20)
at com.javasm.util.JdbcUtils.tetsConnection(JdbcUtils.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
  • 源码:
InputStream inputStream = JdbcUtils.class.getClassLoader()
.getResourceAsStream("dbconfig.properties");
Properties properties = new Properties();
  • 原因:配置文件路径书写错误!!!

  • 修改后的路径:

InputStream inputStream = JdbcUtils.class.getClassLoader()
.getResourceAsStream("com/javasm/util/dbconfig.properties");
Properties properties = new Properties();
  • 注意:配置文件直接放在项目根目录下 无法正确读取,只有放在对应的目录下才可以

Java web错误汇总的更多相关文章

  1. Java web错误总结~

    1.java程序中没有错,但是项目上面显示一个红叉的解决办法 错误信息: 报Description  Resource Path Location Type Java compiler level d ...

  2. Java Web 错误排查

    排查404 1. 检查web.xml,有没有放在web-inf下面,再检查过滤器有没有配置 <filter> <filter-name>struts</filter-na ...

  3. JAVA and JAVA WEB with TOMCAT and ECLIPSE 学习过程中遇到的字符乱码问题及解决方法汇总(随时补充)

    JAVA语言具有跨平台,unicode字符集编码的特点. 但是在开发过程中处理数据时涉及到的字符编码问题零零散散,尤其是处理中文字符时一不留神就可能出现一堆奇奇怪怪的符号,俗称乱码. 对于乱码,究其原 ...

  4. java web工程的错误页面的简单配置

    jsp页面,本身服务器也会将该页面翻译成一个servlet页面,所以请求该页面就会有可能出现错误的情况,就会出现下面类似的页面 这样给客户看到并不友好. 1.jsp页面<%@ page %> ...

  5. Eclipse导入web项目发布项目时报Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java EE 5 and 6 Web错误解决方案

    Eclipse导入web项目后,将web项目加载到server进行发布时,提示Tomcat version 7.0 only supports J2EE 1.2, 1.3, 1.4, and Java ...

  6. 2017.10.28 针对Java Web应用中错误异常处理方法的运用

    针对Java Web应用中错误异常处理方法的运用 在javaweb中其异常都需要对Checked Exception之下的Exception进行继承,并且有选择地对发生的错误和异常进行处理.Java同 ...

  7. Java Web应用定制404错误页面

    Http响应状态码404的含义是服务器端没有找到客户端请求的资源,定制404错误页面至少有以下两个好处: 1.向客户端隐藏服务器信息,服务器提供的默认404错误页面上一般都包含当前应用使用的是什么服务 ...

  8. 【Elasticsearch】【WEB】java web服务连接es elasticsearch始终报错,无法正常连接使用的错误解决历程

    前情提要: web服务往华为云上迁移 ================内网的好环境,相关配置=================== 1.web服务关于ES的集群配置如下: elasticAddress ...

  9. java web 404错误页面配置

    java web 404错误页面配置:注意红框的地方,在工程的web.xml文件里的最开头加入如下的内容便可,但是也有问题,针对以.action后缀名和.jsp后缀名不起作用, 因为后面配置了一些拦截 ...

随机推荐

  1. WEB安全之Token浅谈

    Token一般用在两个地方——防止表单重复提交.anti csrf攻击(跨站点请求伪造). 两者在原理上都是通过session token来实现的.当客户端请求页面时,服务器会生成一个随机数Token ...

  2. stl_queue.h

    stl_queue.h // Filename: stl_queue.h // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: http:/ ...

  3. perl: warning: Falling back to the standard locale ("C").

    /********************************************************************************** * perl: warning: ...

  4. FFmpeg 'scale' filter not present, cannot convert pixel formats.

    /*************************************************************************** * FFmpeg 'scale' filter ...

  5. Mysql备份脚本python编写

    #!/usr/bin/env python #-*- coding: UTF-8 -*- ####################################################### ...

  6. bzoj 2002: 弹飞绵羊 Link-Cut-Tree

    题目: Description 某天,Lostmonkey发明了一种超级弹力装置,为了在他的绵羊朋友面前显摆,他邀请小绵羊一起玩个游戏.游戏一开始,Lostmonkey在地上沿着一条直线摆上n个装置, ...

  7. vue 打包去掉console.log

    在webpack.prod.conf.js  文件中将设置修改为 先全局找到  UglifyJsPlugin 然后修改为: new UglifyJsPlugin({ uglifyOptions: { ...

  8. navicat导入sql文件

    Hello,大家好.Navicat是我们平时使用较多的一个数据库客户端工具,平时小天我主要是用来连接mysql的,使用的时候还是很方便的. 今天小天我就给大家分享一个Navicat如何导入导出sql文 ...

  9. POJ 1503 Integer Inquiry(大数相加)

    一.Description One of the first users of BIT's new supercomputer was Chip Diller. He extended his exp ...

  10. html中插入css和js

    插入css: HTML周明华添加css样式的方法有很多种,常见的有一下几种:. 1.直接标签后添加如: <html> <div style="background:red; ...