java 控制台错误信息 解析

时间:2022-10-30 21:45:59

1. 阅读console信息:
信息包括: 运行时间, 调用哪个类/哪个方法/做了什么…
运行时间, 告诉我们什么时候开始运行, 程序的依次调用顺序
查看加载了哪些配置文件(.properties, xml).
查看程序的入口和出口, 从哪里开始run, 到哪里结束, 中间依次调用了哪些类的哪些方法. 看调用哪些类, 知道经过了怎样流程(可能到哪里出现了问题), 看具体哪些方法, 知道做了怎样的处理.

17:25:06,584  INFO main ClassPathXmlApplicationContext:447 - Refreshing org.springframework.context.support.ClassPathXmlApplicationContext.....
17:25:06,631 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from class path resource
17:25:06,928 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file.....
17:25:07,021 INFO main DefaultListableBeanFactory:595 - Overriding bean definition for bean......
17:25:07,021 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file....
17:25:07,053 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file ....
17:25:07,068 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file ....
17:25:07,099 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file...database-config.xml]
17:25:07,115 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file .....xml]
17:25:07,131 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file.....xml]
17:25:07,146 INFO main XmlBeanDefinitionReader:315 - Loading XML bean definitions from file .....xml]
17:25:07,349 INFO main PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [.....properties]
17:25:07,349 INFO main PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [.....properties]
17:25:07,349 INFO main PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [.....properties]
17:25:07,349 INFO main PropertyPlaceholderConfigurer:177 - Loading properties file from class path resource [.....properties]
17:25:07,396 INFO main DefaultListableBeanFactory:595 - Overriding bean definition for bean '....
17:25:07,396 WARN main CustomEditorConfigurer:171 - Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [int[]; offending editor instance: org.springframework.batch.support.IntArrayPropertyEditor@19b04e2
17:25:07,396 WARN main CustomEditorConfigurer:171 - Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [......
17:25:07,396 WARN main CustomEditorConfigurer:171 - Passing PropertyEditor instances into CustomEditorConfigurer is deprecated: use PropertyEditorRegistrars or PropertyEditor class names instead. Offending key [java.util.Date; ......
17:25:07,412 INFO main DefaultListableBeanFactory:532 - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@123b25c: defining beans ......
17:25:07,709 INFO main SimpleJobLauncher:179 - No TaskExecutor has been set, defaulting to synchronous executor.
17:25:07,740 INFO main SimpleJobLauncher:118 - ....
17:25:07,756 INFO main SimpleStepHandler:133 -...
17:25:07,771 INFO main ListenedFolderStruc:85 - Detecting folder .... will terminate at Thu May 19 17:30:00 CST 2011
......

2.看错误信息
错误信息 ex.getMessage()
堆跟踪 ex.printStackTrace();

主要就这两个常用
清楚代码流程的情况下,看一下getMessage就知道那里出错了
不然就看跟踪信息,会逐条显示出所有出错的代码位置

下面看看java是怎样抛错的:
先抛出什么, 在哪里抛出?
后抛出什么, 在哪里抛出?
分析:
先抛出一般是开始调用的方法(上层方法), 后抛出的是底层代码可能是dao或者sql error了.
抛出位置: 从每一个Exception看, 都是从下面第一个at开始run, 在最后一个at处抛出.
看下面几个Exception的顺序和关系: 第一个是最先抛出的, 第一个Exception caused By 第二个Exception. 同样 第二个Exception Caused by 第三个Exception. 原因在底层, 最后一个Exception, 当然, 也要看所有的Exception 和 Error message 才能下结论.
查看: 使用Eclipse可以跟踪到错误的位置, 然后你可以debug了.

08:02:48,528 ERROR main AbstractStep:226 ... 
java.lang.IllegalArgumentException : Unable to invoke method: ....
at org.springframework.batch.support.SimpleMethodInvoker.invokeMethod(SimpleMethodInvoker.java:108)
at org.springframework.batch.core.listener.MethodInvokerMethodInterceptor.invoke(MethodInvokerMethodInterceptor.java:68)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy5.afterStep(Unknown Source)
at org.springframework.batch.core.listener.CompositeStepExecutionListener.afterStep(CompositeStepExecutionListener.java:62)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:223)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:135)
at org.springframework.batch.core.job.flow.JobFlowExecutor.executeStep(JobFlowExecutor.java:61)
at org.springframework.batch.core.job.flow.support.state.StepState.handle(StepState.java:60)
at org.springframework.batch.core.job.flow.support.SimpleFlow.resume(SimpleFlow.java:144)
at org.springframework.batch.core.job.flow.support.SimpleFlow.start(SimpleFlow.java:124)
at org.springframework.batch.core.job.flow.FlowJob.doExecute(FlowJob.java:135)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:281)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:120)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:48)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:114)
at ..................
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.batch.support.SimpleMethodInvoker.invokeMethod(SimpleMethodInvoker.java:105)
... 17 more
Caused by: java.lang.RuntimeException : ............
at ...................
at ..................
at ................
... 22 more