一個關於java.lang.ClassCastException: $Proxy65的錯誤解決辦法

來源:互聯網
上載者:User

錯誤描述:

今天用jsp調用一個會話bean的時候,出現了一個“java.lang.ClassCastException: $Proxy65”的錯誤,百度了一下,中文的解釋是:

說JBOSS的WEB載入器預設是FALSE,根據設定檔的說明,其目的就是當出現多個載入器的時候,通過設定真假值來決定是否把JBOSS的WEB載入器作為統一的載入器。也就是說,如果在程式中特殊指明了某一個載入器,或者lib中用到了其它版本tomcat的JAR包,那麼JBOSS內建的載入器設為FLASE,就會導致WAR包的JAR和類檔案都沒有被JBOSS的載入器載入。

解決辦法:

把JBOSS內建的載入器由預設的FALSE改為TRUE。

解決細節:

修改jboss-4.2.3.GA/server/default/deploy/jboss-web.deployer/META-INF下的jboss-service.xml檔案中的

seJBossWebLoader屬性改為true(預設是false)。

改後:

<attribute name="UseJBossWebLoader">true</attribute>

 

下面是一段英文的解釋:

 

See ClassLoadingConfiguration.

Available option in deploy/jbossweb-tomcat.sar/META-INF/jboss-service.xml

or deploy/jboss-web.deployer/META-INF/jboss-service.xml

This configuration options toggles usage of separate classloaders for web modules. The JBoss unified classloader holds all the classes from multiple web applications in one big classloader and may cause unwanted interference.

Example

Imagine web modules "sales.war" and "stock.war", both containing some version of "utility.jar". In case "sales.war" uses version 1.0 and "stock.war" requires version 2.0, turning off the unified web loader is the safest solution. If you don't, the first loaded library will have priority, and remains in the classloader till the reference count drops to zero.

The disadvantage of using isolated classloaders: either you need to duplicate the same library across multiple web modules, or add it to the classpath of your server instance (default: lib/). The instance libraries are defaults, they can be overridden when the web module contains it's own custom versions.

The configuration file contains a small comment about isolation of JSP files as well, to separate two JSP files with the same name from two different web modules. In JBoss 4.0.5, using non-precompiled JSP pages, this seems to work fine, even with the JBoss unified web loader.

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.