jboss上的struts2应用

发布于 2024-08-12 05:45:06 字数 4006 浏览 4 评论 0原文

这是在jboss上部署struts应用的延续,但它足够不同我觉得有必要提出一个新问题。

在另一个问题中,我之前使用的是 struts,但现在我使用的是 struts 2。 此处的教程分为 struts 教程和 struts2 教程。

我发现我需要将 JAVA_HOME 设置为指向 jdk6,否则 struts 2 示例将无法工作。因此,在 eclipse 中,我将另一个 JBoss 服务器添加到我的 JBoss 服务器视图中(我正在使用 JBoss 工具)并使其使用 jdk1.6。

我的问题是,这正常吗? struts 2需要jdk6吗?

[编辑] 堆栈跟踪很大,我将其第一部分粘贴在下面:

2009-11-22 05:13:42,625 INFO  [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Parsing configuration file [struts.xml]
2009-11-22 05:13:42,890 DEBUG [com.opensymphony.xwork2.util.LocalizedTextUtil] Added default resource bundle 'org/apache/struts2/struts-messages' to default resource bundles = [org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
2009-11-22 05:13:43,093 DEBUG [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:struts-default namespace: parents:[]}
2009-11-22 05:13:43,203 DEBUG [com.opensymphony.xwork2.validator.DefaultValidatorFactory] Loading validator definitions.
2009-11-22 05:13:43,281 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,281 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,296 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,328 DEBUG [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
2009-11-22 05:13:43,500 ERROR [STDERR] java.lang.Exception: Could not load invoker/war/WEB-INF/classes/org/jboss/invocation/http/servlet/InvokerServlet$GetCredentialAction.class
2009-11-22 05:13:43,500 ERROR [STDERR]  at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:745)
2009-11-22 05:13:43,500 ERROR [STDERR]  at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:148)
2009-11-22 05:13:43,500 ERROR [STDERR]  at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:295)
2009-11-22 05:13:43,500 ERROR [STDERR]  at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:277)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52)
2009-11-22 05:13:43,515 ERROR [STDERR]  at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:200)
2009-11-22 05:13:43,515 ERROR [STDERR]  at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3722)

This is a bit of a continuation of deploy struts app on jboss, but it's different enough that I felt it warranted a new question.

In the other question, I was working with struts, but now I'm working with struts 2.
The tutorials here are broken up into struts tutorials and struts2 tutorials.

What I'm finding is that I need to have JAVA_HOME set to point to a jdk6 or the struts 2 samples won't work. So in eclipse, I added another JBoss Server to my JBoss Server View (I'm using JBoss tools) and made it use jdk1.6.

My question is, is this normal? Does struts 2 require jdk6?

[EDIT]
The stack trace is huge, I'm pasting the first part of it below:

2009-11-22 05:13:42,625 INFO  [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Parsing configuration file [struts.xml]
2009-11-22 05:13:42,890 DEBUG [com.opensymphony.xwork2.util.LocalizedTextUtil] Added default resource bundle 'org/apache/struts2/struts-messages' to default resource bundles = [org/apache/struts2/struts-messages, com/opensymphony/xwork2/xwork-messages]
2009-11-22 05:13:43,093 DEBUG [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:struts-default namespace: parents:[]}
2009-11-22 05:13:43,203 DEBUG [com.opensymphony.xwork2.validator.DefaultValidatorFactory] Loading validator definitions.
2009-11-22 05:13:43,281 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,281 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,296 DEBUG [com.opensymphony.xwork2.interceptor.I18nInterceptor] new I18nInterceptor()
2009-11-22 05:13:43,328 DEBUG [com.opensymphony.xwork2.config.providers.XmlConfigurationProvider] Loaded [BUILDER] {PackageConfig Name:convention-default namespace: parents:[{PackageConfig Name:struts-default namespace: parents:[]}]}
2009-11-22 05:13:43,500 ERROR [STDERR] java.lang.Exception: Could not load invoker/war/WEB-INF/classes/org/jboss/invocation/http/servlet/InvokerServlet$GetCredentialAction.class
2009-11-22 05:13:43,500 ERROR [STDERR]  at com.opensymphony.xwork2.util.finder.ClassFinder.readClassDef(ClassFinder.java:745)
2009-11-22 05:13:43,500 ERROR [STDERR]  at com.opensymphony.xwork2.util.finder.ClassFinder.<init>(ClassFinder.java:148)
2009-11-22 05:13:43,500 ERROR [STDERR]  at org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(PackageBasedActionConfigBuilder.java:295)
2009-11-22 05:13:43,500 ERROR [STDERR]  at org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionConfigs(PackageBasedActionConfigBuilder.java:277)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(ClasspathPackageProvider.java:52)
2009-11-22 05:13:43,515 ERROR [STDERR]  at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:200)
2009-11-22 05:13:43,515 ERROR [STDERR]  at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:360)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:403)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:48)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:108)
2009-11-22 05:13:43,515 ERROR [STDERR]  at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3722)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山川志 2024-08-19 05:45:07

不,Struts 2 不需要 Java 6,只需要 Java 5(甚至可以是 向后移植到 Java 1.4 但这是另一个故事了)。

也就是说,根据您提供的跟踪,约定插件似乎试图与服务器中部署的其他元素混淆,invoker/war/WEB-INF/classes/org/jboss/inspiration/http /servlet/InvokerServlet$GetCredentialAction.class 在您的情况下,它找到了一个它认为是操作的类。这实际上是 Jboss 4.2.3.GA 和约定插件 2.1.6 的一个众所周知的问题。在 这个帖子 中引用 Chris Vogel 面临同样的问题问题(Weblogic):

如果你还没有弄清楚,我会告诉你我学到了什么。
Struts/XWorks 扫描 Action 类并通过扫描目录来完成此操作
它是由类加载器给出的,而不仅仅是通过查看 JAR 文件来给出。这
您在堆栈跟踪中看到的 PackageBasedActionConfigBuilder 使
调用当前线程上下文类的 getResources() 方法
loader,它返回该类的类路径中的目录
装载机。对于 WebLogic,该调用实际上返回基本目录
WebLogic 域的。然后,ClassFinder 类会扫描所有
getResources() 方法返回的目录,对于 WebLogic
包括域的每个目录,并查找 Action 类。如果它
找到一个具有超类的类,它尝试加载该超类并
这就是我们实际看到异常的地方。我想知道JBoss的课程是否
loader 也在做类似的事情。 ClassFinder,如果找不到该类
创建一个异常,然后打印堆栈跟踪,不执行任何其他操作
但有例外。我们将修改 ClassFinder 类以不
打印堆栈跟踪。

AFAIK,有两种解决方案:

  • 部署在 JBoss 5 上,因为它的类加载策略似乎更正统
  • 使用 XWork 2.1.3 版本,该版本应该在调试级别记录异常。

PS:我已经成功地重现了您所描述的行为(使用 JDK 6),我在日志中发现了相同的跟踪,但这似乎并没有阻止应用程序工作(正如我所写,XWork 的开发人员仅更改了日志记录)版本 2.1.3 中的级别)。这也是你所观察到的吗?

No, Struts 2 doesn't require Java 6 but Java 5 only (and can even be backported to Java 1.4 but this is another story).

That said, according to the trace you provided, it seems that the convention plug-in is trying to mess with other elements deployed in the server, invoker/war/WEB-INF/classes/org/jboss/invocation/http/servlet/InvokerServlet$GetCredentialAction.class in your case, it found a class that it thinks is an action. This is actually a well known problems with Jboss 4.2.3.GA and the convention plug-in 2.1.6. Quoting Chris Vogel in this thread that faced the same problem (with Weblogic):

In case you haven't figured it out, I'll tell you what I have learned.
Struts/XWorks scans for Action classes and does this by scanning directories
it is given by the class loader, not just by looking at JAR files. The
PackageBasedActionConfigBuilder that you see in your stack trace makes a
call to the getResources() method of the current thread's context class
loader, which returns back directories in the class path for that class
loader. That call, for WebLogic, actually returns back the base directory
of the WebLogic domain. The ClassFinder class then scans all the
directories returned back from the getResources() method, which for WebLogic
includes every directory of the domain, and looks for Action classes. If it
finds a class that has a super class, it tries to load that super class and
this is where we actually see our exception. I'm wondering if JBoss's class
loader is doing a similar thing. ClassFinder, if it can't find the class
creates an exception and then prints the stack trace and does nothing else
with the exception. We are going to modify the ClassFinder class to not
print the stack trace.

AFAIK, there are two solutions:

  • deploy on JBoss 5 since its classloading policy seems to be more orthodox or
  • use the version 2.1.3 of XWork, the exception should be logged at a debug level with this version.

PS: I've successfully reproduced the behavior you describe (with a JDK 6), I find the same trace in my logs, but this doesn't seem to prevent the application from working (as I wrote, XWork's developer only changed the logging level in version 2.1.3). Is this what you observe too?

錯遇了你 2024-08-19 05:45:07

根据 Struts 2 页面,仅需要 Java 5。我已经有一段时间没有使用 Struts 2 了,但几年前我确实将它与 Tomcat + Java 5 一起使用,并且没有遇到这个问题。当您不使用 Java 6 时会遇到什么异常?

Per the Struts 2 page, only Java 5 is required. I haven't used Struts 2 in a while, but I did use it with Tomcat + Java 5 a few years ago and didn't run into this problem. What exception do you get when you're not using Java 6?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文