Uploaded image for project: 'Commons OGNL (Dormant)'
  1. Commons OGNL (Dormant)
  2. OGNL-13

Class loading issue with in OGNL 2.6.7+ when multiple classloaders

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.6.9, 2.6.11
    • 2.7
    • Core Runtime
    • None
    • 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)

      Attachments

        Activity

          People

            jkuhnert Jesse Kuhnert
            tim.downey Tim Downey
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: