Why is HttpServlet needed on the Java Build Path? [message #1449524] |
Tue, 21 October 2014 09:44  |
Eclipse User |
|
|
|
Hi *,
I basically have a maven project [1] using JSP just for rendering a UI of a portlet. javax.servlet.http.HttpServlet is not necessary at all to either build or run it, but I am getting this error marker on the JSP file anyway:
Quote:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
What is triggering the marker? Is my project misconfigured somehow? Or is WTP assuming incorrectly that all JSP files have to be used as servlets?
[1] github com /jboss-developer/jboss-portal-quickstarts/tree/6.2.x-develop/cdi-scopes-portlet - obfuscated a little bit, sorry, I can only use links to eclipse.org sites while I have fewer than 5 messages
|
|
|
Re: Why is HttpServlet needed on the Java Build Path? [message #1450453 is a reply to message #1449524] |
Wed, 22 October 2014 09:13   |
Eclipse User |
|
|
|
On 10/21/2014 11:53 AM, Peter Palaga wrote:
> Hi *,
>
> I basically have a maven project [1] using JSP just for rendering a UI
> of a portlet. javax.servlet.http.HttpServlet is not necessary at all to
> either build or run it, but I am getting this error marker on the JSP
> file anyway:
>
> Quote:
>> The superclass "javax.servlet.http.HttpServlet" was not found on the
>> Java Build Path
>
>
> What is triggering the marker? Is my project misconfigured somehow? Or
> is WTP assuming incorrectly that all JSP files have to be used as servlets?
>
> [1] github com
> /jboss-developer/jboss-portal-quickstarts/tree/6.2.x-develop/cdi-scopes-portlet
> - obfuscated a little bit, sorry, I can only use links to eclipse.org
> sites while I have fewer than 5 messages
Actually, JSPs are servlets. They are just created in a way that
differs from writing Java directly. If you happen to be using Tomcat,
you can examine the Java file created for the JSP under the "work"
folder. You will find that the generated class extends HttpJspBase,
which extends HttpServlet. I don't think any of this impacted by
whether the JSP is accessed from a portlet or from a browser.
WTP expects projects that contain JSPs to have a server runtime
associated with the project. This runtime will correspond to a version
of the Servlet/JSP spec and will designate which servers you can and
can't deploy the project to. If you use Servlet 3.1 or JSP 2.3, for
Tomcat you could only deploy to version 8.0. WTP will also use this
runtime version to guide the editor for JSPs and other appropriate
editors to match the features in that version of the spec. Since none of
this is involved in actually building your project, I'm guessing the
maven configuration isn't bothering to take this into account.
Cheers,
Larry
|
|
|
|
|
Re: Why is HttpServlet needed on the Java Build Path? [message #1451905 is a reply to message #1451310] |
Fri, 24 October 2014 09:24  |
Eclipse User |
|
|
|
Hi Larry and Max,
> is portlet api 100% independent from servlet?
After having looked properly, yes, Portlet API 2.0 depends on Servlet API 2.4., see
mvnrepository com /artifact/javax.portlet/portlet-api/2.0 *
But given this, should not m2e and WTP all the better know about the missing servlet class as it there in an indirect dependency of my project?
Studying this even deeper I found out that we declare web app 2.5 in the project's web.xml: git.io /ViVHNA *
Could the version mismatch be the problem? I tried to change it to 2.4 but the JSP error has not gone away and I got two new errors "Cannot change version of project facet Dynamic Web Module to 2.4." and "One or more constraints have not been satisfied." I am not sure if these two new errors are issued by WTP.
Thanks,
Peter
* obfuscated because I can only use links to eclipse.org sites while I have fewer than 5 messages
|
|
|
Powered by
FUDForum. Page generated in 0.04087 seconds