首页 > 代码库 > weblogic服务器上类或者方法找不到的解决办法
weblogic服务器上类或者方法找不到的解决办法
下面以eclipse-birt(报表)为例,介绍这种问题出现的原因以及解决之道:
分析比较好的见:http://developer.actuate.com/community/forum/index.php?/topic/9315-exception-javalangnosuchmethoderror/
1>现象:
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)
2>原因:
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.
3>解决:
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>
另外一篇比较好的文章: http://blog.csdn.net/hhb200766/article/details/7818142
在WEB-INF目录下新建weblogic-application.xml文件
- <?xml version="1.0" ?>
- <weblogic-application>
- <prefer-application-packages>
- <package-name>antlr.*</package-name>
- </prefer-application-packages>
- </weblogic-application>
在weblogic.xml文件中插入一段配置:
- <container-descriptor>
- <prefer-web-inf-classes>true</prefer-web-inf-classes>
- </container-descriptor>
针对我自己的这个应用,也是参照上面的解决办法的,具体如下:
config是我自己的一个web应用
在WEB-INF目录下新建一个 application.xml 和 weblogic-application.xml文件,这两个文件的内容是一模一样的,估计只需要一个,至于哪一个可以再尝试我这里就把两个文件都保留着,这两个文件的内容如下:
<?xml version="1.0"?> <weblogic-application> <prefer-application-packages> <package-name>org.mozilla.*</package-name> </prefer-application-packages> </weblogic-application>
紧接着在 weblogic.xml文件中修改一个配置,设置为true
<?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>
最后重启应用即可.
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。