java.lang.NoClassDefFoundError: org/apache/wicket/util/convert/converter/ZeroPaddingIntegerConverter - java

My application was running fine with Wicket 7.6.0. But now I am facing below exception after migration from Wicket 7.6 to 8.5.
Caused by: java.lang.NoClassDefFoundError: org/apache/wicket/util/convert/converter/ZeroPaddingIntegerConverter
at org.apache.wicket.extensions.yui.calendar.DateTimeField.(DateTimeField.java:119)
Caused by: java.lang.ClassNotFoundException: org.apache.wicket.util.convert.converter.ZeroPaddingIntegerConverter
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
... 77 more
In my code nowhere used this class "ZeroPaddingIntegerConverter" but still getting this error for this class.
:
ZeroPaddingIntegerConverter class has been deprecated in Wicket 8.x version.

wicket-datetime module has been removed with Wicket 8 and moved to WicketStuff. In your code you are probably mixing the old wicket-datetime module (7.6.0) with Wicket 8.5. Just remove the old module and replace it with WicketStuff dependency:
<dependency>
<groupId>org.wicketstuff</groupId>
<artifactId>wicket-datetime</artifactId>
<version>8.5.0</version>
</dependency>

Related

Hibernate XML configuration on OpenJ9 (JDK14)

I'm trying trying to load Hibernate XML configuration on OpenJ9 (JDK14) but since JAXB are not longer part of the JDK I get this error:
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandler
I tried to follow some of the answers on: How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException in Java 9 but it seems like none are working on OpenJ9 and when trying to include any of the dependencies I'm getting the following error:
Caused by: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
- with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:278)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:421)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:721)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:662)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:122)
... 5 more
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:788)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1081)
at javax.xml.bind.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:122)
at javax.xml.bind.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:155)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:276)
... 9 more
I found the missing part in the puzzle, the javax.xml.bind.JAXBContextFactory needs to be set in the system property.
So the solution is adding JAXB to list of dependencies:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>2.7.3</version>
</dependency>
And then in the code (or when the JVM starts) set the system property to point to the right factory.
System.setProperty("javax.xml.bind.JAXBContextFactory", "org.eclipse.persistence.jaxb.JAXBContextFactory");
Last since I'm running in a custom classloader the ContextClassLoader has to be set otherwise the factory can't be found.
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());

Spring boot : Unable to load cache item: javax/servlet/Filter

I have a spring boot project and getting some error related to javax servlet filter.
Is it some kind of version compatibility or I am missing something in pom file.
Following is the log from the console and the pom file.
I have been searching all over, couldn't find anything.
Exception in thread "main" java.lang.IllegalStateException: Cannot load configuration class: org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerSecurityConfiguration
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:403)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:249)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:281)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:125)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:687)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:525)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:303)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.abc.application.Application.main(Application.java:15)
Caused by: java.lang.IllegalStateException: Unable to load cache item
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:79)
at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:116)
at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:291)
at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:337)
at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:138)
at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:110)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:393)
... 11 more
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getDeclaredConstructors(Class.java:2020)
at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:566)
at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanFactoryAwareGeneratorStrategy.generate(ConfigurationClassEnhancer.java:252)
at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:329)
at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:492)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:93)
at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:91)
at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
... 19 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 33 more
For me problem were in pom file (in spring boot 2 project),
when I used a parent spring boot in version 2.1.9 which under the hood uses spring-core in version 5.1.10.RELEASE
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
I had dependency:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
removing it resolved problem
I was getting the similar error in my Gradle project(might be a problem with Maven too) when I was trying to upgrade my Spring Boot version to latest one.
A quick gradle clean solved that problem for me.
Usually, this Filter class can be found in embedded tomcat jar.
So please make sure that your application (jar) contains this file:
Open up the Jar file of the compiled spring boot application and check whether the jar named like tomcat-embed-core resides in the BOOT-INF\lib folder.
This answer is valid as long as you're running tomcat of course + use JAR artifact for spring boot application (for WAR the folder is different, probably WEB-INF/lib although I've never worked with WARs of Spring Boot application so I might be wrong here)

IntelliJ & Jersey: java.lang.NoClassDefFoundError

I just tried to use the jersey-server api in a java application.
It's a maven project and I already added the mysql-connector api which works fine.
When the application which is compressed into a jar (Intellij-Artifacts) runs, it throws the exception:
Exception in thread "main" java.lang.NoClassDefFoundError:
com/sun/jersey/api/container/httpserver/HttpServerFactory
at de.myleak.server.Server.init(Server.java:19)
at de.myleak.core.Core.init(Core.java:87)
at de.myleak.core.Core.<init>(Core.java:51)
at de.myleak.core.Core.main(Core.java:40)
Caused by: java.lang.ClassNotFoundException:
com.sun.jersey.api.container.httpserver.HttpServerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
I added the dependency to the pom.xml
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19.4</version>
</dependency>
I also added the maven dependency in the project structure
screenshot

org.apache.commons.validator.EmailValidator

I am trying to validate the email: hello.world#cir.care
boolean isValidEmail = EmailValidator.getInstance().isValid("hello.world#cir.care")
It throws error when I use commonvalidator 1.14 but its works with 1.5.1
Error StackTrace:
org.apache.axis2.engine.AxisEngine receive null org.apache.axis2.AxisFault
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.NoClassDefFoundError: org/apache/oro/text/perl/Perl5Util
boths the jars are available in server path.
Please suggest me if I miss any thing?
Download and add the following jar in your server path apache-jakarta-oro.jar
Also refer the following link for more options
NoClassDefFoundError problems with help of Apache Commons Validator
If you are using maven add this dependency to the project repository
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>

AbstractCreatorProcessor class not found error

While setting up adopt openjdk 8 with Tomcat 9 with my existing application, I am getting the following error
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/stream/buffer/AbstractCreatorProcessor
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)
at javax.xml.ws.Service.<init>(Service.java:77)
at javax.xml.ws.Service.create(Service.java:707)
at org.springframework.remoting.jaxws.LocalJaxWsServiceFactory.createJaxWsService(LocalJaxWsServiceFactory.java:162)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.prepare(JaxWsPortClientInterceptor.java:357)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.afterPropertiesSet(JaxWsPortClientInterceptor.java:339)
It was working fine with Oracle JDK, is there anything I am missing for openjdk?
For openjdk you need the JAX-WS dependency library streambuffer.jar.
You can download it from here or, if you use Maven:
<!-- https://mvnrepository.com/artifact/com.sun.xml.stream.buffer/streambuffer -->
<dependency>
<groupId>com.sun.xml.stream.buffer</groupId>
<artifactId>streambuffer</artifactId>
<version>1.5.6</version>
</dependency>

Categories

Resources