Wicket 9 & Tomcat 10 Can't Cast jakarta.servlet.Filter - wicket

I'm trying to use the Wicket Project 'QuickStart' with
Netbeans 11, Java 11, Tomcat 10, Wicket 9, and Ubuntu 18.04.
When I install the WAR package and start it, it throws:
20-May-2020 09:23:37.067 GRAVE [] org.apache.catalina.core.StandardContext.filterStart Exception at start [wicket.quickstart]
java.lang.ClassCastException: class org.apache.wicket.protocol.http.WicketFilter cannot be cast to class jakarta.servlet.Filter (org.apache.wicket.protocol.http.WicketFilter is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader)
Has anyone seen this issue before and if so, what can I do to resolve this?

The issue is that Tomcat 10 uses jakarta.** packages (Jakarta EE 9) while Wicket 9.x is still based on javax.** packages (Java EE 8).
The solutions are:
Use Tomcat 9.x
Use https://github.com/apache/tomcat-jakartaee-migration to migrate the Wicket application (the .war file) from javax to jakarta
Deploy the javax.** based application into $TOMCAT10_HOME/webapps-javaee/ folder. It will be automatically migrated to jakarta.** by Tomcat.

Don't use Tomcat 10 yet, it works with the new jakarta packages.
Switch to version 9 instead.

To make wicket 9 work with with jakarta, e.g. if using tomcat 10 or spring boot 3, you have to convert some jars. There is the tool jakartaee-migration which does this for a given jar. So apply it at least to these 4 jars and create new ones - I used -jakarta as appendix:
wicket-core -> wicket-core-jakarta
wicket-util -> wicket-util-jakarta
wicket-request -> wicket-request-jakarta
commons-fileupload -> commons-fileupload
Also create proper pom files put all together into your local/shared repository.
To use it, add the new dependencies and exclude the old ones where necessary. Run mvn dependency:tree until nothing bogus gets picked up.
Congrats - you now have wicket 9 for jakarta.

Related

Eclipse classnotfoundexception with imported jar files

I've just plainly imported the jar files and this error has appeared. I've tried multiple ways online but couldn't solve it.
This is the classpath that i've imported.
In JDK 9, the module java.corba which contains the interface org.omg.CORBA.portable.IDLEntity is not resolved by default and has to be manually added:
Add the module java.corba to the Explicitly included modules as described in this answer for java.xml.bind or use a Java 8 JRE/JDK.
See blog post Prepare for JDK 9 by Yolande Poirier (emphasis by me):
Six Java EE libraries in JDK are no longer shared by default in JDK 9.
Those Java EE deprecated APIs are java.corba, java.transaction,
java.activation, java.xml.bind, java.xml.ws, java.xml.ws.annotation.
They have been deprecated in JDK 9 and will be removed in a future
release. They are disabled by default in JDK 9. Their packages will
not compile in Java 9 and give an error message. The documentation
gives you migration options to enable those libraries in JDK 9. This
should be a temporary solution because they are scheduled to be
removed in a future release.

NoSuchMethodError: org.eclipse.jetty.util.MultiMap.add

I loaded my Spring/Maven project in Eclipse (Spring Tools Suite variant), installed Run Jetty Run, and clicked Run Jetty.
PROBLEM: Jetty does not start correctly:
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
Running Jetty 9.0.0.M3
ParentLoaderPriority enabled
Enable config class:runjettyrun.webapp.RJRWebInfConfiguration
Enable config class:org.eclipse.jetty.webapp.WebXmlConfiguration
Enable config class:runjettyrun.webapp.RJRMetaInfoConfiguration
Enable config class:org.eclipse.jetty.webapp.FragmentConfiguration
Enable config class:runjettyrun.annotation.RJRAnnotationConfiguration
Enable config class:org.eclipse.jetty.webapp.JettyWebXmlConfiguration
Enable config class:org.eclipse.jetty.webapp.TagLibConfiguration
ProjectClassLoader: entry=/home/nico/src/nemaki/core/target/classes
ProjectClassLoader: entry=/home/nico/.m2/repository/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
[... many other JAR libraries, none being Jetty ...]
ProjectClassLoader: entry=/home/nico/.m2/repository/jp/aegif/nemakiware/nemakiware-common/2.3.10/nemakiware-common-2.3.10.jar
Excluded entry=/home/nico/src/nemaki/core/target/test-classes
2016-09-30 17:17:09.780:INFO:oejs.Server:main: jetty-9.0.0.M3
2016-09-30 17:17:12.121:WARN:oejuc.AbstractLifeCycle:main: FAILED o.e.j.w.WebAppContext#694e1548{/core,[file:/home/nico/src/nemaki/core/WebContent/],STARTING}: java.lang.NoSuchMethodError: org.eclipse.jetty.util.MultiMap.add(Ljava/lang/Object;Ljava/lang/Object;)V
java.lang.NoSuchMethodError: org.eclipse.jetty.util.MultiMap.add(Ljava/lang/Object;Ljava/lang/Object;)V
at org.eclipse.jetty.annotations.ClassInheritanceHandler.handle(ClassInheritanceHandler.java:56)
at org.eclipse.jetty.annotations.AnnotationParser$MyClassVisitor.visit(AnnotationParser.java:398)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
QUESTION: How can I fix it?
You are running an unstable version of Jetty.
Version 9.0.0.M3 is not a stable release (that's an experimental milestone release, a candidate for release, something to help integrators start to evolve their code for the eventual release).
Use a stable release, such as 9.3.12.v20160915 and you'll have a much better experience.
In 9.3.12.v20160915 the MultiMap class can be found in jetty-util-9.3.12.v20160915.jar
Also note, Jetty 9 is servlet 3.1, not 3.0.1 (seen in your output)
As explained by Joakim, 9.0.0.M3 is an old version of Jetty.
Fortunately, Run Jetty Run has been updated a few weeks ago.
Here is how to use the latest Run Jetty Run:
Uninstall from Eclipse any existing version of Run Jetty Run
Add this update site: http://xzer.github.io/run-jetty-run-updatesite/nightly/
Install from it the required component and the optional component 9.3.6
You now have Run Jetty Run using Jetty 9.3.6, which is a year old already but does not trigger the error above. Be sure to select it in Run configurations.

Grails 3 in Tomcat 6

I am trying to deploy my grails app version 3 on a Tomcat 6 container and I am facing the following error when tomcat is trying to deploy the app:
Jan 05, 2016 5:24:44 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\murruer\DEV\apache-tomcat-6.0.37\webapps\grailstomcat-0.1\WEB-INF\lib\tomcat-embed-core-8.0.28.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Is it possible to deploy a Grails 3 application into Tomcat 6??
Thank your.
Best Regards.
If you read the official Grails Doc you can see this:
Note that by default Grails will include an embeddable version of Tomcat inside the WAR file, this can cause problems if you deploy to a different version of Tomcat. If you don't intend to use the embedded container then you should change the scope of the Tomcat dependencies to provided prior to deploying to your production container in build.gradle:
provided "org.springframework.boot:spring-boot-starter-tomcat"
--Edit--
Another problem deploying a Grails 3x war into a Tomcat 6 server is that it's not suported.
The official documentatiotion says:
Grails runs on any container that supports Servlet 3.0 and above and is known to work on the following specific container products:
Tomcat 7
GlassFish 3 or above
Resin 4 or above
JBoss 6 or above
Jetty 8 or above
Oracle Weblogic 12c or above
IBM WebSphere 8.0 or above

org/eclipse/e4/ui/model/application/ui/MUIElement Class Not Found , Java Eclipse Juno

I am doing a CIMTool project, for a handle of WorkbenchWindow
Code Snippet
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
//(both these Classes are present in Libraries)
IWorkbenchWindow window=PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Issues
Following Error is slapped
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/e4/ui/model/application/ui/MUIElement
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:90)
Environment
Eclipse : Eclipse Java EE IDE for Web Developers, Version: Juno Service Release 2
OS : MS Windows 7 Professional, X86
Java Version : java version "1.7.0_25"
Questions
I tried searching for org/eclipse/e4/ui/model/*, I could not find in
Archives. Where I can find ?
Is there any otherway to get IWorkbenchWindow Instance ? (want to
avoid this issue)
This problem I found that, doesnt appear in Java Indigo. But my project has to be developed in Eclipse , so I cant migrate.
thanks
I also was confronted with this error when executing code from within a project that was created as "SWT/JFace Java Project" using Eclipse Kepler (displaying a ListSelectionDialog).
The main problem is that the project set-up misses a JAR file that contains the MUIElement class. You can easily fix the project set-up by editing the build-path, adding the external jar which has a name similar to this one:
org.eclipse.e4.ui.model.workbench_1.0.1.v20131118-1956.jar.
You find that jar in the plugins directory of your Eclipse installation.

UnsupportedClassVersionError deploying EJB "HelloWord" in Glasshfish 3

I try to deploy a simple "Hello Word" in my local server GlasshFish 3, but at the deploy the console print this message
[#|2013-01-15T15:00:02.458+0100|SEVERE|glassfish3.1.2|
javax.enterprise.system.tools.admin.org.Exception while deploying the app
[HelloWorldEJB] :UnsupportedClassVersionError: Class ejb_other.PlaceAuctionItemBean
as unsupported major or minor version numbers, which are greater than those found
in the Java Runtime Environment version 1.6.0_27|#]
My JAVA_HOME has java version 1.6.0_27 (it refers to _C:\Program Files\Java\jdk1.6.0_27_), my Eclipse (indigo) project refers to java 1.6.0_27.
I think (i don't know how to verify) that GlasshFish refers to JAVA_HOME.
In my PC (Windows 7) I found 2 directory having java.exe:
C:\Windows\SysWOW64>java -version -->>java version "1.6.0_29"
C:\Windows\System32>java -version -->>java version "1.6.0_27"
I found more discussions about this exception (f.e. this or this ), but I need of something more specific for Eclipse/Glasshfish, because I can't to solve. I see that the JVM is the same for compilation and execution.
Post Scriptim
I add the screenshot about the places where I declare JVM: it's always 1.6.
one:
two:
three:
Where can I see that I compile with java 7 or it runs with another JVM?
ejb_other.PlaceAuctionItemBean was obviously compiled for Java 7 which won't work if you run it in a Java 6 JVM.
Found solution
There's another place where setting the compiler's options:
how do I get eclipse to use a different compiler version for Java?