Tuesday, August 24, 2010

Eclipse Ganymede, Portlets and Weird Errors.

Ok so you're doing some of the training exercises from Liferay and you're all excited about working with Liferay 6. (You are, aren't you? Isn't everyone?) You're doing the classic Pitcher-Catcher portlets to practice with inter-portlet communication to show off the Portlet 2.0 specs and everything's going great when...

...You're getting weird errors in Eclipse Ganymede and can't seem to fix them.

The first one is in your view.jsp files where this line

taglib uri = "http://java.sun.com/portlet_2_0" prefix = "portlet"

Is erroring out. Specifically, it says "Cannot find the tag library descriptor for "http://java.sun.com/portlet_2_0"

And nothing you've done has made that go away. You've tried making sure you have the right util-taglib.java file in your build path and nevertheless it won't go away. What's wrong?

Blame Eclipse.

Now, I love Eclipse. I think it's the cat's meow and I don't see myself ever using anything else, but Ganymede isn't perfect and it has a few warts. This is one of them. The solution:

Ignore it. It's a bug but it won't mess up your ability to build and deploy it with Ant.

"But wait!" You say. "I have another error in my jsp. in the line

String pitch = (String)renderRequest.getParameter("pitch");

it has an error saying 'renderRequest cannot be resolved' so how do I fix that?"

Your portlet.jar file is where it's supposed to be, right?

"Right!"

Then ignore that one too. Run your Ant deploy. See, Eclipse is noticing that in that .jsp file there's no declaration for renderRequest so, in its neurotic wisdom, it has assumed that you simply failed to declare the variable and it errors it. That won't stop it from building your project since Java code in .jsp files doesn't get compiled until the first time the page is requested, and Tomcat's got the definition it needs for renderRequest. It'll be fine.

Batter up!

No comments:

Post a Comment