[
https://issues.apache.org/jira/browse/OPENJPA-1860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12925989#action_12925989
]
Hugh commented on OPENJPA-1860:
-------------------------------
Thanks Kevin, I see the problem.
I changed my approach when I discovered the openjpa.ClassResolver plugin
property and managed to get openJPA to use my classloader to load the class I'm
interested in.
There's no need to replace the main classloader.
Yes, I'm running outside the container. I know this is not recommended by some,
but my app is simple enough to manage the EM lifecycle & OpenEJB seems like
overkill.
I'm not sure what you mean when you say a "java agent for my byte code
enhancement" but I'm using bcm which I assume is the same thing?
What I discovered was that even though the @Table annotation name value is
rewritten, it has no effect. Perhaps that's the race condition you mentioned or
perhaps the rewrite is ineffective. What I saw was this order of events I
logged:
getClassResolver(class org.apache.openjpa.jdbc.schema.DataSourceFactory, null)
getClassResolver(class org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory,
sun.misc.launcher$appclassloa...@2bbd86)
getClassResolver(class
org.apache.openjpa.persistence.jdbc.PersistenceMappingFactory,
com.agilityapplications.turret.bcm.tableclassloa...@d557c2)
getClassResolver(class org.apache.openjpa.jdbc.meta.MappingRepository,
com.agilityapplications.turret.bcm.tableclassloa...@d557c2)
Custom class com.agilityapplications.turret.jpa.QueueData to be transformed and
loaded
QueueData constructor
QueueData constructor
QueueData constructor
getClassResolver(class org.apache.openjpa.jdbc.meta.MappingRepository,
sun.misc.launcher$appclassloa...@2bbd86)
Custom class com.agilityapplications.turret.jpa.QueueData to be transformed and
loaded
QueueData constructor
I don't understand why the constructor was run 4 times before the query
actually runs or if this is related to my problem.
Should I be returning the modified Entity or should I call the classloader sent
as my getClassResolver to further modify the class?
The finish line seems so close, but remains tantalisingly out of reach.
> How do I get OpenJPA to use my custom classloader to load Entity classes?
> -------------------------------------------------------------------------
>
> Key: OPENJPA-1860
> URL: https://issues.apache.org/jira/browse/OPENJPA-1860
> Project: OpenJPA
> Issue Type: Question
> Components: jpa
> Affects Versions: 2.0.1
> Environment: OpenJPA 2.0.1 Java 1.6-22
> Reporter: Hugh
>
> I have written a custom classloader and I can't work out how to get OpenJPA
> to use it to load my entity classes.
> I've followed instructions I found to set
> Thread.currentThread().setContextClassLoader() at startup before loading any
> EntityManager and it seems to load the OpenJPA classes and a lot of others,
> but not the class I'm interested in.
> Is this the right approach?
> If so, where have I gone wrong?
> (http://openjpa.208410.n2.nabble.com/Dynamic-Table-value-td5645906.html)
> If not, how should this be done?
> Is there some sort of guide to accomplishing this that someone could point me
> to?
> Thanks.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.