分類  >  Web前端 >

喚起Weblogic啟動報錯的幾個原因

tags:    時間:2013-12-09 23:17:59
引起Weblogic啟動報錯的幾個原因

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

推薦閱讀文章

Bookmark the permalink ,來源:互聯網