196 words

Enhancement API - NullPointerException

#1
2017-10-08 00:14

Hi!

I am trying to use the Enhancement API from within my application like this:

com.objectdb.Enhancer.enhance("my.package.Foo");

However, I get the following NullPointerException:

[ObjectDB 2.7.1_09] null
java.lang.NullPointerException
        at com.objectdb.o.JER.f(JER.java:96)
        at com.objectdb.o.JEL.D(JEL.java:490)
        at com.objectdb.o.JEN.m(JEN.java:103)
        at com.objectdb.Enhancer.enhance(Enhancer.java:69)
        at com.objectdb.Enhancer.enhance(Enhancer.java:90)
        at my.package.Main.main(Main.java:34)

I checked the logs, but there is no more information than what is also printed to the console (see error above). I'm not sure what is happening, the class exists and trying the API with a non-existent class gives me the expected "is not found by the enhancer" error instead of this NullPointerException.

It seems to be similar to this issue: http://www.objectdb.com/database/issue/82

 

 

rroels
rroels's picture
Joined on 2017-08-10
User Post #1
#2
2017-10-08 11:57

Are you trying to enhance classes that are packed in a jar file?

On the fly enhancement by calling com.objectdb.Enhancer.enhance(...) is only supported for classes in separate class files rather in jar files.

If this is the case, a better error message should be shown of course.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,840
#3
2017-10-08 12:03

That was indeed the case, the classes were in a JAR file. Thank you for the quick reply!

rroels
rroels's picture
Joined on 2017-08-10
User Post #2

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel