tataByeBye
tataByeBye

Reputation: 3

struts-layout1.4 throwing no class def found for messageresource.java ,when using with struts2

I was using struts-layout,struts-taglib1.3.8.jar, and struts2.application was working fine. But, as struts2 already has taglibs, so I removed struts-taglib1.3.8.jar and upgraded struts-layout from 1.2 to 1.4 (which says is compatible with struts2). I started getting below exception where I used layout policy.

I decompiled the layout jar. It contains a class LayoutUtils.java which makes a call

 protected static MessageResources messages = MessageResources.getMessageResources("org.apache.struts.taglib.html.LocalStrings");

which throws the below exception.

Caused by: java.lang.NoClassDefFoundError: org/apache/struts/util/MessageResources at fr.improve.struts.taglib.layout.util.LayoutUtils.<clinit>(LayoutUtils.java:48) at fr.improve.struts.taglib.layout.PolicyTag.doStartTag(PolicyTag.java:25) at jsp_servlet._common.__appmenu._jspService(__appmenu.java:269) at weblogic.servlet.jsp.JspBase.service(JspBase.java:34) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.ServletStubImpl.onAddToMapException(ServletStubImpl.java:416) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:326) at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:96) at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56) at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:527) at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:447) at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:163) at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:184) at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:80) ... 95 more Caused by: java.lang.ClassNotFoundException: org.apache.struts.util.MessageResources at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:280) at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:253) at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:177) at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:37) ... 113 more

Upvotes: 0

Views: 597

Answers (2)

cozy
cozy

Reputation: 36

The installation notes did not mention any compatibility with Struts 2.

Compatibility

  • Struts-Layout 1.0 works with Struts 1.0 and 1.1. However, note that due to an inheritage change between Struts 1.0 and Struts 1.1, Struts-Layout must be recompiled to work with struts 1.0.
  • Struts-Layout 1.1 works with Struts 1.1 and 1.2.
  • Struts-Layout 1.2, 1.3 and 1.4 works with Struts 1.2 and 1.3. It can also work with Struts 1.1 if you use the special compatibility jar.

https://web.archive.org/web/20111227074645/http://struts.improve-technologies.com/install.html

This library is not available anymore, but if somebody still has the JAR file for Struts-layout 1.4 that could share, I would be appreciated.

Upvotes: 0

Dave Newton
Dave Newton

Reputation: 160271

I don't see where it says it's compatible with Struts 2.

In any case, on the off-chance it actually is, it still depends on Struts 1 classes, e.g.,

<dependency>
  <groupId>struts</groupId>
  <artifactId>struts</artifactId>
  <version>1.2.9</version>
</dependency>

At the very least you'd need to include the Struts 1 core library.

Here's the thing: Struts 2 looks up its message resources in a very different way than Struts 1, exposes values to the view layer in a different way (although they're still accessible via JSP EL), and so on.

It's quite possible I completely missed the Struts 2 compatibility part, though.

Upvotes: 0

Related Questions