I am able to start the server with the command line 'java -jar jarname.jar
But , while running main method of the spring boot application , server start fails ,saying that a class from an imported dependency project does not exists
Caused by: java.lang.NoClassDefFoundError: Lcom/jj/db/repositories/KKRepository;
Also there is a warning message in the console :
2021-11-15 11:04:47 WARN WebappClassLoaderBase:173 - - The web application [MM] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:215) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2078)
Can anyone please help ?
Instead of a multi-module project, make it as a single module project or specify appropriately in the manifest.
Related
I'm working on some legacy code in JAVA.
It's like "pure java" with JSP and servlets, no maven and no spring boot.
I usually use VSCODE but the "way it's always been done" is with ECLIPSE and TOMCAT with some special configurations and a keystore.
My problem is: after I modify a .java file on VSCODE the TOMCAT starts giving up the errors:
ago 28, 2020 11:42:13 AM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
Caused by: org.apache.catalina.LifecycleException: A child container failed during start
ADVERTĂNCIA: The web application [header] appears to have started a thread named [Abandoned connecti
on cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.ref.ReferenceQueue.remove(Unknown Source)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:40)
ago 28, 2020 11:42:13 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
And I have no idea why or how to fix. I end up having to revert the changes, copy and paste the changes inside Eclipse. And then it works, even GIT says there's no changes...
No idea why, but excluding and then reading any file from buildpath seems to be the trick.
Maybe just touching the ".classpath" file should be enough.
That file doesn't appear in Eclipse by default, but does in VSCODE. Its located in the root folder of the project.
It appears you don't need to keep doing this every time.
I'm using git flow and only as I've changed to a new feature branch I had to do this again.
I'm using Gatling Frontline to run load tests written in scala with sbt as the build tool. The project compiles, builds, and runs successfully locally. However, when running on a Frontline host, the host fails to connect to the injector pool because the injector process has crashed with an Exception in thread "main" java.lang.reflect.InvocationTargetException. The stack trace indicates that this exception is caused by
java.lang.NoClassDefFoundError: com/google/protobuf/ByteString$Output
and
java.lang.ClassNotFoundException: com.google.protobuf.ByteString$Output.
This error has never occurred locally, during development, as this google package is not used by my project. Could this problem be fixed by changing any of the jvm options supplied by Frontline, or by adding certain system properties or build properties.
The project runs normally in eclipse, but there is a problem when the project is packaged and runs in the terminal. How should this problem be solved?
D:>java -jar
optaplanner-examples-7.4.1.Final-jar-with-dependencies.jar
D:\roster_450.xml 100 Exception in thread "main"
java.lang.ExceptionInInitializerError
at org.kie.api.internal.utils.ServiceRegistry.getInstance(ServiceRegistry.java:27)
at org.kie.api.KieServices$Factory$LazyHolder.(KieServices.java:332)
at org.kie.api.KieServices$Factory.get(KieServices.java:339)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:460)
at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:331)
at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:220)
at org.optaplanner.core.impl.solver.AbstractSolverFactory.buildSolver(AbstractSolverFactory.java:61)
at org.optaplanner.examples.common.app.CommonApp.createSolver(CommonApp.java:105)
at org.optaplanner.examples.nurserostering.app.NurseRosteringApp.createSolutionBusiness(NurseRosteringApp.java:94)
at org.optaplanner.examples.nurserostering.app.NurseRosteringApp.init(NurseRosteringApp.java:85)
at org.optaplanner.examples.nurserostering.app.NurseRosteringApp.main(NurseRosteringApp.java:77)
Caused by: java.lang.RuntimeException: Child services
[org.kie.api.internal.assembler.KieAssemblers] have no parent
at org.kie.api.internal.utils.ServiceDiscoveryImpl.buildMap(ServiceDiscoveryImpl.java:186)
at org.kie.api.internal.utils.ServiceDiscoveryImpl.getServices(ServiceDiscoveryImpl.java:97)
at org.kie.api.internal.utils.ServiceRegistryImpl.(ServiceRegistryImpl.java:36)
at org.kie.api.internal.utils.ServiceRegistryImpl$LazyHolder.(ServiceRegistryImpl.java:32)
... 11 more
Drools doesn't like uber-jarring because several jars have a META-INF directory with files with the same name. So last-one-wins.
Either don't use uber-jarring or doing use Drools score calculation.
A spring boot application (uses gradle) setup in IntelliJ starts up properly with no exceptions. However, on hitting it with requests via browser/postman throws Internal Server Error.
The application works perfect when started from commandline via
./gradlew bootRun
The exception stack trace says:
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:330)
I suspect something is not right (on classpath) when the application is started from inside IntelliJ - 14.
Any pointers are appreciated.
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.