Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ognl classloading issue #161

Closed
dguggi opened this issue Mar 13, 2014 · 1 comment
Closed

Ognl classloading issue #161

dguggi opened this issue Mar 13, 2014 · 1 comment

Comments

@dguggi
Copy link

dguggi commented Mar 13, 2014

We have a classloading problem with mybatis-3.2.2:

Caused by: java.lang.NullPointerException: null at org.apache.ibatis.ognl.OgnlRuntime.isInstance(OgnlRuntime.java:686) ~[mybatis-3.2.2.jar:3.2.2] at org.apache.ibatis.ognl.ASTInstanceof.getValueBody(ASTInstanceof.java:56) ~[mybatis-3.2.2.jar:3.2.2] at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170) ~[mybatis-3.2.2.jar:3.2.2]

The reason for that is that we have different/multiple classloaders in our application. By default Ognl (DefaultClassResolver) loads classes with 'Class.forName(className)', which does not work for us due to mupltiple/different classloaders.

Ognl already has support for using a custom ClassResolver. We need an implementation that loads clases using the current Thread's ContextClassLoader.
Unluckily it is not possible to provide a custom ClassResolver implementation via mybatis configuration. See org.apache.ibatis.scripting.xmltags.OgnlCache.

Currently we changed OgnlCache.getValue() like this:

// we create OgnlContext with a custom class-resolver
Map context = Ognl.createDefaultContext(root, new CustomOgnlClassResolver());
return Ognl.getValue(parseExpression(expression), context, root);

This works, but we don't really want to patch/modify mybatis like that :)

It would be great if we can provide a CustomClassResolver implementation via (mybatis) configuration.

emacarron added a commit that referenced this issue May 7, 2014
Custom ognl class resolver related to #161
@emacarron
Copy link
Member

Fixed in #193

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants