The JAR file C:\...Tomcat-8.0\lib\servlet-api.jar has no source attachment - eclipse

I did Ctrl+Click on HttpServlet to see source code of HttpServlet, but it gave me this error:
How to fix this? It says, I should download "servlet-api.jar", but when I try to download, I can not understand which one should I download? There are lot of servlet-api.jar files.

The source code is not necessarily specific to the Servlet API, but to the Servlet Implementation itself. In your particular case, Tomcat is the Servlet Implementation. So, you need to head to its homepage to find download links to the source code. Usually it's at the same place as where you downloaded the binaries.
Tomcat 8.0 download page is here, if you scroll to bottom, then you should see those links:
Binary Distributions
Core:
zip <-- this is Tomcat server itself.
...
Source Code Distributions
...
zip <-- this contains the source code.
Download the source code zip, put it somewhere in your file system (I usually put it in Tomcat installation folder; do note that you do not need to extract it!). Finally, press Attach Source button in Eclipse and point to that source code zip file.

If this maven based project , you just select the dependency in the Package Explorer, right click and then select "Attach resource"

Related

Google debug: How to debug a library in executable jar - Error : File was not found in the executable

Details: Java app on GKE : Kubernetes
I am able to debug all the java files of my executable jar but not the inner jars/libraries. My executable jar's main code is in implementaion jars/libraries, I have source code of those libraries. How can I debug them?
I have used gcr.io/google-appengine/openjdk and added following entry points:
ENTRYPOINT ["java","-agentpath:/opt/cdbg/cdbg_java_agent.so", "-Djava.security.egd=file:/dev/./urandom" ,"-Dcom.google.cdbg.module=watchlist", "-Dcom.google.cdbg.version=develop","-jar","/watchlist.jar"]
I think I need a way to put all the class files of required library jars in my main executable jar's web-inf/classes folder. How can I do that?
TIA
I recommend using an IDE.
In my experience, when you got the implementation from your java file to the class file (CTRL + click normally does the trick for classes or Right click and go to implementation for implementation), you reach the class file of the jar.
There you can go to the top of the class file and click on the package. This will open the jar from target of your project explorer.
You will be able to find your desired class there, or in a different package.
I hope this approach works for you.
PS: I use Intellij

Bring back the original project from a WSDL file or a WAR file

We have lost our java code that implement a web service. Now we have only a wsdl file (and a WAR file) published in tomcat. We need to bring back the original java project so I have tried to generate java source code from WSDL file (and WAR file) and I succeeded -by using axis2 (WSDL2JAVA) plugin- but I think it generates only the java classes that should exist in the src package of the project.. no welcome pages or index.xml etc.. I Don't know what other things are missing and how to bring them back.
My question is: what to do after generating java classes from WSDL file? should I complete the other project parts in my own? Is there a way to bring back exactly the original project from WSDL or WAR file?
As per the Scenario you mentioned for WAR file you can use JAD tool to unpack the whole code but with certain limitations like you cannot edit or save the code and I am not sure about the copy feature because it was not working for previous version.
Here is the link below.
https://varaneckas.com/jad/

Netbeans, get the right javadoc for EclipseLink

In Netbeans 7.2.1 i've created a new java project
In the project properties, in the libraries section, i've added "EclipseLink (JPA 2.0)" that is a library that ships with Netbeans (at least with this version).
But javadoc isn't provided so, for example, when i try to instantiate an EntityManagerFactory:
Persistence.createEntityManagerFactory(String string Map map)
i can't get support, so eventually i don't know what i am expected to pass into the map argument.
How can i determine the correct javadoc file/s to add and where can i find it?
Solution attempt 1
As far as i can see, there is no reference to the url of the project inside the library, so you are supposed to get this information in other places.
Once i've got the information (http://www.eclipse.org/eclipselink/api/2.5/index.html), i downloaded the zip file and i put in a local directory:
/home/homersimpson/NetBeansLibraries/EclipseLink (JPA 2.0)/eclipselink-javadocs.zip
Then, in NetBeans Ant Libraries, i've added, for the "EclipseLink (JPA 2.0)" the zip file to the sources.
I still cannot get help for class: javax.persistence.Persistence
but in the .zip file i have:
javax/persistence/Persistence.html
I assume NetBeans needs to source to show you the java docs. So ensure you include the source code jar for JPA.
For online java docs see,
http://www.eclipse.org/eclipselink/api/2.5/index.html

Where to put jar files for struts 2 in eclipse,giving error index.jsp(8,40) File "/struts-tags" not found

Eclipse is only giving me option to include jar files in Java Build Path->Libraries .In some tutorial sites they are showing to add jar files in WEb-INF/lib,but iam not able to add jar here.i tried importing files to WEB-INF/lib,jars were added but they did not had jar icon instead some weird icon ,and when i m trying to run my struts login page its giving me error
/index.jsp(8,40) File "/struts-tags" not found.Where to put jar to make it work,Also while learning struts sometime i get Http 404 error,but when i restart eclipse(I tried restarting server but it didnt help) the error is gone all of a sudden.why this is happening.Eclipse is so confusing.
Go to the your web-project folder outside the eclipse.Cope your jars (which are required for your project).
Than open-up Eclipse, follow these steps
Right Click on project(Project Explorer) choose -->Configure build path.
Go to Library tab and click on add jars, it will open this wizard
Add required jars and i hope this will solve your problem.
Make sure you have required jars in your class-path..
As jars are showing some weird icon, I would suggest you to change the jar files. Also, make sure your added jar contains struts-tags.tld file. This will resolve error on index.jsp.
sorry, system is not allowing me to put comment. So editing the same.
Follow below steps to check the jars are added to build path correctly -
switch to package explorer view.
check whether your jars are added under web app Libraries. If yes your jars are added properly.
Then check struts-tags.tld file is present inside struts2-core.jar. If not present then copy it or add new jar containing the same.

Dynamic Web Project libraries

Good morning in my timezone.
I have imported one Dynamic web project to my eclipse. I have downloaded the Tomcat server.
If I work without any IDE, I know that every libraries that we use in the project must be inside the lib folder in tomcat.
Folder structure : Tomcat\webapps\WEB-INF\lib
My question is, if I need a library (*.jar) should I put it directly in the lib folder or should I configure in the build path, adding it in the libraries tab?
Second question, my project steels have the red cross above the project name, but I do not see where the error is, in the src folder no class have any error and inside the Web Content folder there is not any cross, so how can I know where the problem is?
Thanks in advance.
Best regards developer community.
There shouldn't be any need for configuration, just copy them in the lib folder.
Make sure you have set the right jdk and the server libraries. right click on project -> build path -> configure -> libraries. if there is no tomcat runtime lib, you should add it.(I assume tomcat is embedded in eclipse. If not, right click on servers(next to console) and add the tomcat server.)