Servlet API classes are not on the classpath, some scriplet editing features are disabled.(NetBeans-Glassfish server) - java

The NetBeans IDE wont show me any hint for the code I type. Instead it shows me the error "Servlet API classes are not on the classpath. Some scriplet editing features are disabled":
I have tried:
Uninstalling the IDE.
Installing a new JDK version.
Deleting the GlassFish Server.
Setting classpath in my environment variables to jakarta-servlet-api.jar file, found in the /lib of Glassfish
I just want the error to go away, and the IDE to behave as it did before.

Related

Java Class files in tomcat not linking/updating when using eclipse

I am working on an old jsp project. I have to modify it so that I can use it to meet my needs. I was facing issue while using any newer version of tomcat or java sdk. Therefore, I am using Tomcat 5.5.7 and java SDK 1.5. I have updated java class files of this project using eclipse helios (2012). But the implementation don't show up in my project. Like when I change the database name and run the project it still wants to use the old database name. I have tried to upgrade the whole project to a new version of tomcat and java sdk but it doesn't work. Can anyone help me with this?
Steps you need to take -
Import the project into eclipse - Create a new project, import using existing source files.
You need to setup the Java Facet of "Dynamic Web Application" along with some other Facets to make this application run successfully on the tomcat container inside of eclipse.
You need to install the server tools in eclipse. Using the Java EE perspective is very helpful.
When making changes to the JDK or the server runtime, as you mentioned, you will need to update the projects build path. Right click on the root of your project and go to the build path. Change the SDK version, change the runtime version of tomcat that is included with it. You will need to create a new Java Server runtime for any other versions of Tomcat you want to add to the project.
This is a complicated issue, and there is no specific answer, as your question is very broad. I would recommend watching some tutorials on "How to setup Web application projects in Eclipse." Maybe add Java 5 or 6 to the search to get older results.

removing java.endorsed.dirs from Tomcat on Eclipse with Java 9 and Java 10

I'm using Eclipse 4.7.3a with Tomcat 9.0.4 in the IDE. I upgraded from Java 8 to Java 10. I changed my JAVA_HOME to point to the JDK 10 installation. I went into Eclipse and created a new JDK installed JRE pointing at the Java 10 JDK, and selected it. I rebuilt my project, and tried to start the Tomcat server I had. It said:
-Djava.endorsed.dirs=C:\bin\tomcat\endorsed is not supported. Endorsed standards and standalone APIs
in modular form will be supported via the concept of upgradeable modules.
I poked around and found that in the Tomcat launch configuration in Eclipse, under the Arguments tab, there are the following VM arguments:
-Dcatalina.base="I:\work\.metadata\.plugins\org.eclipse.wst.server.core\tmp1" -Dcatalina.home="C:\bin\tomcat" -Dwtp.deploy="I:\work\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps" -Djava.endorsed.dirs="C:\bin\tomcat\endorsed"
I removed the last part, -Djava.endorsed.dirs="C:\bin\tomcat\endorsed", and hit Apply, but the changes don't "stick"; when I come back to that dialog, the value is still there, and I still can't run Tomcat.
How can I removed the java.endorsed.dirs system property from the Eclipse Tomcat configuration?
Better yet, how can I avoid the problem altogether? Isn't Eclipse and Tomcat ready for Java 9+? Will a newer version of Tomcat 9 fix the problem? Should I remove and add back the Eclipse server? How can I get to the root of the problem?
I also have this problem before and but after updating WTP plugin to the latest version (3.9.5) which is not included even in the latest Eclipse (Oxygen.3a) to solve the problem.
For me this was still occurring even in the latest Eclipse IDE 2019-12R with eclipse web tools platform release 3.16 running AdoptOpenJDK jdk-11.0.5.10-hotspot.
I did as the OP, found -Djava.endorsed.dirs in the Arguments tab under the VM arguments for Tomcat. Get there by right clicking your project, select Run As -> Run Configurations... then, search for tomcat. In my case I clicked on 'Tomcat v9.0 Server at localhost', selected the Arguments tab and found the offending entry by scrolling down in the 'VM arguments' text box. I deleted the argument and it's referenced path. I restarted Eclipse and it seems to have stuck.

"The type java.util.Map$Entry cannot be resolved" (tomcat6 + JDK7)

I've a JSP app which gives me the error:
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
Stackoverflow is full of post about this error, but all of them get to solve just compiling the .java files using JDK7, plus using tomcat with same version (I mean, below to JDK8 which seems to be the problem, because some IDE version and tomcat versions doesn't support it).
The problem is that I've built my app (.java files) using JDK 1.7.0_79, plus I've my tomcat 6 server using the same one.
So there's no JDK 8 anywhere... Some screenshots with data:
My JVM directory:
Error stacktrace:
Tomcat process (running using JDK7):
Javac version used to compile:
Any idea about why do I still get this error?
Thank you in advance
Run Tomcat with Java 6 or upgrade to Tomcat 7 and make sure you don't have some old pre-Java 5/pre-generics library on the classpath.
Why do you get this error? Somewhere in the JSP code (not your code, mind), is a dependency on java.util.Map.Entry. This could be in code which Jasper generates from your JSP.
It's not a direct dependency; rather your code (or the Java code generated from your JSP) needs something else which then needs java.util.Map.Entry
But the interface has changed in some way. Usually, that's with Java 8 because of the new static helper methods which they added: The name of the class is the same (which makes the error so confusing) but the API has changed and the code can't find something (or found something it didn't expect).
A similar problem can happen when you try to compile against a pre-generics class (even though that should work).
Even worse, import java.util.Map in your JSP works. It's the existing bytecode somewhere else that causes the trouble.
[EDIT]
In my /WEB-INF/lib/ folder I've: commons-fileupload, commons-io, poi and rt (may this one be the problem?)
Yes :-) rt.jar is the Java runtime. It contains java.* and in your case, a version of java.util.Map which doesn't match the one from your Java VM.
Remote it and it should work.
I had the same problem with Eclipse Mars, JDK 8 and the Tomcat Maven Plugin. It was solved changing the plugin version to 2.2 in my pom.xml.
I have tomcat-7.0.22 and jdk1.8.0_45 and I replaced the ecj-3.7.jar file that is in tomcat/lib directory with ecj-4.6.1.jar file that's included in the tomcat-8.0.43 and that got rid of the error.
for more information take a look at this post How to change tomcat compiler

Google App Engine JSP can't deploy: java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE

this is hopefully something simple but... Eclipse has been working relatively fine for everything except deploying to GAE.
I can run my GAE app locally, but when I try to deploy to google, I get this message:
java.lang.RuntimeException: Cannot get the System Java Compiler. Please use a JDK, not a JRE.
I have set the build path to JDK.
It also happens when trying to deploy the same project from more than one system (win7 and win8) so I suspect the problem is to do with the project itself. This particular project is existing and already running on google for years.
Interesting that this error only shows up when I have .jsp files in my app to deploy. If I remove the jsp files, it deploys without error. (kinda need the jsp files tho)
thanks
link to image of my build path
I had the same problem and was able to deploy successfully after forcing Eclipse to use
the JRE within my SDK directory (Win 7 64bit). To force Eclipse to use a particular JRE see this. It seems that the JVM that Eclipse uses, the JVM that app engine spawns, & the JVM that appconfig uses should all be the same. Hope this helps w/ your situation as well.
I tried setting my project jre to be the same as my eclipse jre according to AlohaCode's answer. This was insufficient for me. The answer was in my classpath, there is java.exe in C:\windows\system32 which was BEFORE my java home variable.
The solution is to put the java home path before the C:\windows\system32 entry.
I found the answer here: 2FL5sJ">https://groups.google.com/forum/?fromgroups=#!msg/google-appengine-java/RyFybJWUhU4/78UE_2FL5sJ
In Eclipse, go to: Window->Preferences->Java->Installed JREs , add->Standard VM TO JDK PATH\JRE. and If you had a JRE checked previously uncheck it and check this jre
The given advice solved my problem. The -vm argument cannot be the first line.
-vm
C:\Program Files (x86)\Java\jdk1.7.0_51\bin\javaw.exe
Setting -vm in eclipse.ini did not help. All other settings were seemingly pointing to the JDK. Out of desperation, I uninstalled all JREs from my system, leaving only the JDK. The consequence was that Eclipse would not start as the JDK bin directory was not on my PATH (Windows 8 here). Adding this in environment system variables got Eclipse to start. Thereafter I could deploy to app engine.
Removing the JRE file located in my C:/Program Files(*86)/Java folder , reopening the eclipse IDE resolved the issue.
I had Java JDK installed in my C:/Program Files/Java folder which was not detected earlier.

does sysdeo tomcat plugin for eclipse add value to helios?

am developing a simple web app using jsps and servlets for tomcat 5.5.
Currently using the Eclipse Helios and Dynamic Web Application Project.
For some reason it is a nightmare. We spent 4 hours today trying to deploy a servlet to tomcat. We kept getting errors like
"java.lang.UnsupportedClassVersionError: Bad version number in .class file"
we played around with everything trying to set the build compatibility to what tomcat had but couldn't make the stupid thing work. (Yes it is possible we're incompetent. any suggestions on what we can try looking at are apprecieated)
My friend recalls from long time ago that he used this plugin
eclipsetotale_tomcatPlugin
in order to create a "tomcat project". My question is, does sysdeo tomcat plugin add any features that aren't already available in helios?
thanks
Not sure about sysdeo, but your error seems similar to bug 116713:
If your default JRE is set to 1.4.2 and you have a Web project targetting
Tomcat 5.5 (dynamic Web module version 2.4 and Java 5.0), when you tried to run
a main program, you'll get the error (you mention).
What is your default JRE set for your project?
This scenario happens when the JVM running the code is older than the one the compiler generated code for.
Have you considered simply running Tomcat under Java 6? If that is not an option, please edit your question to include this and any other restrictions on this project.
We used to get that error often when we had Java version issues. Eclipse environment and Windows environment (java_home and path variables typically) are easy to overlook.
Also, you can use javap -v Foo in same directory as Foo.class to find out its version.
Just use the Eclipse IDE for Java EE Developers, 206 MB edition of Eclipse. It has Tomcat and other webserver support built-in by default. Works like a charm!
Sysdeo is an old, as far as I know obsolete, plugin.

Categories