Editing .java files in VSCODE causes error on Tomcat in Eclipse - java

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.

Related

How to get KQueue to be available in Java in OSX?

My packages are as following:
implementation("io.netty:netty-transport-native-epoll:$nettyVersion")
implementation("io.netty:netty-transport-native-kqueue:$nettyVersion")
implementation("io.netty:netty-transport-native-epoll:$nettyVersion:linux-aarch_64")
implementation("io.netty:netty-transport-native-epoll:$nettyVersion:linux-x86_64")
implementation("io.netty:netty-transport-native-kqueue:$nettyVersion:osx-x86_64")
Gradle showing the package getting installed correctly: (where <source> is the path to our internal library storage)
Cached resource <source>/releases/io/netty/netty-transport-native-kqueue/4.1.78.Final/netty-transport-native-kqueue-4.1.78.Final-osx-x86_64.jar is up-to-date (lastModified: Fri Jun 24 17:45:28 PDT 2022).
Gradle output showing the system:
------------------------------------------------------------------------
Detecting the operating system and CPU architecture
------------------------------------------------------------------------
os.detected.name=osx
os.detected.arch=x86_64
os.detected.version=12.4
os.detected.version.major=12
os.detected.version.minor=4
os.detected.classifier=osx-x86_64
Simplest way I can reproduce is:
KQueue.isAvailable()
returns false.
If I run the following to get more information:
KQueue.unavailabilityCause().printStackTrace();
I get: (removed repeating or unnecessary stack traces)
java.lang.UnsatisfiedLinkError: could not load a native library: netty_transport_native_kqueue_x86_64
at io.netty.util.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:239)
at io.netty.channel.kqueue.Native.loadNativeLibrary(Native.java:155)
...
Suppressed: java.lang.UnsatisfiedLinkError: no netty_transport_native_kqueue_x86_64 in java.library.path: /Users/kdilsiz/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
...
Am I not supposed to be able to run this code? What am I missing?
If I search online for the error, it shows outdated Netty package loading errors (only showing up in debug level logging). This is NOT my problem. The package loads correctly when I run gradle and I can see it is being cached/loaded with gradle -info --refresh-dependencies.
It was due to one of the dependencies importing netty-all. This was causing the Kqueue packages to be imported twice and with different versions.
The problem was that I did not fully read the stack trace from:
KQueue.unavailabilityCause().printStackTrace();
In the end of that stack trace, it said:
Caused by: java.lang.IllegalStateException: Multiple resources found for 'META-INF/native/libnetty_transport_native_kqueue_x86_64.jnilib' with different content:
...
After that, I was able to find where the package was coming from and fix it. Then I was able to locally run the Java Code to run domain socket and test it locally.
I used IntelliJ to run it after the fix. (VsCode had a problem even after the fix, hence wanted to mention it)

Java Jar starts from command line , but not from intellij idea

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.

Google Drive api Java QuickStart EOFException

I am following google drive v3 api quickstart
tutorial
I don't want to use gradle for this application since is a group project.
I have downloaded the google drive v3 libraries.
I am using Intellij, and I have added all of the jar to the class path. All jars are imported successfully and the IDE doesn't give any error.
At run time I get a warning which from reading online seems to be a problem with Windows Compatibility.
I have downloaded the .json file with user ID and user secret and placed it in the same folder as the main
My code is the same as the one of the quickstart example:
The error i get is the following:
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: C:\Users\HP\.credentials\drive-java-quickstart
Apr 06, 2017 2:31:52 PM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: C:\Users\HP\.credentials\drive-java-quickstart
Exception in thread "main" java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2624)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3099)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:853)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:349)
at com.google.api.client.util.IOUtils.deserialize(IOUtils.java:171)
at com.google.api.client.util.store.FileDataStoreFactory$FileDataStore.<init>(FileDataStoreFactory.java:102)
at com.google.api.client.util.store.FileDataStoreFactory.createDataStore(FileDataStoreFactory.java:73)
at com.google.api.client.util.store.AbstractDataStoreFactory.getDataStore(AbstractDataStoreFactory.java:55)
at com.google.api.client.auth.oauth2.StoredCredential.getDefaultDataStore(StoredCredential.java:171)
at com.google.api.client.auth.oauth2.AuthorizationCodeFlow$Builder.setDataStoreFactory(AuthorizationCodeFlow.java:736)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.setDataStoreFactory(GoogleAuthorizationCodeFlow.java:209)
at com.elox.Main.authorize(Main.java:77)
at com.elox.Main.getDriveService(Main.java:93)
at com.elox.Main.main(Main.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
I don't Understand why I get this error or how I could correct it
I know that this is an old post, but I had almost the exact same stacktrace and couldn't find an answer. So, I'm posting in hopes that it will help those that come after me.
The issue appears to be related to file/directory permissions. As soon as I changed the filepath being used by the FileDataStoreFactory to a directory that my application had read/write permissions to, OAuth2 worked correctly. So, make sure that you are using a non-restricted filepath and that all of the directories have the correct ownership and permissions.

Tomcat Manager Deploying WAR file located on server

I have a linux server installed CentOS and Tomcat6. And i am trying to deploy my jsf application and i created a war file of my project. I am using Tomcat Manager using Deploy directory or WAR file located on server with parameters given below
My war file is located in wepapps directory as suggested. Than i am giving the Context Path to my app name like /myapp and giving the WAR or Directory URL the url of my application which is like /var/lib/tomcat6/webapps/myapp.war and last i am leaving empty the value of XML Configuration. And when i press the Deploy button Message says Failed to deploy application at context path /myapp
Since this is the first experience for me to deploy an app located on server im not sure if i am doing right. I've searched lots of documents already but still cant find a usefull explanation to start my application.
I am realy stucked with this and need your help?
Here is my catalina log file
Sep 5, 2013 1:38:37 p.m. org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw error
java.lang.NoClassDefFoundError: org.apache.tomcat.util.modeler.ManagedBean
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1556)
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.execute(MbeansDescriptorsDigesterSource.java:238)
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:216)
at org.apache.tomcat.util.modeler.Registry.load(Registry.java:689)
at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:800)
at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:780)
at org.apache.catalina.mbeans.MBeanUtils.createRegistry(MBeanUtils.java:1066)
at org.apache.catalina.mbeans.MBeanUtils.<clinit>(MBeanUtils.java:95)
at java.lang.Class.initializeClass(libgcj.so.10)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.<clinit>(GlobalResourcesLifecycleListener.java:68)
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.Catalina.load(Catalina.java:617)
at org.apache.catalina.startup.Catalina.load(Catalina.java:665)
at java.lang.reflect.Method.invoke(libgcj.so.10)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Sep 5, 2013 1:47:15 p.m. org.apache.tomcat.util.digester.Digester startElement
SEVERE: Begin event threw error
java.lang.NoClassDefFoundError: org.apache.tomcat.util.modeler.ManagedBean
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1556)
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.execute(MbeansDescriptorsDigesterSource.java:238)
at org.apache.tomcat.util.modeler.modules.MbeansDescriptorsDigesterSource.loadDescriptors(MbeansDescriptorsDigesterSource.java:216)
at org.apache.tomcat.util.modeler.Registry.load(Registry.java:689)
at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:800)
at org.apache.tomcat.util.modeler.Registry.loadDescriptors(Registry.java:780)
at org.apache.catalina.mbeans.MBeanUtils.createRegistry(MBeanUtils.java:1066)
at org.apache.catalina.mbeans.MBeanUtils.<clinit>(MBeanUtils.java:95)
at java.lang.Class.initializeClass(libgcj.so.10)
at org.apache.catalina.mbeans.GlobalResourcesLifecycleListener.<clinit>(GlobalResourcesLifecycleListener.java:68)
at java.lang.Class.initializeClass(libgcj.so.10)
at java.lang.Class.newInstance(libgcj.so.10)
at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRule.java:145)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
at gnu.xml.stream.SAXParser.parse(libgcj.so.10)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.Catalina.load(Catalina.java:617)
at org.apache.catalina.startup.Catalina.load(Catalina.java:665)
at java.lang.reflect.Method.invoke(libgcj.so.10)
at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:281)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:455)
Caused by: java.lang.ClassNotFoundException: javax.management.modelmbean.ModelMBeanNotificationBroadcaster not found in org.apache.catalina.loader.StandardClassLoader{urls=[file:/usr/share/apache-tomcat-7.0.42/lib/,file:/usr/share/apache-tomcat-7.0.42/lib/catalina-tribes.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-coyote.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-dbcp.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-util.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-jdbc.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-i18n-ja.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-i18n-fr.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-api.jar,file:/usr/share/apache-tomcat-7.0.42/lib/ecj-4.2.2.jar,file:/usr/share/apache-tomcat-7.0.42/lib/catalina-ha.jar,file:/usr/share/apache-tomcat-7.0.42/lib/catalina-ant.jar,file:/usr/share/apache-tomcat-7.0.42/lib/jsp-api.jar,file:/usr/share/apache-tomcat-7.0.42/lib/jasper.jar,file:/usr/share/apache-tomcat-7.0.42/lib/catalina.jar,file:/usr/share/apache-tomcat-7.0.42/lib/tomcat-i18n-es.jar,file:/usr/share/apache-tomcat-7.0.42/lib/annotations-api.jar,file:/usr/share/apache-tomcat-7.0.42/lib/el-api.jar,file:/usr/share/apache-tomcat-7.0.42/lib/jasper-el.jar,file:/usr/share/apache-tomcat-7.0.42/lib/servlet-api.jar], parent=gnu.gcj.runtime.SystemClassLoader{urls=[file:/usr/share/apache-tomcat-7.0.42/bin/bootstrap.jar,file:/usr/share/apache-tomcat-7.0.42/bin/tomcat-juli.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}}
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.VMClassLoader.defineClass(libgcj.so.10)
at java.lang.ClassLoader.defineClass(libgcj.so.10)
at java.security.SecureClassLoader.defineClass(libgcj.so.10)
at java.net.URLClassLoader.findClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.ClassLoader.loadClass(libgcj.so.10)
at java.lang.Class.forName(libgcj.so.10)
at java.lang.Class.initializeClass(libgcj.so.10)
...25 more
Thanks and Regards
I solved the problem at last. The reason for error is simple actually. We configured our project and created war file using tomcat7. So when we try to deploy and run at server which has previous version of tomcat (tomcat6) it doesnt work. So we installed tomcat7 to that server and it works now. And probably its because tomcat6 doesnt support servlet3 and some of jsf feauters. Thanks again.
Well i have shorted Out that problem Just
Step 1:-
Install JDK 1.7.0
step 2:-
Just include Jre Directory when you are Making TOMCAT Server 7. just goto Installed Jre and Just select ADD in option in that and GOTO the Location of your JRE and add that Folder that.
Step3:-
after adding that finish server installation and run your server.
that way that will be working.

Tomcat 7 - java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation

I'm facing the following Exception:
Mar 26, 2012 1:20:34 PM org.apache.catalina.loader.WebappClassLoader loadClass
INFO: Illegal access: this web application instance has been stopped already.
Could not load org.apache.log4j.spi.ThrowableInformation.
The eventual following stack trace is caused by an error thrown for debugging purposes
as well as to attempt to terminate the thread which caused the illegal access, and has
no functional impact.
java.lang.IllegalStateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1562)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:322)
at com.abc.supervisionmanager.Monitoring.run(Monitoring.java:205)
at java.lang.Thread.run(Thread.java:662)
Exception in thread "Thread_Monitoring" java.lang.NoClassDefFoundError: org/apache/log4j/spi/ThrowableInformation
at org.apache.log4j.spi.LoggingEvent.<init>(LoggingEvent.java:165)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.error(Category.java:322)
at com.abc.supervisionmanager.Monitoring.run(Monitoring.java:205)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.spi.ThrowableInformation
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
... 5 more
I googled about this exception and found that most answers points that it is bug in tomcat 5.5 and it will be solved in version 5.5.28.
However I'm currently using tomcat 7.11 with log4j-1.2.16.jar I'm still facing the same issue.
For me, the solution for this issue (tested with Openbravo 3.0MP11 and Tomcat 7.0.21) was:
Remove the log4j-1.2.16.jar from WEB-INF/lib.
Put the log4j jar inside Tomcat's lib directory. In Ubuntu 11.10 this would be /usr/share/tomcat7/lib
Note for my specific use case of Openbravo: This does solve the log4j issue, but then I ran into other issues.
Sounds like it is a problem with your libraries. Are you sure that you have the Log4J jar-file in the WEB-INF/lib folder of your webapp?
How to solve it . For me:
try {} catch() log4j exception throw.
run tomcat again to find the real problem
solve the real problem and delete try{} catch()
It is not problem for log4j and tomcat. It will throw exception because some of your code run error in webapp init. Maybe xml or config is error.
I had this problem with a portlet (liferay 6.2 Tomcat bundle). I fixed it by deleting the deployment that caused the exception (in the tomcat webapps folder), cleaning and redeploying (with maven -- liferay:deploy) the portlet.

Categories

Resources