Possible cause for "Enhancement of type ... is old and cannot be used"

#1

We get the following log:

[2015-06-08 13:07:02 #1 type.user]
Enhancement of type com.btc.ep.requirement.bl.internal.ScopeRequirementContainerImpl is old and cannot be used (1567684682299716046:-2962887009206123121)


[2015-06-08 13:07:02 #2 type]
Type com.btc.ep.requirement.bl.internal.ScopeRequirementContainerImpl is not enhanced.

[2015-06-08 13:07:02 #3 type.user]
Enhancement of type com.btc.ep.requirement.bl.internal.RequirementReferenceImpl is old and cannot be used (1519595287234187308:-2962887009206123121)


[2015-06-08 13:07:02 #4 type]
Type com.btc.ep.requirement.bl.internal.RequirementReferenceImpl is not enhanced.

We understand the reason of the messages #2 and #4 "Type ...  is not enhanced". We didn't added the package com.btc.ep.requirement.bl.internal.* to the enhancer.

But what is a possible cause for the messages #1 and #3 "Enhancement of type ... is old and cannot be used".

#2

This error message indicates that the class is enhanced, but that enhancement cannot be used because of a change that affects that class, which occurred after enhancement, e.g. adding a persistent field to a super class.

ObjectDB Support
#3

Since Feb 2016 I have been getting the error 'Enhancement of type ... is old and cannot be used' across a number of projects (both large web app project and dedicated ObjectDB test projects) since trying objectdb-2.6.6_07 (from around Jan 2016) and now also with objectdb-2.6.9 (from 2016-08-10).

I do NOT get this error with objectdb-2.6.3_04 (from around Jun 2015) on any of these projects.

In all cases I am using post-compile, pre-deployment enhancement using an Ant script, and I have taken extra care to make sure the enhancement script runs the same objectdb.jar library version that the program runs with.

I am certainly not 'adding a persistent field to a super class' in any of these cases.

I have not yet tried versions between objectdb-2.6.3_04 and objectdb-2.6.6_07 (bracketing to find which one broke it). But I know that I can't run any of my objectdb-based programs using a version later than objectdb-2.6.3_04 (other than the very basic ObjectDB points db test).

#4

This error is expected in situations as described in #2 above. If you see the error after a clean build of your entire project followed by full enhancement of all the classes, then it is an unexpected exception and probably indicates a bug in ObjectDB.

The code that throws the exception has not been changed since build 2.6.3_04, but of course it may still be affected indirectly by some other change.

Please try to isolate the error. It may be related to a specific entity hierarchy or a specific element in the definition of your entity classes.

ObjectDB Support
#5

Support wrote:

> Please try to isolate the error. It may be related to a specific entity hierarchy or a specific element in the definition of your entity classes.

I already provided a detailed description and a concise test sample for you demonstrating the problem some months ago as an issue report at:

BUG: objectdb-2.6.6_07: FAILS on @OneToMany with @TableGenerator/strategy = GenerationType.TABLE (www.objectdb.com/ticket/1823)

You had attempted to fix it in build 2.6.6_08. I reported today on investigations by version here:

http://www.objectdb.com/database/support/556?u#item-3

I repeat them also below for convenience:

It does not happen when using:

- objectdb-2.6.3_04

- objectdb-2.6.4 from 2015-10-13

It does happen when using:

- objectdb-2.6.5 from 2015-12-25 (which might indicate what was changed that caused it).

- objectdb-2.6.6 from 2016-01-27

- objectdb-2.6.9 from 2016-08-10

You wrote:

> Please try build 2.6.6_08.

Assuming the changes from build 2.6.6_08 were carried into objectdb-2.6.6 from 2016-01-27, they did not work.

#6

The issue that was reported and demonstrated by that support ticket was getting an exception with the error message "Attempt to modify a primary key of a managed object" when using a TableGenerator.

That problem was demonstrated by the provided test case, fixed in build 2.6.6_08 and then integrated into version 2.6.7 (note the version order is: 2.6.6 => 2.6.6_08 => 2.6.7, so patches as 2.6.6_08 are included in 2.6.7 rather than in 2.6.6).

This is a different issue that is not related to this forum thread.

Your log in that report also included "Enhancement of type com.greensoft.test.objectdb.entity.Element is old and cannot be used" line, but that was not the reported issue, and since that error message is specific to the way the project is built and enhanced, further instructions on how to reproduce the exception with this sample test case are needed.

When you say that you still get the 'Enhancement of type ... is old and cannot be used' in all these ObjectDB versions, is it with this specific test case? How do you build this test case project and enhance it to get the exception?

ObjectDB Support
#7

Briefly: in one simple web app test case I just established this evening that this error:

Enhancement of type com.greensoft.test.objectdb.entity.Element is old and cannot be used

only occurred (during initial persistence of a very simple entity model) when I was using the experimental mode 'objectdb.temp.no-detach'. It was completely reproducible, and only happened with recent versions of ObjectDB (at least older than objectdb-2.6.3_04), and only when I had 'objectdb.temp.no-detach' true.

When I had 'objectdb.temp.no-detach' false, I got the same error that I reported at this new issue report (and for which I provided a console test case link this evening):

Issue #1924 - ObjectDB-2.6.9: Failed to commit transaction: Failed to set numeric value of field property Element.id using reflection

However, in my main real-world web app (too large to provide here) I however definitely have 'objectdb.temp.no-detach' false and I DO still get:

"Enhancement of type com.greensoft ... .entity.Element is old and cannot be used"

I am trying to isolate it now with a dedicated test case.

#8

With objectdb-2.6.9

I have just very carefully checked it with my main (real-world) very large web app. During building of the entity model it reports twice (only) that:

Enhancement of type com.greensoft.entity.Element is old and cannot be used (1252247514539030428:4308790899156851014)

Here Element is a universal base class entity (except that it in turn inherits from a non-entity Serializable class that provides common logging services); nearly every other domain entity in the system inherits from Element.

Thereafter, it complains that nearly every other entity is not enhanced (when they clearly are, i.e. the Ant post-compile, pre-deployment enhancement task has run and reported the enhancements):

Type com.greensoft.entity.Element is not enhanced.
Info:   [2016-08-16 03:15:28 #934 type]
Type com.greensoft.entity.Element is not enhanced.
Info:   [2016-08-16 03:15:28 #935 type]
Type com.greensoft.entity.DomainElement is not enhanced.
Severe:   [2016-08-16 03:15:28 #935 type]
Type com.greensoft.entity.DomainElement is not enhanced.

...

As a side-effect it then eventually fails with:

Caused by: javax.ejb.CreateException: Initialization failed for Singleton ReflectionHelper
at com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:476)
at com.sun.ejb.containers.AbstractSingletonContainer.access$000(AbstractSingletonContainer.java:74)
at com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:647)
... 47 more
Caused by: com.objectdb.o.UserException: Failed to locate set method for field property com.greensoft.entity.value.EnumValue.oldValue using reflection

I have not managed to reproduce this yet in a smaller test app (except with the experimental "objectdb.temp.no-detach" mode, which I am NOT using currently at all in my main real-world web app).

 

 

 

 

 

#9

The bug was found and fixed in build 2.6.9_01. It can affect any application that uses property access mode.

More details are in this issue thread (see post #4).

ObjectDB Support
#10

Build 2.6.9_01 "gets further" but only fixes some cases. Please see https://www.objectdb.com/issue/1924#item-5. The initial error (with inevitable fatal side-effects) is similar (see more detailed error report at that link):

    Enhancement of type com.greensoft.entity.value.BooleanValue is old and cannot be used
...

Where BooleanValue is a generic, "deep" value-wrapper entity class.

I am working on preparing a test case app with such generic value-wrapper entity classes that demonstrates the remaining shortcomings.

Thanks for your corresponding persistence in this matter.

#11

Spawned to dedicated forum posting focussing on the generics aspects and with very careful diagnostics: objectdb-2.6.9_02 (with "objectdb.temp.no-enhancement-crc-check") vs. generic classes with interfaces: detailed investigation

Reply