java.lang.NoSuchMethodError: org.json.JSONObject.getNames Exception - java

I have included the required JAR downloaded from here: www.java2s.com/Code/Jar/j/Downloadjavajsonjar.htm in the Build Path of the project.
Yet, unable to resolve this error. What else could cause the problem?
My stack trace is shown below:
java.lang.NoSuchMethodError: org.json.JSONObject.getNames(Lorg/json/JSONObject;)[Ljava/lang/String;
at com.comp.cloud.portal.zRPCEngine.zCompRPC(zRPCEngine.java:641)
at com.comp.cloud.portal.zCompManager.CompSubscribe(zCompManager.java:1480)
at com.comp.cloud.portal.zCompManager.AddCompHD(zCompManager.java:310)
at com.comp.cloud.portal.zCompManager.LoadInventory(zCompManager.java:96)
at com.comp.cloud.portal.zCompCloudPortalUI.Login(zCompCloudPortalUI.java:333)
at com.comp.cloud.portal.portlets.Login.ExecuteLogin(Login.java:333)
at com.comp.cloud.portal.portlets.Login$button_login_clicked.buttonClick(Login.java:234)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198)
at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:984)
at com.vaadin.ui.Button.fireClick(Button.java:393)
at com.vaadin.ui.Button$1.click(Button.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:295)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:188)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:93)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:41)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1408)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:237)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)

About java.lang.NoSuchMethodError :
This error is a runTime error which occurs as a result of missing method definition in the classes available in the ClassPath. After the classLoader loads the class, linking phase fails to link the method call as the requested method is not available in the ClassPath classes
This error generally occurs when you compile and test your code in one environment (generally local machine) and you deploy your code in another environment.
We will consider the following example for our use case : java.lang.NoSuchMethodError: org.json.JSONTokener
Why the classes are not available in the ClassPath despite creating a uber jar? :
It’s because classes are loaded at runtime and if loader finds multiple classes with same signature, it loads the first one it encounters. If that class doesn’t have the required method, we will get the NoSuchMethodError.
Gist is that classLoader fails to find the exact class which we want it to load.
How to find which class is getting load?
We can use following code snippet in the main method to find out the class which is getting loaded.
ClassLoader classloader = org.json.JSONTokener.class.getClassLoader();
URL res = classloader.getResource("org/json/JSONTokener.class");
String path = res.getPath();
System.out.println("Core JSONTokener came from " + path)
What to do after finding the path of class from which it is getting loaded?
If you find that the library that is getting loaded is coming from some other path in the machine, you have to make sure that the desired library gets loaded. The best method to do so is to shade your jar and rename the references in your project.
How to shade a jar and rename references in Scala/Java?
In Scala, you can add
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.7")
to ./project/plugins.sbt and then use the sbt commandsbt assembly to generate a fat jar-file.
Now to shade the jar use following code in your sbt:
assemblyShadeRules in assembly := Seq(
ShadeRule.rename(“org.json.**” -> “shadedJson.#1”)
.inLibrary(“org.json” % “json” % “20180813”)
.inAll
)
What this will do is, rename all the references of regex
org.json.** to shadedJson.** in your code as well as in the library that you have included in your dependencies and shade the jar with changes.
Now when you run your program, it will find both the jars in the classPath, but since you have renamed the references in your code and your jar, that will be the one which will be loaded by classLoader and not the other ones.
In Java, you can use maven-jar-plugin and maven-shade-plugin to create a shaded jar in java.
https://examples.javacodegeeks.com/enterprise-java/maven/maven-jar-plugin-example/
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
</plugin>
</plugins>
</build>
now to rename reference in java, you have to use relocation pattern in maven-shade-problem as mentioned in the following link:
http://maven.apache.org/plugins/maven-shade-plugin/examples/class-relocation.html
How to check if jar is shaded or not?
Simple, just explode the jar and search for class name as per your rename. eg in our case you can search for shadedJson
Command to explode :
jar -tf
*redirect the output to a file and search in that file.

May be that you added the jar to your project build path, but you are not bundling it into your war deployed on Tomcat. Edit: You either bundled an older version of the jar or an older version of the jar is visible from your application classpath.

Related

How to use thymeleaf and jsp in same SpringBoot project? [duplicate]

This question already has answers here:
Deploying a JSF webapp results in java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config [duplicate]
(3 answers)
Closed 7 years ago.
When I am run my application after entering the URL, this exception is coming.I am using Eclipse and Tomcat7.0.35. I also added Jstl.jar and jstl1.2.jar
My code is
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:91)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:78)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The error is telling you it cannot find the class because it is not available in your application.
If you are using Maven, make sure you have the dependency for jstl artifact:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
If you are not using it, just make sure you include the JAR in your classpath. See this answer for download links.
Download the following jars and add it to your WEB-INF/lib directory:
jsp-api-2.0.jar
jstl-1.2.jar
By default, Tomcat container doesn’t contain any jstl library. To fix it, declares jstl.jar in your Maven pom.xml file if you are working in Maven project or add it to your application's classpath
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Probably the jstl libraries are missing from your classpath/not accessible by tomcat.
You need to add at least the following jar files in your WEB-INF/lib directory:
jsf-impl.jar
jsf-api.jar
jstl.jar
Add jstl jar to your application classpath.
Just a quick comment: sometimes Maven does not copy the jstl-.jar to the WEB-INF folder even if the pom.xml has the entry for it.
I had to manually copy the JSTL jar to /WEB-INF/lib on the file system. That resolved the problem. The issue may be related to Maven war packaging plugin.
Add JSTL library as dependency to your project (javax.servlet.jsp.jstl.core.Config is a part of this package).
For example, if you were using Gradle, you could write in a build.gradle:
dependencies {
compile 'javax.servlet:jstl:1.2'
}
I had the same problem. Go to Project Properties -> Deployment Assemplbly and add jstl jar

Getting HTTP Status 500 - Servlet execution threw an exception

I Created a Dynamic web project where the input parameters are coming from UI(Index.html) going to servlet.java, but when I am trying to call auth in oAuthBean.java file its giving me an error.
Attached navigation view:
Exception:
Aug 24, 2017 3:18:42 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [clientCredServlet1] in context with path [/Java-Credit-Offers-Example] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
at controller.clientCredServlet.doPost(clientCredServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
It looks like your servlet uses Apache http client (that's where org.apache.http.HttpEntity is coming from), but corresponding dependency jar is not present in resulting deployment, most likely because there is a lack of configuration glue between Maven and Eclipse WTP plugin which deploys to and runs your Tomcat from IDE. That lack appeared because it seems that Maven project has been created outside of Eclipse.
Option 1. Leave things as is and do quickfix (worse)
Try executing under your project root folder:
mvn eclipse:eclipse -Dwtpversion=2.0
and reopen Eclipse workspace then
According to Maven Eclipse plugin documentation when the wtpversion flag is explicitly set, maven generates necessary workspace configuration for WTP plugins (including Tomcat one) in order to let them understand how to obtain Maven dependencies during deployments from Eclipse
Option 2. Rely on built-in IDE integration with Maven (best for long term)
Examine following great answer which, at some approximation, describes why, and how to rely on built-in Eclipse Maven support. This approach eliminates the problem with missing dependencies in IDE deployments as well, but requires more effort to migrate project onto, which however is quite minor while your project is at the beginning stage

Birt Runtime maven artifact issue

I want to use Birt Api library im my project so I included rg.eclipse.birt.runtime 4.5 maven dependency into my project
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.5.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.10.100.v20150529-1857</version>
</dependency>
When I want to execute my report I got below stack trace error caused by "org.eclipse.core.runtime.IExtensionRegistry"'s signer information does not match signer information of other classes in the same package. Previously I used the same library Birt Runtime 4.5 but manually downloaded and attached to my project and the report was generated successfully.
org.eclipse.birt.core.exception.BirtException: error.CannotStartupOSGIPlatform
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:81)
at org.report.birt.service.BirtApi.getReport(BirtApi.java:33)
at org.report.birt.endpoint.BirtEndPoint.handleRequest(BirtEndPoint.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.springframework.ws.server.endpoint.MethodEndpoint.invoke(MethodEndpoint.java:134)
at org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.invokeInternal(DefaultMethodEndpointAdapter.java:291)
at org.springframework.ws.server.endpoint.adapter.AbstractMethodEndpointAdapter.invoke(AbstractMethodEndpointAdapter.java:55)
at org.springframework.ws.server.MessageDispatcher.dispatch(MessageDispatcher.java:236)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:176)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:89)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:61)
at org.springframework.ws.transport.http.MessageDispatcherServlet.doService(MessageDispatcherServlet.java:293)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:929)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:585)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.SecurityException: class "org.eclipse.core.runtime.IExtensionRegistry"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:952)
at java.lang.ClassLoader.preDefineClass(ClassLoader.java:666)
at java.lang.ClassLoader.defineClass(ClassLoader.java:794)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1190)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1190)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.eclipse.birt.core.framework.jar.ServicePlatform.<init>(ServicePlatform.java:46)
at org.eclipse.birt.core.framework.jar.ServiceLauncher.startup(ServiceLauncher.java:46)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:75)
... 35 more
org.eclipse.birt.runtime-4.5.0 available on Maven Central Repository depends on JARs signed with both an old and a new version of Eclipse certificate, but these JARs contains classes from the same package (in this case org.eclipse.core.runtime). When loading classes from both JARs, the JVM throws such SecurityException because of this signature inconsistency.
For instance this can be put into evidence with org.eclipse.equinox.common-3.6.200.v20130402-1505.jar and org.eclipse.equinox.registry-3.6.0.v20150318-1503.jar, both dependencies of org.eclipse.birt.runtime-4.5.0 containing classes in org.eclipse.core.runtime package. Versions available on the Central Maven Repository are signed with different certificates, as shown by jarsigner -verify -verbose -certs xxx.jar:
//org.eclipse.equinox.common-3.6.200.v20130402-1505.jar
[entry was signed on 09/04/13 15:24]
X.509, CN="Eclipse.org Foundation, Inc.", OU=IT, O="Eclipse.org Foundation, Inc.", L=Ottawa, ST=Ontario, C=CA
//org.eclipse.equinox.registry-3.6.0.v20150318-1503.jar
[entry was signed on 18/03/15 18:14]
X.509, CN="Eclipse Foundation, Inc.", OU=IT, O="Eclipse Foundation, Inc.", L=Ottawa, ST=Ontario, C=CA
Hence the SecurityException when trying to load classes from both JARs. You can:
Use version 4.6.0-20160607 with Maven instead
Manually download and attach version 4.5.0 from the official website which is packaged with JARs signed with a recent certificate version
Side note: Problem can be reproduced by creating a Maven project with the following dependency:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.5.0</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</exclusion>
</exclusions>
</dependency>
And running a code which will load classes contained in JARs signed with different certificates such as the one cited above, for example:
Class.forName("org.eclipse.core.runtime.Assert").getResource("Assert.class");
Class.forName("org.eclipse.core.runtime.IExtensionRegistry").getResource("IExtensionRegistry.class");
will result in a similar SecurityException when using version 4.5.0 but not with version 4.6.0-20160607.
Another note: There is a similar issue with version 4.2.0 M7.
I have got 2 solutions. Please check
First:
Use dependency version 4.5.0a instead of 4.5
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.5.0a</version>
</dependency>
Resource Link: https://communities.opentext.com/forums/discussion/comment/217265/#Comment_217265
Second:
Full tutorial is given by step by step here:
http://wiki.eclipse.org/BirtPOJO_Viewer_WebSphere_Deployment
I also faced the same issue for "org.eclipse.core.runtime.IExtensionRegistry" and in my maven project that class was coming from "registry-3.5.400-v20140428-1507.jar".
Mention jar was supposed to load from "org.eclipse.birt.runtime-4.4.1.jar" but was loaded from other maven dependency which was signed by different certificates.
So to resolve this issue I followed below steps.
Search the jar from which "IExtensionRegistry" was loaded and it was from "registry-3.5.400-v20140428-1507.jar" in my case.
As Maven will always load the JAR on class path based on first come first serve basis.
So if you are using maven project then insure that jar must be loaded on class path from it's parent jar "org.eclipse.birt.runtime-4.4.1.jar" so that there will be no certificate miss match issue.
If it is still loading from other parent dependency then add "registry-3.5.400-v20140428-1507.jar" dependency into your pom.xml from maven "https://mvnrepository.com/artifact/org.eclipse.equinox/registry" with correct version and also make sure to put this dependency before that other parent dependency from which it was loading and creating this issue.

org.springframework.web.context.ContextLoaderListener classnotfoundexception

I get the below error when I run my Spring project..I followed multiple SO links and implemented everything but still I have the same problem.
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
I have attached my project Maven depedencies, deployment assembly and wtpwebapps lib folder to show all the dependencies..
Not sure what else Im missing.
Stack
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4153)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4709)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
You should have this in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
Also you can try:
Right click on your project
"Propeties"
Deployment Assembly
Add
Java Build Path Entries
Maven Dependencies (Selected them all)
Finish
Your project setup shows there is jar file missing or your are pointing to missing jar file in your project build path.
Right click on your project ==> Go to Build Path ==> In Libraries tab..
You can see the jar files missed with red color cross mark delete them (if you need them add those missing jars in your path)
And re-build the project.

java.lang.NoClassDefFoundError: org/springframework/web/servlet/HttpServletBean : org/springframework/context/EnvironmentAware

I am new to this forum. I am trying to make an application using spring 3.2.6 and tomcat 7.0. I have added all the necessary jars in the WEB-INF/lib folder. The DispatcherServlet and ContextLoaderListener is properly configured in the web.xml. The same application was working fine with spring 3.0.2 version. Now when I am trying to open the jsp page, it is giving me below error:
HTTP Status 500 - org/springframework/web/servlet/HttpServletBean :
org/springframework/context/EnvironmentAware
type Exception report
message org/springframework/web/servlet/HttpServletBean :
org/springframework/context/EnvironmentAware
description The server encountered an internal error that prevented it
from fulfilling this request.
exception
java.lang.NoClassDefFoundError:
org/springframework/web/servlet/HttpServletBean :
org/springframework/context/EnvironmentAware
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2895)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1173)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1681)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:491)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:662)
note The full stack trace of the root cause is available in the Apache
Tomcat/7.0.42 logs.
The jar
spring-context-3.2.6.RELEASE
is already added in the classpath. I am able to open the class file also from the Eclipse. But I don't understand why it is giving class not found error at run time. I tried to search it on google but didn't find exact the solution.
Thanks in advance.
If it works for an older version(as you say), What I guess there are some places you have old jar in the path, which mess up the jar dependency
I will suggest you do a full disk search to find out all your spring jar location and clean them up.
BTW: you can try to add jar to tomcat/lib to try also (it is not proper practice, but this can help to find out whether it is path related issue).
The class org.springframework.web.servlet.HttpServletBean is part of spring-webmvc. You will need to add that library to your classpath as well. You can get it here.
EnvironmentAware is located in the spring-context-3.1.1.RELEASE.jar, so you are missing that one.
Also recheck your Maven POM file so that you are not missing any other Spring library, like spring-web, spring-webmvc (you may have these since the DispatcherServlet class if found), spring-orm if you use an ORM like Hibernate, spring-jms if you use JMS, etc.
I had this problem. I solved it by adding the jar:
org.springframework.context-3.1.0.RELEASE.jar
to both the build path and as a maven dependency (java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet error)
Hope it helps

Categories

Resources