Tuesday, 6 October 2015

Java Development - Where are my HttpServlet and HttpServletRequest types ?

I saw a huge batch of exceptions, including: -

HttpServlet cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletRequest cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
HttpServletResponse cannot be resolved to a type
ServletException cannot be resolved to a type
ServletException cannot be resolved to a type
The import javax.servlet cannot be resolved
The import javax.servlet cannot be resolved
The import javax.servlet cannot be resolved
The import javax.servlet cannot be resolved
The import javax.servlet cannot be resolved
WebServlet cannot be resolved to a type


when I attempted to compile a new Java servlet using Eclipse, either Luna or Mars.

In both cases, I had the requisite Java EE version of the IDE, and yet .....

This: -


amongst other things made me realise what I was missing.

Whilst I had the Eclipse IDE, I didn't have a target runtime :-)

I'd downloaded the latest Eclipse Mars from IBM Bluemix here: -


but I was missing a runtime ( this is on my Mac running OS X10.10.5 ).

I downloaded WebSphere Liberty Profile ( WAS Liberty with Java EE 7 Full Platform ) from here: -


and expanded it: -

unzip ~/Downloads/wlp-javaee7-8.5.5.7.zip 

Once I configured Eclipse to use Liberty and, more importantly, changed my JEE project to use Liberty as a Targeted Runtime: -


all the nasty errors went away :-)

No comments:

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...