Reputation: 1807
I have a statement
String pass = com.liferay.portal.util.PortalUtil.getUserPassword(renderRequest);
that causes the following error in eclipse IDE:
The type javax.servlet.http.HttpSession cannot be resolved. It is indirectly referenced from required .class files
Why is this error occuring? I have added an import statement for the type but yet the error remains. How can I remove this error?
Thanks for your help.
Upvotes: 5
Views: 28132
Reputation: 512
In order to remove this error You need to add the Servlet API to your classpath. In Tomcat 6.0, this is in a JAR called servlet-api.jar in Tomcat's lib folder. You can either add a reference to that JAR to the project's classpath, or put a copy of the JAR in your Eclipse project and add it to the classpath from there.
If you want to leave the JAR in Tomcat's lib folder:
Right-click the project, click Properties. Choose Java Build Path. Click Add External JARs... Browse to find servlet-api.jar and select it. Click OK to update the build path.
if you copy the JAR into your project:
Right-click the project, click Properties. Choose Java Build Path. Click Add JARs... Find servlet-api.jar in your project and select it. Click OK to update the build path.
Upvotes: 2
Reputation: 309
Download Apache-Tomcat. Browse to the lib folder. Now open eclipse and go to build-path-> configure build path-> add external libraries.
Upvotes: 2
Reputation: 617
Check your project setup. If I recall correctly, this has to do with com.liferay.portal.util.PortalUtil.getUserPassword(renderRequest) using javax.servlet.http.HttpSession under the hood, but eclipse isn't able to find that class. Try adding the servlet api jar to the project class path
Upvotes: 2
Reputation: 346506
You need to put the definition of that class (usually contained in a servlet.jar file) into the build path of your project (right-click on the project, select "Properties" and then "Build Path").
Upvotes: 3
Reputation: 1503419
It sounds like you haven't referenced the right libraries. Add a reference to servlet.jar.
Upvotes: 9