openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MikoĊ‚aj Gierulski" <mikolaj.gierul...@javatech.com.pl>
Subject Using custom ValueHandler
Date Fri, 11 Apr 2008 14:39:49 GMT
Hello,
I am trying to use a custom ValueHandler to map custom objects to columns.
I have implemented a class
pl.com.agora.testcase.valuehandler.ConfigurationOptionValueHandler
extends org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler

In my entities I use it as follows:
    @Persistent
    @Column(name = "OPTION")
    @Strategy("pl.com.agora.testcase.valuehandler.ConfigurationOptionValueHandler")
    private ConfigurationOption option;

The problem is, an org.apache.openjpa.persistence.ArgumentException is
thrown on the first attempt to access the entity, where the root of
the problem is:

org.apache.openjpa.persistence.ArgumentException:
"pl.com.agora.testcase.entity.TestEntity.option" declared custom value
handler "pl.com.agora.testcase.valuehandler.ConfigurationOptionValueHandler",
but this handler cannot be instantiated.
	at org.apache.openjpa.jdbc.meta.MappingRepository.namedHandler(MappingRepository.java:949)
	at org.apache.openjpa.jdbc.meta.MappingRepository.defaultStrategy(MappingRepository.java:712)
	at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:62)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:438)
	at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:403)
	at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:823)
	at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:319)
	at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:605)
	at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:492)
	... 83 more
Caused by: <1.0.0 fatal user error>
org.apache.openjpa.persistence.ArgumentException: The class name
"pl.com.agora.testcase.valuehandler.ConfigurationOptionValueHandler"
used in a metadata extension on field
"pl.com.agora.testcase.entity.TestEntity.option" is not valid.
	at org.apache.openjpa.meta.JavaTypes.classForName(JavaTypes.java:227)
	at org.apache.openjpa.meta.JavaTypes.classForName(JavaTypes.java:194)
	at org.apache.openjpa.jdbc.meta.MappingRepository.namedHandler(MappingRepository.java:939)
	... 91 more

I did some debugging and found out, that the problem seems to be, that
the method
org.apache.openjpa.lib.meta.CFMetaDataParser.classForName(String name,
String pkg, boolean resolve, ClassLoader loader)
called by
org.apache.openjpa.meta.JavaTypes.classForName(String name,
ClassMetaData meta, Class dec, ValueMetaData vmd, ClassLoader loader)

returns null instead of my ConfigurationOptionValueHandler class.

If I call this method from within my application though, with
classloader set to null and other arguments the same, it works
properly and returns desired class.

I am using bea weblogic 10.0.1 with openjpa 1.0.0
The ConfigurationOptionValueHandler class is located in the same jar
file, as the TestEntity class.
This jar file is located in a lib folder of a war installed as a
library on the server.
My application is also installed as a war and depends on that library.

My guess is the value handler should be located somewhere else, but I
don't know where this should be.

Any suggestions will be much appreciated.

Best regards,
Mikolaj.

Mime
View raw message