I would like to profile my Spring Web Application that is running on Tomcat and Eclipse. I added VisualVM to the Eclipse and followed below steps to run the application for profiling.
Right click on the application name >
Run As >
Run Configuration >
Java Application >
'Selected Project' >
Set 'org.apache.catalina.starup.Boostrap' as a value for Main class,
also selected VisualVM as the Launcher > clicked on Run button.
The VisualVM starts but shows following message:
"Cannot open requested application"
Under local I can see VisualVM, Eclipse and Tomcat.
Following exception will be thrown and shown on console as well:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/juli/logging/LogFactory
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:59)
Caused by: java.lang.ClassNotFoundException: org.apache.juli.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
I reckon the issue is because of wrong server selected. Maybe I should choose Tomcat but not sure how.
Probably an issue with an incomplete classpath when the VisualVM plugin launches Tomcat. You could try to correct the classpath of the start configuration which you created (e.g. try to add bin/tomcat-juli.jar from your tomcat installation) but I doubt this will work easily.
You can try the following:
start your Tomcat, e.g. from Eclipse
then manually start VisualVM: It is actually part of the JDK and located in <JDK dir>/bin/jvisualvm(.exe)
in the application list you should see the Tomcat process and then you can open it with a double click.
Try using Java Mission Control by running jmc. It is included in recent versions of the JDK.
See the getting started doc at http://docs.oracle.com/javacomponents/jmc-5-5/jmc-user-guide/index.html
Run your application, then open the jmc window and connect to the Tomcat process.
This is caused when a class file that your code depends on is not found at run time. This is purely an issue with the class path. Either the class is not exists in the class path or you have a different version of JAR file in the class path. The exception will go away if the class path is corrected.
Related
I have built a Java 1.8 application under Maven in Eclipse that allows me to generate BIRT reports in a programmatic way without the need for the UI. Within Eclipse everything works fine. If I compile the code into a JAR file and try to run it however I run into problems with java.lang.NoClassDefFoundErrors. Clearly I have a missing dependancy but I don't know how to resolve the problem.
The error is
java -cp target/* com.resonancex.scheduler.Scheduler
Establishing conection...
Connected
Got products to report
ProductId=1 ProductType=BREN Isin=XS1939207996 Template=BREN_MU
* birtEngine EngineConfig: org.eclipse.birt.report.engine.api.EngineConfig.emitterConfigs={html=org.eclipse.birt.report.engine.api.HTMLEmitterConfig#71bbf57e};
* Birt Engine Startring ....
Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/core/runtime/CoreException
at org.eclipse.birt.core.framework.Platform.createPlatformLauncher(Platform.java:115)
at org.eclipse.birt.core.framework.Platform.startup(Platform.java:74)
at com.resonancex.scheduler.BirtEngine.start(BirtEngine.java:33)
at com.resonancex.scheduler.BirtEngine.getBirtEngine(BirtEngine.java:47)
at com.resonancex.scheduler.BIRTReportGenerator.setReportCustom(BIRTReportGenerator.java:67)
at com.resonancex.scheduler.Scheduler.generateAllReports(Scheduler.java:68)
at com.resonancex.scheduler.Scheduler.main(Scheduler.java:79)
Caused by: java.lang.ClassNotFoundException: org.eclipse.core.runtime.CoreException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
I added the library org.eclipse.birt.runtime_4.8.0-20180626-4.8.0 which appears to be the required BIRT runtime. Can anyone give me a few pointers as to what else I may need?
Just in case anyone else tries to do this I thought I would list the libraries I needed to install to get standalone BIRT report generation running running. The list is as follows. Obviously this list may change over time so keep that in mind:
axis-1.4.jar
batik-anim-1.7.jar
batik-awt-util-1.7.jar
batik-bridge-1.7.jar
batik-css-1.7.jar
batik-dom-1.7.jar
batik-gvt-1.7.jar
batik-i18n-1.9.jar
batik-parser-1.7.jar
batik-script-1.7.jar
batik-svg-dom-1.7.jar
batik-transcoder-1.7.jar
batik-util-1.8.jar
batik-xml-1.7.jar
hibernate-agroal-5.4.9.Final.jar
icu4j-4.8.jar
itext-2.1.7.jar
mssql-jdbc-7.4.1.jre8.jar
org.apache.batik.css-1.6.0.jar
org.eclipse.birt.runtime_4.8.0-20180626-4.8.0.jar
org.eclipse.core.runtime_3.14.0.v20180417-0825-4.8.0.jar
org.eclipse.datatools.connectivity.oda-3.5.0.201603142002.jar
org.eclipse.datatools.connectivity.oda.consumer-3.3.0.201603142002.jar
org.eclipse.emf.common-2.16.0.jar
org.eclipse.emf.ecore-2.11.1.jar
org.eclipse.emf.ecore.xmi-2.11.1.jar
org.eclipse.equinox.common_3.10.0.v20180412-1130-4.8.0.jar
org.eclipse.equinox.registry_3.8.0.v20180426-1327-4.8.0.jar
org.eclipse.osgi_3.13.0.v20180409-1500-4.8.0.jar
org.mozilla.javascript-1.7.5.v201504281450.jar
org.w3c.dom.smil_1.0.1.v200903091627-4.8.0.jar
org.w3c.dom.svg-1.1.0.jar
sac-1.3.jar
xml-apis-1.4.01.jar
I am using Postman alongside a JAR file that runs a REST service that holds some contacts. However when I try to run the JAR file by using: java -jar ContactListRESTService.jar in Powershell, I am seeing a bunch of errors that Apache Tomcat could not run. Postman also doesn't recognize the localhost.
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:159)
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletCntainer.java:159) ~[spring-boot 1.3.7.RELEASE.jar!/:1.3.7.RELEASE]
I have tried uninstalling and reinstalling JAVA SE per some guidance from a mentor with no results.
If anyone can point me in the right direction please.
I'm trying to make a Java program that can communicate with JavaDB. I've made the Database class, started a server and made a tiny client program to check if they would communicate.
The program crashes when i try to run it, giving a class not found exception at the line where i try to set the database driver. I googled it and found that this error appears if derbyclient.jar and derby.jar are not found in the classpath. I also read that the scripts setNetworkClientCP and setNetworkServerCP found in the db directory would set these in the classpath. I found the scripts, ran them, and checked to make sure the classpath got updated, but i still get the same error. Does anyone know what the problem might be?
EDIT: SOLVED - i just realized that i need to include the derbyclient.jar in the NetBeans project library.
I'm using NetBeans and the built in JavaDB. I set the classpath by using the scripts that i mentioned above, and upon checking the classpath i found these entries:
%DERBY_INSTALL%\lib\derbyclient.jar;
%DERBY_INSTALL%\lib\derby.jar;
%DERBY_INSTALL%\lib\derbytools.jar;
%DERBY_INSTALL%\lib\derbynet.jar;
The Error:
java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:260)
at Database.<init>(Database.java:14)
at TestKlient.main(TestKlient.java:8)
I have configured JDEE in emacs. But when I try to run any App, it throws NoClassDefFoundError .
Upon compilation, although a class file is created, it only shows the buffer for sometime and then closes it.
The same files if compiled and run from the terminal work perfectly fine.
Also, on this machine I have java-6-openjdk installed. I had configured JDEE on my home computer which has sun java jdk and there are no such problems there.
Other than this, features such as code completion, generation etc work fine.
How do I solve this? Is this due to open jdk ?
I am using a Ubuntu 10.04 desktop.
This is the stack trace
cd /home/vineet/java/KodeJava/src/org/kodeplay/kodejava/
/usr/lib/jvm/java-6-openjdk/bin/java org.kodeplay.kodejava.EmacsTest
Exception in thread "main" java.lang.NoClassDefFoundError: org/kodeplay/kodejava/EmacsTest
Caused by: java.lang.ClassNotFoundException: org.kodeplay.kodejava.EmacsTest
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: org.kodeplay.kodejava.EmacsTest. Program will exit.
Process org.kodeplay.kodejava.EmacsTest exited abnormally with code 1
Thanks
something in your config is wrong. you are trying to run from the "/home/vineet/java/KodeJava/src/org/kodeplay/kodejava/" directory, but in order to find your class on the classpath, you should be running from "/home/vineet/java/KodeJava/src/". Probably need to configure the "jde-run-working-directory" variable.
From the question, it sounds as if the JDEE configuration is not complete when it comes to setting up the command to be launched when running the Java App.
If the same Java App can be run from the terminal with no issues, OpenJDK is not causing the trouble, I'd wager.
Perhaps you copied over from the other computer the JDEE configurations and did not adopt them for the new computer that has OpenJDK.
I created a new project and a new class in eclipse in my ubuntu machine to write the simple Hello World program. It works fine as long as i write the main method and use System.out.println to print my "Hello World". but i want to use the acm.jar package so I imported it to my project and tried to extend the ConsoleProgram class in acm.jar but once i write the public void run() method and try to run it i get some error
i know that i have imported acm.jar successfully because eclipse suggested the rest of the import when i was typing import acm.program.*;
here is the results i get:
Exception in thread "main" java.lang.NoClassDefFoundError: sun.applet.AppletViewer
at gnu.java.lang.MainThread.run(libgcj.so.90)
Caused by: java.lang.ClassNotFoundException: sun.applet.AppletViewer not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:/home/bilm3z/workspace/xbSampleProject1/bin/,file:/home/bilm3z/workspace/acm.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
at java.net.URLClassLoader.findClass(libgcj.so.90)
at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at java.lang.ClassLoader.loadClass(libgcj.so.90)
at gnu.java.lang.MainThread.run(libgcj.so.90)
here is a snapshot of the situation:
http://www.mypicx.com/12302009/situation1/
It follows from your stack trace that you're using a GCJ JVM. Try installing the Sun JVM - there are instructions here. (Note that you might have to enable different repositories for this, and note the update-java-alternatives command.)
After you install the Sun JVM, update your Eclipse preferences according to Bozho's answer, so that your Eclipse uses the correct JVM.
That's strange. Try Right click on your project > Build path > Configure built path > libraries, remove the JRE / JDK from there (if it exists), and add it anew - Add library > JRE System Library