Commons OGNL
  1. Commons OGNL
  2. OGNL-13

Class loading issue with in OGNL 2.6.7+ when multiple classloaders

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.6.9, 2.6.11
    • Fix Version/s: 2.7
    • Component/s: Core Runtime
    • Labels:
      None
    • Environment:
      Java 1.6, Windows, JBoss

      Description

      Hi,

      With some help from Jesse, I've tracked down a classloading issue with OGNL 2.6.7+. When evaluating expressions in an environment with multiple classloaders, NullPointerExceptions can occur if OGNL is configured to use the incorrect classloader when evaluating expressions.

      In my environment, I have a WAR classloader and the unified classloader from JBoss. If I attempt to evaluate an expression against an object loaded by the unified classloader that attempts to refer to a class managed by the WAR classloader, I get a NullPointerException.

      It would be nice if OGNL would throw a ClassNotFoundException when Ognl.getValue() fails to load a class rather than a NPE. Below is the trace that occurs when the expression attempts to load a class that can't be found in

      the attempted classloader.

      FWIW, following Jesse's directions I was able to use a custom resolver ala Tapestry to solve my issue. Here's a reference to that.

      http://svn.apache.org/viewvc/tapestry/tapestry4/tags/4.0.2/framework/src/java/org/apache/tapestry/services/impl/ExpressionEvaluatorImpl.java?view=markup

      [java] 14:23:01,480 ERROR [STDERR] java.lang.NullPointerException

      [java] 14:23:01,480 ERROR [STDERR] at ognl.OgnlRuntime$ClassCache.get(OgnlRuntime.java:144)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.OgnlRuntime.getHandler(OgnlRuntime.java:1551)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.OgnlRuntime.getMethodAccessor(OgnlRuntime.java:1494)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.OgnlRuntime.callStaticMethod(OgnlRuntime.java:804)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.ASTStaticMethod.getValueBody(ASTStaticMethod.java:67)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

      [java] 14:23:01,480 ERROR [STDERR] at ognl.SimpleNode.getValue(SimpleNode.java:210)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.ASTChain.getValueBody(ASTChain.java:109)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.SimpleNode.getValue(SimpleNode.java:210)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:333)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:413)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:454)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:433)

      [java] 14:23:01,527 ERROR [STDERR] at com.workscape.oneforce.web.component.employeedetails.EmployeeDetails.getValue(E mployeeDetails.java:96)

      [java] 14:23:01,527 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor967.invoke(Unknown Source)

      [java] 14:23:01,527 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja va:25)

      [java] 14:23:01,527 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:597)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:491)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.OgnlRuntime.getMethodValue(OgnlRuntime.java:904)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.ObjectPropertyAccessor.getPossibleProperty(ObjectPropertyAccessor.java:54)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.ObjectPropertyAccessor.getProperty(ObjectPropertyAccessor.java:122)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1616)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.ASTProperty.getValueBody(ASTProperty.java:96)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.SimpleNode.getValue(SimpleNode.java:210)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:333)

      [java] 14:23:01,527 ERROR [STDERR] at ognl.Ognl.getValue(Ognl.java:310)

      [java] 14:23:01,527 ERROR [STDERR] at org.apache.tapestry.services.impl.ExpressionEvaluatorImpl.readCompiled(Expressi onEvaluatorImpl.java:91)

      [java] 14:23:01,527 ERROR [STDERR] at $ExpressionEvaluator_111298ac296.readCompiled($ExpressionEvaluator_111298ac296. java)

      [java] 14:23:01,527 ERROR [STDERR] at org.apache.tapestry.binding.ExpressionBinding.resolveExpression(ExpressionBindi ng.java:110)

      [java] 14:23:01,527 ERROR [STDERR] at org.apache.tapestry.binding.ExpressionBinding.getObject(ExpressionBinding.java: 103)

      [java] 14:23:01,527 ERROR [STDERR] at org.apache.tapestry.binding.AbstractBinding.getObject(AbstractBinding.java:87)

      [java] 14:23:01,527 ERROR [STDERR] at $Insert_1715.getValue($Insert_1715.java)

        Activity

        Tim Downey created issue -
        Jesse Kuhnert made changes -
        Field Original Value New Value
        Component/s Core Runtime [ 21251 ]
        Fix Version/s 2.7 [ 21688 ]
        Jesse Kuhnert made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Tony Stevenson made changes -
        Project Import Mon Jun 18 09:00:45 UTC 2012 [ 1340010045016 ]

          People

          • Assignee:
            Jesse Kuhnert
            Reporter:
            Tim Downey
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development