Problem with dependencies in ResourceConfig on Jersey - java

I have a Jersey / Spring project (Project A : com.project.a) on Eclipse that depends on another (Project B : com.project.b).
Eclipse does not show any error on the projects until building and running the application on a local Tomcat server.
It throws this error:
SEVERE: StandardWrapper.Throwable
MultiException stack 1 of 1
java.lang.NoClassDefFoundError: com/project/b/SomeClassToRegister
at com.project.a.CustomApplication.<init>(CustomApplication.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1129)
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1009)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:905)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:997)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:989)
at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:340)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:336)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1228)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5449)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5747)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.project.b.SomeClassToRegister
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)
... 28 more
Jul 09, 2019 5:52:13 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet [com.project.a.CustomApplication] in web application [/someApplication] threw load() exception
java.lang.ClassNotFoundException: com.project.b.SomeClassToRegister
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1955)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1798)
at com.project.a.CustomApplication.<init>(CustomApplication.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1129)
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1009)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:905)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:997)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:989)
at org.glassfish.jersey.server.ApplicationHandler.createApplication(ApplicationHandler.java:340)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:319)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:336)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
at javax.servlet.GenericServlet.init(GenericServlet.java:158)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1228)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1066)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5449)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5747)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1707)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1697)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
CustomApplication extends org.glassfish.jersey.server.ResourceConfig and is trying to register that class as follows:
public class CustomApplication extends ResourceConfig {
public CustomApplication() {
// Specify packages of java code.
packages("com.project.a");
packages("com.project.b"); //>>> Line 30
register(com.project.b.SomeClassToRegister.class); //>>> Line 31
}
}
Interestingly, Line 30 calls the main package of com.project.b with no problem, but the code crashes on line 31. com.project.b.SomeClassToRegister exists on the dependency com.project.b .
After the error is shown, the welcome-file jsp page for the server is shown normally, but every endpoint throws the same NoClassDefFoundError error when accessed.
The build path of Project A has Project B as a listed dependency and Project B is also listed as part of the Web Deployment Assembly packaging of Project A.
I am currently running it on a local Tomcat server with the following resource configuration. I have tried to remove the duplicate appearance of Project B with the same result.
Am I missing anything about linking the two projects together that might be the cause of the error?

After fiddling a lot with the configurations of both projects, what worked for me was :
Go to Properties of Project A
Java Build Path
Source
Add folder src/main/java of Project B
Apply and close
Clean projects and run

Related

how to resolve "java.util.zip.ZipException:duplicate entry: org/apache/xmlbeans/xml/stream/Location.class" issue while hosting springboot in tomcat 10

I am trying to host spring boot rest api in Apache Tomcat 10, but it is not getting hosted, I had placed my spring boot application in webapps-javaee folder, as tomcat 10 default support jakartaee
When I checked logs I am getting this err
23-Mar-2022 19:48:49.103 SEVERE [Catalina-utility-2] org.apache.tomcat.jakartaee.Migration.migrateArchiveStreaming Failed to migrate archive [webService-0.0.1-SNAPSHOT-exec.war]. Using the "-zipInMemory" option may help.
java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class
at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
at org.apache.tomcat.jakartaee.Migration.migrateArchiveStreaming(Migration.java:228)
at org.apache.tomcat.jakartaee.Migration.migrateStream(Migration.java:289)
at org.apache.tomcat.jakartaee.Migration.migrateArchiveStreaming(Migration.java:229)
at org.apache.tomcat.jakartaee.Migration.migrateStream(Migration.java:289)
at org.apache.tomcat.jakartaee.Migration.migrateFile(Migration.java:200)
at org.apache.tomcat.jakartaee.Migration.execute(Migration.java:166)
at org.apache.catalina.startup.HostConfig.migrateLegacyApp(HostConfig.java:1298)
at org.apache.catalina.startup.HostConfig$MigrateApp.run(HostConfig.java:2048)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.startup.HostConfig.migrateLegacyApps(HostConfig.java:1260)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:471)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1757)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:316)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1162)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1365)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1369)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1347)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
my Spring boot application is working fine in tomcat 9, but for tomcat 10 it is giving this error
You have to convert the war file manually, go to https://tomcat.apache.org/download-migration.cgi and download the migration tool, then run the command java -jar jakartaee-migration-1.0.0-shaded.jar -zipInMemory oldFile.war newFile.war, the -zipInMemory option will take care of duplicated files in your war file, then you can put the new war file directly in the webapps folder.

Embedded Tomcat failed to scan

I work on Eclipse with an embedded Tomcat (8.0.24). I ran mvn clean package install and got a build success.
However, when I start tomcat by running a main method in Eclipse (as it's an embedded Tomcat), I got lots of error like :
mai 11, 2018 3:26:20 PM org.apache.tomcat.util.scan.StandardJarScanner processURLs
WARNING: Failed to scan [file:/C:/Users/username/.m2/repository/com/sun/xml/ws/jaxws-rt/2.1.7/saaj-impl.jar] from classloader hierarchy
java.io.FileNotFoundException: C:\Users\username\.m2\repository\com\sun\xml\ws\jaxws-rt\2.1.7\saaj-impl.jar (The system cannot find the file specified)
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.zip.ZipFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at java.util.jar.JarFile.<init>(Unknown Source)
at org.apache.tomcat.util.compat.JreCompat.jarFileNewInstance(JreCompat.java:188)
at org.apache.tomcat.util.scan.JarFileUrlJar.<init>(JarFileUrlJar.java:65)
at org.apache.tomcat.util.scan.JarFactory.newInstance(JarFactory.java:49)
at org.apache.tomcat.util.scan.StandardJarScanner.process(StandardJarScanner.java:374)
at org.apache.tomcat.util.scan.StandardJarScanner.processURLs(StandardJarScanner.java:309)
at org.apache.tomcat.util.scan.StandardJarScanner.doScanClassPath(StandardJarScanner.java:266)
at org.apache.tomcat.util.scan.StandardJarScanner.scan(StandardJarScanner.java:229)
at org.apache.catalina.startup.ContextConfig.processJarsForWebFragments(ContextConfig.java:1888)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1116)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:765)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:94)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5138)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1421)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1411)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I listed some of the concerned .jar :
com\sun\xml\bind\jaxb-xjc\2.1.7\jsr173_1.0_api.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\activation.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\jaxb-impl.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\jaxb-api.jar
com\sun\xml\bind\jaxb-xjc\2.1.7\activation.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jaxb1-impl.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jsr173_1.0_api.jar
com\sun\xml\bind\jaxb-impl\2.1.7\activation.jar
com\sun\xml\bind\jaxb-impl\2.1.7\jaxb-api.jar
com\sun\xml\messaging\saaj\saaj-impl\1.3.3\activation.jar
com\sun\xml\messaging\saaj\saaj-impl\1.3.3\saaj-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\stax-utils.jar
com\sun\xml\ws\jaxws-rt\2.1.7\streambuffer.jar
com\sun\xml\ws\jaxws-rt\2.1.7\stax-ex.jar
com\sun\xml\ws\jaxws-rt\2.1.7\activation.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxb-impl.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxb-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\resolver.jar
com\sun\xml\ws\jaxws-rt\2.1.7\woodstox.jar
com\sun\xml\ws\jaxws-rt\2.1.7\sjsxp.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr173_api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\saaj-impl.jar
com\sun\xml\ws\jaxws-rt\2.1.7\saaj-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr250-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jsr181-api.jar
com\sun\xml\ws\jaxws-rt\2.1.7\jaxws-api.jar
javax\xml\soap\saaj-api\1.3\servlet.jar
javax\xml\soap\saaj-api\1.3\jax-qname.jar
javax\xml\soap\saaj-api\1.3\activation.jar
javax\xml\soap\saaj-api\1.3\jaxp-api.jar
I already deleted the content of repository in .m2 and eclipse->project->maven->update project->update project (and force update of snapshot/release).
I checked in the indicated locations and indeed those .jar don't exist. I am a maven's beginner so maybe my error is stupid...

Encountered exception javax.management.RuntimeOperationsException: Exception invoking method check

I have been getting a series of error messages when trying to deploy a web application to an instance of tomcat 7.0.35 server installed on my computer. The application is developed in jsp using eclipse.
The first error message I received was:
FAIL - Encountered exception javax.management.RuntimeOperationsException: Exception invoking method check
The above error message came after I tried to deploy the application in the tomcat manager application.
I have an xml file named myapp.xml placed in the root folder of the application in the workspace, and its contents are:
<Context path="/myapp" docBase="d:\path\to\myapp"/>
I tried to resolve this error message a number of different ways, with no effect. After some time, an error message started to appear as well.
Finally, every few seconds, the console is refreshing with a large batch of new error messages from its continued retries, and those error messages include the following:
Feb 8, 2013 10:38:19 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor d:\mypath\apache-tomcat-7.0.35\conf\Catalina\localhost\myapp.xml
Feb 8, 2013 10:38:19 PM org.apache.catalina.startup.HostConfig deployDescriptor
SEVERE: Error deploying configuration descriptor d:\mypath\apache-tomcat-7.0.35\conf\Catalina\localhost\myapp.xml
java.io.FileNotFoundException: d:\mypath\apache-tomcat-7.0.35\conf\Catalina\localhost\myapp.xml (Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Feb 8, 2013 10:38:19 PM org.apache.catalina.startup.HostConfig deployDescriptors
SEVERE: Error waiting for multi-thread deployment of context descriptors to complete
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
at java.util.concurrent.FutureTask.get(Unknown Source)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:579)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:475)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1449)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:301)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1374)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1519)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
at org.apache.catalina.startup.HostConfig.addWatchedResources(HostConfig.java:1172)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:706)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1637)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
... 1 more
It seems to be throwing a null pointer error when tomcat looks for myapp.xml within a tomcat folder. But it does not seem to be seeing that myapp.xml is located in my eclipse workspace, at the d:\path\to\myapp url that I gave in the tomcat manager application, as shown above. And it seems like the problem is getting worse as I keep trying new things.
Can anyone show me how to fix all this so that I can deploy my application on tomcat? I have deployed other application on this server using similar methods without problems before this.
I got around this error by uninstalling and then re-installing both eclipse and tomcat.

Struts2 Rest plugin unable to load configuration bean

I am trying out the struts2 Rest plugin, upon adding the jar to my lib folder this error showed up.
Jan 18, 2013 9:16:44 AM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
Unable to load configuration. - bean - jar:file:/C:/Users/John/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/HitPlay/WEB-INF/lib/struts2-rest-plugin-2.3.7.jar!/struts-plugin.xml:36:138
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:483)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:277)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:258)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:382)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:103)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4650)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5306)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Unable to load configuration. - bean - jar:file:/C:/Users/John/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/HitPlay/WEB-INF/lib/struts2-rest-plugin-2.3.7.jar!/struts-plugin.xml:36:138
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:71)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471)
... 16 more
Caused by: Unable to load bean: type:org.apache.struts2.rest.handler.ContentTypeHandler class:org.apache.struts2.rest.handler.JsonLibHandler - bean - jar:file:/C:/Users/John/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/HitPlay/WEB-INF/lib/struts2-rest-plugin-2.3.7.jar!/struts-plugin.xml:36:138
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:68)
... 18 more
Caused by: java.lang.NoClassDefFoundError: net/sf/json/JSONArray
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getDeclaredConstructors(Unknown Source)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:235)
... 21 more
Caused by: java.lang.ClassNotFoundException: net.sf.json.JSONArray
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 25 more
I have no idea why this is happening. any clues?
You're missing required libraries, at least the JSON library. This may be because you're not using Maven or an equivalent.
You can't just drop a plugin library into your app and expect it to work, plugins have their own dependencies.

spring 3.2.0 classnotfoundexception

I get the following error:
java.lang.ClassNotFoundException: org.springframework-web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1062)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
I got these .jar's in my WEB-INF/lib directory
spring-beans-3.2.0.RELEASE.jar
spring-context-3.2.0.RELEASE.jar
spring-core-3.2.0.RELEASE.jar
spring-expression-3.2.0.RELEASE.jar
spring-webmvc-3.2.0.RELEASE.jar
spring-web-3.2.0.RELEASE.jar
What else do i need?
It should be org.springframework.web.servlet.DispatcherServlet without the dash in the package name. Just a typo in your web.xml maybe?
Factors which may cause the exception :
Jars are not added to the WEB-INF/lib directory
DispatcherServlet reference is not configured properly in web.xml
Can you upload the web.xml, project structure and verify the information above?

Categories