struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yasser Zamani <yasserzam...@apache.org>
Subject RE: Java 11 support
Date Wed, 23 Jan 2019 07:17:09 GMT


>-----Original Message-----
>From: Sebastian Götz <s.goetz@inform-technology.de>
>Sent: Thursday, January 17, 2019 4:41 PM
>To: user@struts.apache.org
>Subject: Re: Java 11 support
>
>Hi folks,
>
>it appears that there is some work left in the convention plugin. As I can see from
>my IVY resolve process this plugin drags in asm 5.2. From its sources it looks like it
>supports class version up to 1.8 (class version 52).
>As we compile with JDK 11 already (class version 55) we get a lot of these
>exceptions:
>
>  java.lang.IllegalArgumentException
>     at org.objectweb.asm.ClassReader.<init>(Unknown Source)
>     at org.objectweb.asm.ClassReader.<init>(Unknown Source)
>     at org.objectweb.asm.ClassReader.<init>(Unknown Source)
>     at
>org.apache.struts2.convention.DefaultClassFinder.readClassDef(DefaultClassFind
>er.java:461)
>     at
>org.apache.struts2.convention.DefaultClassFinder.<init>(DefaultClassFinder.java:
>93)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildClassFind
>er(PackageBasedActionConfigBuilder.java:395)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(Pa
>ckageBasedActionConfigBuilder.java:377)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionCo
>nfigs(PackageBasedActionConfigBuilder.java:333)
>     at
>org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(Classpat
>hPackageProvider.java:52)
>     at
>com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(D
>efaultConfiguration.java:206)
>     at
>com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(Con
>figurationManager.java:66)
>     at
>org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:957)
>     at
>org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.j
>ava:463)
>     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496)
>     at
>org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:7
>3)
>     at
>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrep
>areAndExecuteFilter.java:61)
>     at
>eu.inform.servlet.context.URIExcludeFilter.init(URIExcludeFilter.java:37)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig
>.java:270)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig
>.java:251)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.ja
>va:102)
>     at
>org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4491)
>     at
>org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:51
>35)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432
>)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422
>)
>     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>     at
>org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorServ
>ice.java:75)
>     at
>java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorS
>ervice.java:140)
>     at
>org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
>     at
>org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432
>)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422
>)
>     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>     at
>org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorServ
>ice.java:75)
>     at
>java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorS
>ervice.java:140)
>     at
>org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
>     at
>org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:801)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at org.apache.catalina.startup.Catalina.start(Catalina.java:695)
>     at
>java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
>Method)
>     at
>java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodA
>ccessorImpl.java:62)
>     at
>java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
>MethodAccessorImpl.java:43)
>     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
>     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
>
>I tried to exclude asm 5.2 on favor of 7.0 which works from the dependency
>resolving side. But the Struts2 ClassVisitor implementation is tied to ASM 5:
>
>public class InfoBuildingVisitor extends ClassVisitor {
>         private Info info;
>         private ClassFinder classFinder;
>
>         public InfoBuildingVisitor(ClassFinder classFinder) {
>             super(Opcodes.ASM5);
>             this.classFinder = classFinder;
>         }
>...
>}
>
>Therefore this leads to the following problem:
>
>java.lang.UnsupportedOperationException: This feature requires ASM7
>     at
>org.objectweb.asm.ClassVisitor.visitNestMember(ClassVisitor.java:236)
>     at org.objectweb.asm.ClassReader.accept(ClassReader.java:651)
>     at org.objectweb.asm.ClassReader.accept(ClassReader.java:391)
>     at
>org.apache.struts2.convention.DefaultClassFinder.readClassDef(DefaultClassFind
>er.java:462)
>     at
>org.apache.struts2.convention.DefaultClassFinder.<init>(DefaultClassFinder.java:
>93)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildClassFind
>er(PackageBasedActionConfigBuilder.java:395)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.findActions(Pa
>ckageBasedActionConfigBuilder.java:377)
>     at
>org.apache.struts2.convention.PackageBasedActionConfigBuilder.buildActionCo
>nfigs(PackageBasedActionConfigBuilder.java:333)
>     at
>org.apache.struts2.convention.ClasspathPackageProvider.loadPackages(Classpat
>hPackageProvider.java:52)
>     at
>com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(D
>efaultConfiguration.java:206)
>     at
>com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(Con
>figurationManager.java:66)
>     at
>org.apache.struts2.dispatcher.Dispatcher.getContainer(Dispatcher.java:957)
>     at
>org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.j
>ava:463)
>     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:496)
>     at
>org.apache.struts2.dispatcher.InitOperations.initDispatcher(InitOperations.java:7
>3)
>     at
>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrep
>areAndExecuteFilter.java:61)
>     at
>eu.inform.servlet.context.URIExcludeFilter.init(URIExcludeFilter.java:37)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig
>.java:270)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig
>.java:251)
>     at
>org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.ja
>va:102)
>     at
>org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4491)
>     at
>org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:51
>35)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432
>)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422
>)
>     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>     at
>org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorServ
>ice.java:75)
>     at
>java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorS
>ervice.java:140)
>     at
>org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
>     at
>org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432
>)
>     at
>org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422
>)
>     at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>     at
>org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorServ
>ice.java:75)
>     at
>java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorS
>ervice.java:140)
>     at
>org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
>     at
>org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at
>org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:801)
>     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
>     at org.apache.catalina.startup.Catalina.start(Catalina.java:695)
>     at
>java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
>Method)
>     at
>java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodA
>ccessorImpl.java:62)
>     at
>java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Delegating
>MethodAccessorImpl.java:43)
>     at java.base/java.lang.reflect.Method.invoke(Method.java:566)
>     at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
>     at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
>
>Can someone verfiy that and propose a fix?
>


Hi Sebastian,

Thank you very much for your explores share!

Yes you're right. It seems we should upgrade to ASM7 in 2.5.21 also if it passed all tests
as well. And sorry for these troubles above! We missed those because we run our integration
tests in struts showcase app only on JDK8 and only with target java 7 (as you discovered).

Could you please check if any further issue persists with my following solution (beside your
workaround for drop-in ASM7 dependency)? I think "This feature requires ASM7" will vanished
with it but I'm not comprehensively sure if any further issue arises after. If so, it would
be nice to fix them in 2.5.21 as well (beside asm.version=7.0).

The solution (with thanks to Struts awesome design) :) :
1. Copy org.apache.struts2.convention.DefaultClassFinder and paste to your.app.target.package.ASM7DefaultClassFinder.
2. Replace all Opcodes.ASM5 with Opcodes.ASM7 in your.app.target.package.ASM7DefaultClassFinder.
3. Define the new class your.app.target.package.ASM7ClassFinderFactory as below:
import com.opensymphony.xwork2.util.finder.ClassFinder;
import com.opensymphony.xwork2.util.finder.ClassFinderFactory;
import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
import com.opensymphony.xwork2.util.finder.Test; 
public class ASM7ClassFinderFactory implements ClassFinderFactory {
    public ClassFinder buildClassFinder(ClassLoaderInterface classLoaderInterface, Collection
urls, boolean extractBaseInterfaces, Set protocols, Test classNameFilter) {
        return new ASM7DefaultClassFinder(classLoaderInterface, urls, extractBaseInterfaces,
protocols, classNameFilter);
    }
}
4. Register it in your struts.xml as below:
<bean type="com.opensymphony.xwork2.util.finder.ClassFinderFactory" class="your.app.target.package.ASM7ClassFinderFactory"
scope="singleton"/>

Thanks in advance!

Kind Regards.
Mime
View raw message