简体   繁体   English

jboss上的struts2应用程序

[英]struts2 application on jboss

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. 这是jboss上部署struts应用程序的延续,但是它与众不同,以至于我认为它值得一个新的问题。

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. 在另一个问题中,我正在使用struts,但是现在我正在使用struts2。 此处的教程分为struts教程和struts2教程。

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. 我发现的是,我需要将JAVA_HOME设置为指向jdk6,否则struts 2示例将无法工作。 So in eclipse, I added another JBoss Server to my JBoss Server View (I'm using JBoss tools) and made it use jdk1.6. 因此,在eclipse中,我向我的JBoss Server视图中添加了另一个JBoss Server(我正在使用JBoss工具),并使其使用jdk1.6。

My question is, is this normal? 我的问题是,这正常吗? Does struts 2 require jdk6? 支撑杆2是否需要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)

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). 不,Struts 2不需要Java 6,而仅需要Java 5(甚至可以反向移植到Java 1.4,但这是另一回事了)。

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. 就是说,根据您提供的跟踪,似乎该约定插件正在尝试与服务器中部署的其他元素( invoker/war/WEB-INF/classes/org/jboss/invocation/http/servlet/InvokerServlet$GetCredentialAction.class您的invoker/war/WEB-INF/classes/org/jboss/invocation/http/servlet/InvokerServlet$GetCredentialAction.class ,它找到了一个它认为是操作的类。 This is actually a well known problems with Jboss 4.2.3.GA and the convention plug-in 2.1.6. 这实际上是Jboss 4.2.3.GA和约定插件2.1.6的一个众所周知的问题。 Quoting Chris Vogel in this thread that faced the same problem (with Weblogic): 在面临相同问题(使用Weblogic)的线程中引用Chris Vogel:

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. Struts / XWorks会扫描Action类,并通过扫描类加载器提供的目录来执行此Action ,而不仅仅是查看JAR文件。 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. 您在堆栈跟踪中看到的PackageBasedActionConfigBuilder调用了当前线程的上下文类加载器的getResources()方法,该方法返回该类加载器的类路径中的目录。 That call, for WebLogic, actually returns back the base directory of the WebLogic domain. 对于WebLogic,该调用实际上返回了WebLogic域的基本目录。 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. 然后, ClassFinder类扫描从getResources()方法返回的所有目录getResources()对于WebLogic,该方法包括域的每个目录),并查找Action类。 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. 我想知道JBoss的类加载器是否在做类似的事情。 ClassFinder , if it can't find the class creates an exception and then prints the stack trace and does nothing else with the exception. ClassFinder ,如果找不到该类,则会创建一个异常,然后打印堆栈跟踪,并且对该异常不执行任何其他操作。 We are going to modify the ClassFinder class to not print the stack trace. 我们将修改ClassFinder类以不打印堆栈跟踪。

AFAIK, there are two solutions: AFAIK,有两种解决方案:

  • deploy on JBoss 5 since its classloading policy seems to be more orthodox or 部署在JBoss 5上,因为它的类加载策略似乎更传统
  • use the version 2.1.3 of XWork, the exception should be logged at a debug level with this version. 如果使用XWork版本2.1.3,则应使用此版本在调试级别记录异常。

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). PS:我已经成功复制了您描述的行为(使用JDK 6),我在日志中发现了相同的踪迹,但这似乎并不能阻止应用程序正常工作(正如我所写的那样,XWork的开发人员仅更改了日志记录)级别2.1.3)。 Is this what you observe too? 这也是您观察到的吗?

Per the Struts 2 page , only Java 5 is required. 在Struts 2页面上 ,仅需要Java 5。 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. 我已经有一段时间没有使用Struts 2了,但是几年前我在Tomcat + Java 5中使用了Struts 2,并且没有遇到这个问题。 What exception do you get when you're not using Java 6? 当您不使用Java 6时会遇到什么异常?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM