码迷,mamicode.com
首页 > Web开发 > 详细

weblogic服务器上类或者方法找不到的解决办法

时间:2014-05-08 15:31:19      阅读:1688      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   class   code   java   

下面以eclipse-birt(报表)为例,介绍这种问题出现的原因以及解决之道:

 分析比较好的见http://developer.actuate.com/community/forum/index.php?/topic/9315-exception-javalangnosuchmethoderror/

  1>现象:

bubuko.com,布布扣

I could run report as stand alone, but while I am trying to use report engine in weblogicI am getting following error.
java.lang.NoSuchMethodError: org.mozilla.javascript.ImporterTopLevel.initStandardObjects(Lorg/mozilla/javascript/Context;Z)V

root cause:

java.lang.NoSuchMethodError: org.mozilla.javascript.ImporterTopLevel.initStandardObjects(Lorg/mozilla/javascript/Context;Z)V
org.eclipse.birt.core.script.ScriptContext.(ScriptContext.java:80)
org.eclipse.birt.core.script.ScriptContext.(ScriptContext.java:67)
org.eclipse.birt.report.engine.executor.ExecutionContext.(ExecutionContext.java:295)
org.eclipse.birt.report.engine.api.impl.EngineTask.(EngineTask.java:137)
org.eclipse.birt.report.engine.api.impl.RunAndRenderTask.(RunAndRenderTask.java:62)
org.eclipse.birt.report.engine.api.impl.ReportEngineHelper.createRunAndRenderTask(ReportEngineHelper.java:292)
org.eclipse.birt.report.engine.api.impl.ReportEngine.createRunAndRenderTask(ReportEngine.java:299)
com.teamcenter.project.birt.servlet.WebReport.doGet(WebReport.java:90)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.teamcenter.project.servlet.LoginTimerFilter.doFilter(LoginTimerFilter.java:74)
com.teamcenter.project.servlet.UTF8EncodingFilter.doFilter(UTF8EncodingFilter.java:50)
bubuko.com,布布扣

  2>原因:

bubuko.com,布布扣
The problem is because the application server contains a older version of
Rhino‘s js.jar, while BIRT uses the latest version (1.6RC1). Because the js.jar
in the application server is loaded before the one in BIRT, the older version
of class org.mozilla.javascript.Context is loaded. Since the older version of
class org.mozilla.javascript.Context doesn‘t contain function
initStandardObjects, a runtime java.lang.NoSuchMethodError happened.

To solve this kind of problem, the application server usually provides a
configuration to allow loading application‘s java classes before the app
server‘s. 
bubuko.com,布布扣

  3>解决:

  

bubuko.com,布布扣
the conflict was between Weblogic Application Server and BIRT library, in weblogic-application.xml we have added the following configuration which has resolved the issue.

Configuration:
<prefer-application-packages>
<package-name>org.mozilla.*</package-name>    
</prefer-application-packages>
bubuko.com,布布扣

   另外一篇比较好的文章: http://blog.csdn.net/hhb200766/article/details/7818142

    在WEB-INF目录下新建weblogic-application.xml文件

    1. <?xml version="1.0" ?>  
    2. <weblogic-application>  
    3.     <prefer-application-packages>  
    4.         <package-name>antlr.*</package-name>  
    5.     </prefer-application-packages>  
    6. </weblogic-application> 

    在weblogic.xml文件中插入一段配置:

    1. <container-descriptor> 
    2.     <prefer-web-inf-classes>true</prefer-web-inf-classes> 
    3. </container-descriptor>

 

针对我自己的这个应用,也是参照上面的解决办法的,具体如下:

    config是我自己的一个web应用

bubuko.com,布布扣

  在WEB-INF目录下新建一个 application.xml 和 weblogic-application.xml文件,这两个文件的内容是一模一样的,估计只需要一个,至于哪一个可以再尝试我这里就把两个文件都保留着,这两个文件的内容如下:

bubuko.com,布布扣
<?xml version="1.0"?> 
<weblogic-application> 
    <prefer-application-packages>
        <package-name>org.mozilla.*</package-name>    
    </prefer-application-packages>
</weblogic-application> 
bubuko.com,布布扣

紧接着在 weblogic.xml文件中修改一个配置,设置为true

bubuko.com,布布扣
<?xml version="1.0" encoding="UTF-8"?>

<wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
    <wls:context-root>/config</wls:context-root>
    <wls:charset-params>
        <wls:input-charset>
            <wls:resource-path>/*</wls:resource-path>
            <wls:java-charset-name>UTF-8</wls:java-charset-name>
        </wls:input-charset>
    </wls:charset-params>
 
    <wls:container-descriptor>
            <!-- yangw change false to true -->
        <wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
    
    </wls:container-descriptor>

    
</wls:weblogic-web-app>
bubuko.com,布布扣

最后重启应用即可.

 

weblogic服务器上类或者方法找不到的解决办法,布布扣,bubuko.com

weblogic服务器上类或者方法找不到的解决办法

标签:des   style   blog   class   code   java   

原文地址:http://www.cnblogs.com/yangw/p/3715762.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!