1:数据库链接的URL问题
问 题关键出现在红色参数部分:jdbc:mysql://localhost:3306/hzzj?charsetEncoding=UTF8& amp;defaultFetchSize=100&useCursorFetch=true&defaultFetchSize=100
报错特征:
2012-05-11 10:19:08,328 WARN [com.mchange.v2.resourcepool.BasicResourcePool] - -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
java.sql.SQLException: java.lang.NullPointerException
?at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:904)
?at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:704)
?at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:547)
2012-05-11 10:19:08,390 WARN [org.hibernate.cfg.SettingsFactory] - Could not obtain connection metadata
java.sql.SQLException: Connections could not be acquired from the underlying database!
?at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
?at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
?at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
?at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBeanCaused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
?at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
?at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
解决方式:将红色参数去除即可
?
2:Struts2的struts.xml文件中包含其他文件时用的是*号
问题关键:<include file="struts*.xml"/>
报错特征:
<2012-5-11 上午10时31分48秒 CST> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
Unable to load configuration. - [unknown location]
?at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
?at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
?at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
?at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
?at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
?Truncated. see log file for complete stacktrace
Error loading configuration file struts.xml - [unknown location]
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:148)
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:111)
?at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:164)
?at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
?at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
?Truncated. see log file for complete stacktrace
unable to attain an URLClassLoader - [unknown location]
?at com.opensymphony.xwork2.util.ClassPathFinder.findMatches(ClassPathFinder.java:80)
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:923)
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:144)
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:111)
?at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:164)
?Truncated. see log file for complete stacktrace
>
解决方式:将<include file="struts*.xml"/>更改为如<include file="struts_system.xml"/>。
造成的原因如下:
xwork的ClassPathFinder.findMatches方法里取得当前classloader的方式是
ClassLoader loader = Thread.currentThread().getContextClassLoader();在tomcat环境下取到的是 URLClassloader的实例,而在weblogic下面却是 weblogic.utils.classloaders.ChangeAwareClassLoader,weblogic有自己的 classLoader机制,因此导致了错误
?
3:Struts2的struts.xml文件中配置模式的参数问题
问题关键:<constant name="struts.devMode" value="true" />
报错特征:
<2012-5-11 上午10时35分17秒 CST> <Error> <HTTP> <BEA-101165> <Could not load user defined filter in web.xml: org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.
java.lang.NullPointerException
?at com.opensymphony.xwork2.util.FileManager$FileRevision.needsReloading(FileManager.java:209)
?at com.opensymphony.xwork2.util.FileManager.fileNeedsReloading(FileManager.java:60)
?at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.needsReload(XmlConfigurationProvider.java:325)
?at org.apache.struts2.config.StrutsXmlConfigurationProvider.needsReload(StrutsXmlConfigurationProvider.java:168)
?at com.opensymphony.xwork2.config.ConfigurationManager.conditionalReload(ConfigurationManager.java:220)
?Truncated. see log file for complete stacktrace
>
解决方式:将<constant name="struts.devMode" value="true" />更改为<constant name="struts.devMode" value="false" />
?
4:在做查询的时候,报出? org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken这? 个错误(是通过数据源连接的)
问题关键:Weblogic环境中缺失antlr.jar Jar包
报错特征:
netest?Exception: org.hibernate.queryexception:classnotfindException:org.hibernate.hql.ast.HqlToken
解决方式:
A: 将如果你是通过Eclipse/Myeclipse启动weblogic的,那么依次点击windows-preferences-myeclipse workbench-servers-weblogic-weblogic10.x-path,在prepend to classpath选项中,把hibernate要用到的包antlr.jar添加到weblogic的classpath中。
这样在weblogic便可以通过myeclipse正常启动,以上提到的问题解决。
B:如果你是通过weblogic自带的脚本运行,即通过startWebLogic.cmd启动:
将 工程里的antlr.jar拷贝到weblogic的wlserver_10.3\server\lib文件夹下面,在domains \base_domain\bin里找到startWebLogic.cmd文件,在set classpath 的上下分别增加了两句话,如下: set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.6rc1.jar?
??????????????????????????????????????????????????????????????????????????? set CLASSPATH=%SAVE_CLASSPATH%?
????????????????????????????????????????????????????????????????????????????set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
然后启动WebLogic,系统正常运行。
?
?
?
http://hi.baidu.com/shancunyefeng/item/30e93236708830342e0f812d