You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Igor Naumov (JIRA)" <ji...@apache.org> on 2006/06/12 22:31:29 UTC

[jira] Created: (COCOON-1861) Check for Null URI in LDAPTransformer

Check for Null URI in LDAPTransformer
-------------------------------------

         Key: COCOON-1861
         URL: http://issues.apache.org/jira/browse/COCOON-1861
     Project: Cocoon
        Type: Bug

  Components: Blocks: Naming  
    Versions: 2.1.8, 2.1.9    
    Reporter: Igor Naumov
    Priority: Minor


In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
A simple fix is to add a check for NULL URI and just pass through that element:

     public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
+        if (uri == null) {
+            super.startElement(uri, name, raw, attributes);
+            return;
+        }
         if (!uri.equals(my_uri)) {
             super.startElement(uri, name, raw, attributes);
             return;



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Antonio Gallardo reassigned COCOON-1861:
----------------------------------------

    Assign To: Antonio Gallardo

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Assignee: Antonio Gallardo
>     Priority: Minor
>      Fix For: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
>  Attachments: LDAP stacktrace.htm, authenticateLDAP.xml
>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Antonio Gallardo reassigned COCOON-1861:
----------------------------------------

    Assign To: Antonio Gallardo

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Assignee: Antonio Gallardo
>     Priority: Minor

>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1861?page=comments#action_12416453 ] 

Antonio Gallardo commented on COCOON-1861:
------------------------------------------

Would you post the full stacktrace of the exception? I just wonder why nobody else complains for this error.

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor

>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Antonio Gallardo updated COCOON-1861:
-------------------------------------


Did you tested the patch? I have few questions:

1- What happens when the uri is null? I am asking because code code will call:

super.startElement(uri, name, raw, attributes);

2- What happens when this element end? Because the element must emit and endElement call defined in line 795:

endElement(String uri, String name, String raw)

Can be in this case uri == null? If yes, do we need a similar fix?

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Assignee: Antonio Gallardo
>     Priority: Minor

>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Closed: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]
     
Antonio Gallardo closed COCOON-1861:
------------------------------------

    Fix Version: 2.2-dev (Current SVN)
                 2.1.10-dev (current SVN)
     Resolution: Fixed

Thanks for the patch. It was applied with minor changes. Feel free to reopen this issue if needed.

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor
>      Fix For: 2.2-dev (Current SVN), 2.1.10-dev (current SVN)
>  Attachments: LDAP stacktrace.htm, authenticateLDAP.xml
>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Igor Naumov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1861?page=comments#action_12416462 ] 

Igor Naumov commented on COCOON-1861:
-------------------------------------

I attached the stacktrace (from Cocoon 2.1.9 running on Tomcat 5 - so it's not just SAP NetWeaver) and a sample XML that I apply the LDAP transformer to. 
Let me explain a little bit what I am doing with LDAP. In the authentication pipeline I first collect some parameters with aggregate, then apply an XSL to it to produce an ldap:execute-query element (while still leaving some elements outside of the ldap query), and then apply the LDAP transformer.
With the unpatched code it fails on LDAP transformation with NullPointer.
However with a patch (only to startElement method) everything works just fine. Seems like standalone Cocoon does not have that problem, so it depends on a J2EE server. If I remember correctly, we did not have that issue with WebSphere.

I think the reason nobody complained about it is that there are several factors that needs to be present:
- Using LDAP to begin with - not everyone, I guess
- Using additional elements without a namespace in LDAP query - not the best practice as well (not having a namespace).
- Using particular J2EE server
- Potentially the fact that I apply XSLT before applying LDAP transformation - the URI may be affected by that as well.

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor
>  Attachments: LDAP stacktrace.htm, authenticateLDAP.xml
>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Igor Naumov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Igor Naumov updated COCOON-1861:
--------------------------------

    Attachment: LDAP stacktrace.htm

This is a stacktrace from a simplified pipeline including LDAP transformer. I had to remove some path references for security reasons - sorry...

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor
>  Attachments: LDAP stacktrace.htm
>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Igor Naumov (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/COCOON-1861?page=comments#action_12416452 ] 

Igor Naumov commented on COCOON-1861:
-------------------------------------

I actually did test the patch exactly as I described.
The problem occurs when the source for LDAP transformer has elements without a namespace. For some reason my J2EE server (SAP NetWeaver) passes the uri as null and uri.equal obviously returns a NullPointer exception. 
Apparently super.StartElement is more tolerant to a null URI, so the element is just copied to the output without any action in the transformer.
I can run some more checks to see what exactly happens.

I agree that logically there should be a similar fix in the endElement. I overlooked it (probably because just the fix in the endElement worked).
I think the whole problem is caused by some faulty behaviour of the J2EE server. But I am not good at Java, so I would rely on your judgement. 
In general, is is safe to assume that the parameter declared as String would not be null?


> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor

>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Assigned: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Antonio Gallardo (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Antonio Gallardo reassigned COCOON-1861:
----------------------------------------

    Assign To:     (was: Antonio Gallardo)

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor

>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Updated: (COCOON-1861) Check for Null URI in LDAPTransformer

Posted by "Igor Naumov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/COCOON-1861?page=all ]

Igor Naumov updated COCOON-1861:
--------------------------------

    Attachment: authenticateLDAP.xml

This is a sample XML that I feed to the LDAP transformer that causes the NullPointerException

> Check for Null URI in LDAPTransformer
> -------------------------------------
>
>          Key: COCOON-1861
>          URL: http://issues.apache.org/jira/browse/COCOON-1861
>      Project: Cocoon
>         Type: Bug

>   Components: Blocks: Naming
>     Versions: 2.1.8, 2.1.9
>     Reporter: Igor Naumov
>     Priority: Minor
>  Attachments: LDAP stacktrace.htm, authenticateLDAP.xml
>
> In the LDAPTransformer.java (src\blocks\naming\java\org\apache\cocoon\transformation\LDAPTransformer.java) the URI is not checked for NULL.
> On some J2EE servers (SAP NetWeaver) the URI passed may be NULL and it causes a NullPointerException.
> A simple fix is to add a check for NULL URI and just pass through that element:
>      public void startElement(String uri, String name, String raw, Attributes attributes) throws SAXException {
> +        if (uri == null) {
> +            super.startElement(uri, name, raw, attributes);
> +            return;
> +        }
>          if (!uri.equals(my_uri)) {
>              super.startElement(uri, name, raw, attributes);
>              return;

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira