Using taglib TEI in a JSP does not appear to be working

I have a JSP project which uses a 3rd party taglib which injects certain objects into the pageContext at runtime.  I'm doing development using Apache Sling.  One of the tags I'm trying to work with is the <sling:defineObjects/> tag.  The TLD file defines a TEI file correctly, and it is there.

The syntax checker is correctly handling the tag itself.  It can code assist with parameters.  If I ctrl-click on the tag, it takes me to the TLD file.  If I ctrl-click on the class specified in the <tei-class> tag, IntelliJ takes me to the correct class file, so that much is working.  But in my JSP file itself, while the tag is handled properly, I'm still getting the syntax checker marking the newly defined implicit variables as red/error.  Does IntelliJ need some further hinting?  Sling projects are NOT set up like other web projects, so I wonder if that's an issue?  For example, I can't define a web facet.  Is that required?

I'm using 9.0.4.

Thanks for any help,


Message was edited by: David Levine

Comment actions Permalink

Could you provide a code snippet? Scriptlets like

    String foo = (String) pageContext.getAttribute("foo");

work fine for me.

Comment actions Permalink

I'm sorry, I misspoke.  Instead of pageContext, I meant implicit objects.  The tag adds implicit objects which are also identified in a TEI class.

So an example piece of code from a JSP file would be something like:

<%@taglib prefix="sling" uri=""
%><sling:defineObjects />
<%= currentNode.getProperty("text").getString() %>

If I ctrl-click on the "sling:defineObjects" tag, IntelliJ correctly opens the TLD file.  In the TLD file I can ctrl-click on the classes defined in the <tag-class> and <tei-class> nodes and both will correctly open the class file.  So it looks as if IntelliJ sees everything properly.  And the code completion works with the tag itself.  When I type "<sling:" it instantly pops up with the possible completions.  But for some reason the implicit object "currentNode" that is created by the defineObjects tag is not being resolved by IntelliJ.

Comment actions Permalink

Hi David,
I am facing the exact same problem i.e. currentNode is not recognized even after doing <sling:defineObjects/>. I was wondering if you found any solution for this.

Comment actions Permalink

Same issue here... did you find a solution for this problem?


Comment actions Permalink

Bump; I am running into the same issue.

Using IntelliJ IDEA Ultimate 12.1.4

Comment actions Permalink

I also had the same issue for weeks.. am using IDEA 12

Just make sure you have all the taglib dependency jar files.. in other words there should be no errors ( red marks ) in IDE editor when you open the taglib file....

Comment actions Permalink

Same happens to me with Idea 13:

It's basically a POC, so i can post the structure and files. It works when deploying the war, but the IDE doesn't recognize the TEI implicit variable

- lib
     -     jsp-api.jar
     -     servlet-api.jar
- src
     - org
- web
     - WEB-INF
          - jsp
               - test.jsp
          - tld
               - test.tld
          - web.xml


public final class TestTag extends BodyTagSupport {

    public TestTag(){

    public int doStartTag()
            throws JspException
        String result = null;
        result = (String)this.pageContext.getAttribute("test", PageContext.REQUEST_SCOPE);
        if (null == result){
            result = "Hello World";
                result, PageContext.PAGE_SCOPE);
        return super.doStartTag();

public final class TestTEI extends TagExtraInfo {

    public TestTEI(){


    public VariableInfo[] getVariableInfo(TagData paramTagData){
        return new VariableInfo[] {
                new VariableInfo("test", "java.lang.String", true,


<?xml version="1.0" encoding="ISO-8859-1"?>

<taglib xmlns=""






<%@ taglib uri="tld/test" prefix="test" %>
    <%= test %>

Actually i got the code hint for <test:init> but i got a "cannot resolve symbol 'test'" on the scriptlet. As i said, it works when deploying it on tomcat

Comment actions Permalink


I've copied all the source code/markup you have provided into my test project and see no problem.

Could you pack the whole test project where the problem occurs on your side and attach? Maybe the project settings play a part.

Thank you,

Comment actions Permalink

I'm experiencing the same problem with TEI and scripting variables.

Tested on MacOSX 10.9 +
     IntelliJ 12.1.6 Ultimate (129.1359),
     IntelliJ 13 Ultimate (133.193)

- I created a new project, type: Java
- Add Web Application support (checked create web.xml)
- Added dependency on servlet-api.jar and jsp-api.jar (from Tomcat 7 lib dir)
- Created the two classes above (org/, org/
- Created WEB-INF/tld/test.tld
- Added reference in web.xml
- Updated index.jsp with test code
- Rebuilt project

After the above steps, the 'test' variable in the scriptlet is highlighted in red.

Project directory is attached.

Comment actions Permalink

Thank you. Short off-topic: is there "1" macro in your Settings / Path Variables? Opening attached project requires to define it (I can work without it for now).


Comment actions Permalink

Indeed, there is a "1" macro in my path settings.  Weird.

Comment actions Permalink

I see the red just after the rebuilding the project. However, after closing and reopening of the project the error goes away.

The fact that reopen is required is anyway a defect or limitation, I will report it. But please confirm that reopening the project helps on your side to make sure we observe the same issue.

Thank you,

Comment actions Permalink

And what is its value?

I'm sure this does not relate to TEI issue, just hoping we could catch one more.


Comment actions Permalink

It's unrelated.  It was defined as "2'.   I have no idea why.

Comment actions Permalink

That's different behavior than I'm seeing.  For me, "test" remains "highlighted red" after closing and re-opening the project (also after quitting and restarting IntelliJ).

I rebuilt the project without the "1" macro and saw no change.  Any diagnostics I can enable?  I'm going to try a fresh IntelliJ install on Windows (instead of MacOS X) with the same project.  

Comment actions Permalink

It works fine after a fresh install of IntelliJ 13 on Windows.  I'm going to try nuking my prefs on MacOS X (By launching IntelliJ as a guest user account)

Edit: Did not work after nuking ~/Library/Preferences/Intellij13 on OS X.

Edit2: Works on a fresh IntelliJ Linux install too.

Message was edited by: Chris Thielen

Comment actions Permalink

I installed a fresh copy of IntelliJ on:

Linux (Ubuntu 13.10)  (TEI works)
Windows XP   (TEI works)
Mac OS X Mavericks 10.9.1   (TEI does NOT work)

For Mavericks, I installed a brand new copy of Mavericks 10.9.1, JDK 1.7.0_45 and IntelliJ IDEA 13.  I downloaded Java 6 runtime when the IDEA installer asked me to.

Edit: I tried something based on IDEA-75293 ... On Mavericks, if I tell IntelliJ IDEA to launch using JDK 1.7*, then the variable defined by the TEI is no longer "red".  However, being run under JDK 1.7 is not supported by IDEA, apparently.

Final Edit:
I have determined the cause of the problem, as it affects me (OS X):

This is an interaction between IntelliJ running under JRE 1.6 and the project being compiled by a JDK1.7 compiler.  My project is all 1.7.
The project is built using the 1.7 compiler.  IDEA, running under JRE 1.6 tries to link to the TEI classes inside the project output directory.  Since the TEI classes were built with 1.7, they have a class version higher than JRE 1.6 can load, the link fails and the TEI does not get executed.

My workaround is to isolate my Tag and TEI classes to its their own module, set that module to JDK 1.6 (and language level 6.0), then rebuild the project.  Now, IntelliJ running under JRE 1.6 can link to the TEI classes, which are now built with JDK 1.6.

Message was edited by: Chris Thielen

Comment actions Permalink

Thanks mate!

After firing up Idea13 with JVMVersion 1.7* in Info.plist sorts the issue!

Actually that's fine for me since the project was also for 1.7 so everything works like a charm for now...

Anyway, the issue is a bit weird methinks :-)



Please sign in to leave a comment.