Friday, September 9, 2011

Cloud Foundry and the missing TLD

I just started with Cloud Foundry and... well... what to say....
WHOOOOAAAAA!
It's absolutely fantastic! I hope the BETA will end soon to switch to a "general availability" of sort.
It took just five (5) minutes to start a complete Spring web project.
The only problem I had was with the c.tld file. Initially I had the problem that Tomcat could not locate the META-INF/c.tld file.
I didnt find any precise answer on the web, but in The Big Moose Saloon gave me the right hint
The problem is that in my POM file I added the dependencies
<dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>servlet-api</artifactId>
 <version>2.5</version>
</dependency>
<dependency>
 <groupId>javax.servlet.jsp</groupId>
 <artifactId>jsp-api</artifactId>
 <version>2.2</version>
</dependency>
Doing so I added these two jars to the classpath but this conflict with Tomcat.
I added them to avoid compilation issues for tag handler in Eclipse.
Obviously, you can simply remove the dependencies and disable JSP validation in Eclipse. But that's not a solution, that's a workaround. And a ugly one, in my opinion.
There is a solution and is very simple. Just tell Maven to trust these jars exist, i.e. change the scope of the dependencies
<dependency>
 <groupId>javax.servlet</groupId>
 <artifactId>servlet-api</artifactId>
 <version>2.5</version>
 <scope>provided</scope>
</dependency>
<dependency>
 <groupId>javax.servlet.jsp</groupId>
 <artifactId>jsp-api</artifactId>
 <version>2.2</version>
 <scope>provided</scope>
</dependency>

Done!

4 comments:

  1. Have u come across this error with cloudfoundry " Unable to read TLD "META-INF/c.tld""

    ReplyDelete
    Replies
    1. Hi Ramesh. Honestly I don't remember now the actual description of the error. Maybe it said "read" instead of "locate". Did you try the solution above?

      Delete
  2. Why do u need to keep a dependency if that could be removed?

    ReplyDelete
    Replies
    1. So much time passed that I don't remember exactly. Mainly, if my memory does not fail, it's because removing it completely caused compilation errors. Hence, I provide it at compile time though excluding it during packaging.

      Delete