2015异常问题解决方案经验总结(一)

1.     could not find java.dll

C:\Users\admin>java

Error: Registry key 'Software\JavaSoft\JavaRuntime

 

has value '1.6', but '1.8' is required.

Error: could not find java.dll

Error: Could not find Java SE RuntimeEnvironment.

 

问题原因:机器上装了多个版本的JDK,或者曾经装过不同版本的JDK,卸载不完全

解决方法:添加JAVA_HOME环境变量

添加JAVA_HOME环境变量,而且一定要放在系统变量里,不要用用户变量。

2.     liquibase.exception.ValidationFailedException:Validation Failed:

Error occurred while trying to get theupdates needed for the database. Validation Failed: 1 change sets check sumliquibase-update-to-latest.xml::200902142213::ewolodzko is now:3:ace82a1ecb3a0c3246e39f0bebe38423 

java.lang.RuntimeException: Error occurredwhile trying to get the updates needed for the database. Validation Failed:

    1 change sets check sum

         liquibase-update-to-latest.xml::200902142213::ewolodzko is now:3:ace82a1ecb3a0c3246e39f0bebe38423

 

         atorg.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:631)

         atorg.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:590)

         atorg.openmrs.util.DatabaseUpdater.updatesRequired(DatabaseUpdater.java:262)

         atorg.openmrs.web.Listener.setupNeeded(Listener.java:170)

         atorg.openmrs.web.Listener.contextInitialized(Listener.java:142)

         atorg.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4210)

         atorg.apache.catalina.core.StandardContext.start(StandardContext.java:4709)

         atorg.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:802)

         atorg.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)

         atorg.apache.catalina.core.StandardHost.addChild(StandardHost.java:583)

         atorg.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:675)

         atorg.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:601)

         atorg.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)

         atorg.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)

         atorg.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)

         atorg.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)

         atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1068)

         atorg.apache.catalina.core.StandardHost.start(StandardHost.java:822)

         atorg.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)

         atorg.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)

         atorg.apache.catalina.core.StandardService.start(StandardService.java:525)

         atorg.apache.catalina.core.StandardServer.start(StandardServer.java:759)

         atorg.apache.catalina.startup.Catalina.start(Catalina.java:595)

         atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

         atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

         atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

         atjava.lang.reflect.Method.invoke(Method.java:597)

         atorg.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)

         atorg.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)

Caused by:liquibase.exception.ValidationFailedException: Validation Failed:

    1 change sets check sum

         liquibase-update-to-latest.xml::200902142213::ewolodzko is now:3:ace82a1ecb3a0c3246e39f0bebe38423

 

         atliquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:141)

         atliquibase.Liquibase.listUnrunChangeSets(Liquibase.java:625)

         atorg.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:619)

         ...28 more

 

 

Caused by: java.lang.Exception: Unable toget a connection to the database.  Pleasecheck your openmrs runtime properties file and make sure you have the correctconnection.username and connection.password set

         atorg.openmrs.util.DatabaseUpdater.getLiquibase(DatabaseUpdater.java:368)

         atorg.openmrs.util.DatabaseUpdater.getUnrunDatabaseChanges(DatabaseUpdater.java:617)

         ...28 more

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException:Could not create connection to database server. Attempted reconnect 3 times.Giving up.

         atsun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

         atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

         atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

         atjava.lang.reflect.Constructor.newInstance(Constructor.java:513)

         atcom.mysql.jdbc.Util.handleNewInstance(Util.java:406)

         atcom.mysql.jdbc.Util.getInstance(Util.java:381)

         atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)

         atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)

         atcom.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)

         atcom.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2364)

         atcom.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:773)

         atcom.mysql.jdbc.JDBC4Connection.(JDBC4Connection.java:46)

         atsun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

         atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

         atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

         atjava.lang.reflect.Constructor.newInstance(Constructor.java:513)

         atcom.mysql.jdbc.Util.handleNewInstance(Util.java:406)

         atcom.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:352)

         atcom.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)

         atjava.sql.DriverManager.getConnection(DriverManager.java:582)

         atjava.sql.DriverManager.getConnection(DriverManager.java:185)

         atorg.openmrs.util.DatabaseUpdater.getConnection(DatabaseUpdater.java:427)

         atorg.openmrs.util.DatabaseUpdater.getLiquibase(DatabaseUpdater.java:365)

         ...29 more

Caused by:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown database'openmrs'

错误原因:不是第一次运行openmrs

解决方法:删除运行时配置文件

把前一次运行openmrs时生成的运行时配置文件删除,路径:C:\Users\admin\ApplicationData\OpenMRS

3.     get方式提交中文乱码

解决方法:在tomcat下指定URL编码格式为UTF-8

配置tomcatconf/server.xml 

<Connectorexecutor="tomcatThreadPool" 
              port="8080"protocol="org.apache.coyote.http11.Http11NioProtocol" 
              connectionTimeout="30000" 
              maxKeepAliveRequests="1" 
              maxHttpHeaderSize="8192" 
  URIEncoding="UTF-8" 
   enableLookups="false" 
   acceptCount="100" 
   redirectPort="8443" 
/> 

 

如果使用的是Eclipse,因为Eclipse运行的是虚拟的tomcat服务器,原始的tomcat修改后需要重新配置到Eclipse,或者直接到虚拟tomcat下也做修改。

虚拟tomcat路径为:\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

4.     Tomcat启动超时异常unable to start within 45 seconds

ServerTomcat v6.0 Server at localhost was unable to start within 45 seconds. If theserver requires more time, try increasing the timeout in the server editor

异常原因:Tomcat默认启动最大时长是45秒,当启动时间超过45秒回抛出此异常

解决方法:修改默认启动时常

如果你用的是eclipse,双击tomcat服务器,打开一个视图,右边有个times out,点开,把45改成450或者更大即可

5.     Tomcat启动: Errorstarting static Resources

一般来说出现这种错误是由于你在MyEclipse或Eclipse中删除了某个项目后,没有将Tomcat-6.x\conf\server.xml相关修改完全,才引起了这个问题

解决

第一步 清空Tomcat-6.x目录下的work目录;

第二步再把server.xml的没有用的<Context>标签都删除或者注释掉;

第三步 最后再将conf目录下的Catalina目录下的localhost内的所有文件都删除

6.     SetPropertiesRule]{Server/Service/Engine/Host/Context}Setting property 'source'

通过Eclipse集成Tomcat6启动时报以下警告信息:

SetPropertiesRule]{Server/Service/Engine/Host/Context}Setting property 'source' to 'org.eclipse.jst.jee.server:webtest' did not finda matching property.

 

这是因为我们在eclipse下,通过tomcat部署web工程时,会在tomcat的配置文件server.xml中会自动生成一个关于该web工程的配置信息,类似于下面的东西:

<Context docBase="webtest" path="/webtest"reloadable="true" source="org.eclipse.jst.jee.server:webtest"/>

而默认情况下,server.xml的 Context元素不支持名称为source的属性,所以会发出警告。

解决

关闭tomcat,双击eclipse下tomcat服务器,在出来的Tomcat server at localhost页面中找到server options选项,选中其中的选项”Publish modualcontexts to separat XML files“,ctr+s 保存,启动tomcat。

这样项目的配置信息会被放到conf\Catalina\localhost目录下的单独xml文件中

7.     SyntaxError: unterminatedstring literal

无端接的字符串,出现该错误的原因是字符串的双引号或单引号中间有违反json规范的特殊字符,如回车,换号,单引号,双引号等

解决方法:删除字符串中非法字符

8.     java.lang.OutOfMemoryError:PermGen space

网上查找可知该异常产生的原因是JVM默认分配的4M运行空间过小,J2EE项目加载的类过多,造成内存溢出。

解决方案为:通过添加参数增加分配给JVM的内存空间

-Xms256m -Xmx512m -XX:MaxNewSize=256m -XX:MaxPermSize=256m

网上的解决方案多半是针对纯Tomcat的情况,并非通过Eclipse启动的Tomcat。
或者修改eclipse.ini配置文件,不过这些方法都不适合Eclipse运行Tomcat抛出该异常的情况。

修改eclipse.ini配置文件增大的是Ecipse开发平台本身运行的JVM的空间,并非Eclipse启动Tomcat的内存空间。

正确的方法是,点击“Run” – “Run Configurations…”,选中Tomcat Server,进入Arguments分页,在VM arguments中加入提升初始分配空间的参数,如下图所示:

2015异常问题解决方案经验总结(一)_第1张图片

9.     InvalidDataAccessResourceUsageException

org.springframework.dao.InvalidDataAccessResourceUsageException:could not insert:

Caused by: org.hibernate.exception.SQLGrammarException: could notinsert:

异常原因:数据库表使用了mysql的关键字,请检查修改表字段。

解决:检查修改表字段

10.             chrome通过file协议浏览html代码时,发送的ajax请求本地文件,会报跨域错误

XMLHttpRequest cannot loadfile:///E:/webs/extJS/ext-3.3.0/examples/csdn/combobox.txt?_dc=1414738973999.Cross origin requests are only supported for protocol schemes: http, data,chrome-extension, https, chrome-extension-resource.

解决

解决办法是给chrome添加启动参数:--allow-file-access-from-files ,这样本地ajax请求就不会报跨域错误了。(注意如果给chrome添加多个启动参数,每个启动参数“--”之前要有空格隔开,如"C:\ProgramFiles\Google\Chrome\Application\chrome.exe" --enable-file-cookies--allow-file-access-from-files

具体方法:在浏览器快捷方式上右键-属性-快捷方式-目标 如下图:

 2015异常问题解决方案经验总结(一)_第2张图片

你可能感兴趣的:(Web,异常,解决方案,经验)