File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes No tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "No tag "ajax" defined in tag library imported with prefix "f"" Watch "No tag "ajax" defined in tag library imported with prefix "f"" New topic

No tag "ajax" defined in tag library imported with prefix "f"

David Erkstam

Joined: Feb 24, 2012
Posts: 1
I'm really pulling my hair out over this. I'm new to JSF and I'm afraid I'm pretty new to Java all together though not programming in general. I've gone thourgh the documentation and the earlier examples work fine but when I'm using some tags like "f:ajax" and some other as well I'm getting errors that they're not defined. I've read that they didn't exist before version 2.0 and I've made sure I'm not using any earlier with this function:




And (drum roll) the error:

During my many tests I got some slightly different results from wrting the ajax.jsp as a xhtml-file and putting the tag-import lines in that format where you type them as attributes to the html-tag. Then however it said something about #{...} not valid in template.

I'm using jBoss 7, JSF 2.1.7 and I'm just exporting the project as a WAR-file without Maven or any such thing. That shouldn't cause it to use an older version of JSF? Just to be safe I even removed a jar-file named JSF-something version 1 from folder in jBoss.

It's also the same with these additions to the web.xml, which I'm slightly surprised, don't seem to be needed:

I'm accessing the page with this URL btw: /test/ajax.jsf

Please help, it would really make the weekend so much better if I didn't have this to come back to on monday :p
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17417

Welcome to the JavaRanch, David!

It certainly does look like a classpath issue. I cannot tell what the actual problem is, but I can tell you a few things about how the WAR should be set up. Since the implementation classes for JSF are built into JBoss 7, you only need a JSF-api.jar in your WAR. You should not have to meddle in any way with JBoss's classes. The tag libary dereferencing is done exclusively on the View definition itself, so the faces-config doesn't matter, and web.xml would only come into play if you had used the JBoss override of JSF classes.

One thing that does smell funny is that the message you're getting looks like a JSP compile error, and that's not what you should be seeing in JSF, and most especially in JSF2. JSF Views are not JSPs. They are, in fact, page template XML files in JSF View Definition Language. JSPs are compiled into Java code (servlets). JSF views are not. They are digested into component trees used by the FacesServlet.

It's possible that if you rename your ".jsp" file to ".xhtml" and add Facelets configuration as suggested for JBoss that that might resolve your problem.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: No tag "ajax" defined in tag library imported with prefix "f"
jQuery in Action, 3rd edition