You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by garpinc <ga...@yahoo.com> on 2012/07/20 14:52:40 UTC
Failing to persist a field where the type is XMLGregorianCalendar.
I'm having an issue when trying to persist a field where the type is
XMLGregorianCalendar.
I see a post here
http://vard-lokkur.blogspot.com/2011/04/jpa-and-unmodifiable-collections.html
which seems to show a similar issue.
Can anyone help me figure out what's going on here?
Getting the following exception at commit time:
java.lang.IllegalAccessError: class
org.apache.openjpa.util.org$apache$xerces$jaxp$datatype$XMLGregorianCalendarImpl$0$proxy
cannot access its superclass
org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
at serp.bytecode.BCClassLoader.findClass(BCClassLoader.java:50)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at
org.apache.openjpa.util.GeneratedClasses.loadBCClass(GeneratedClasses.java:67)
at
org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyBean(ProxyManagerImpl.java:452)
at
org.apache.openjpa.util.ProxyManagerImpl.newCustomProxy(ProxyManagerImpl.java:303)
at
org.apache.openjpa.kernel.SingleFieldManager.proxy(SingleFieldManager.java:133)
at
org.apache.openjpa.kernel.StateManagerImpl.proxyFields(StateManagerImpl.java:2921)
at
org.apache.openjpa.kernel.PNonTransState.initialize(PNonTransState.java:45)
at
org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:294)
at
org.apache.openjpa.kernel.StateManagerImpl.commit(StateManagerImpl.java:1135)
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
I already opened / fixed / closed the JIRA[1] for this issue. It should be
in the nightly trunk builds.
https://issues.apache.org/jira/browse/OPENJPA-2238
Thanks,
Rick
On Sat, Aug 4, 2012 at 10:10 AM, garpinc <ga...@yahoo.com> wrote:
> Can we post a jira associated with this so others can see the fix when it's
> available?
>
>
>
> --
--
*Rick Curtis*
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
Can we post a jira associated with this so others can see the fix when it's
available?
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580797.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
I will be on irc://irc.freenode.net/ #openjpa for the next 30 min if you
want to try to catch me in there.
Thanks,
Rick
On Fri, Jul 20, 2012 at 3:54 PM, Rick Curtis <cu...@gmail.com> wrote:
> As am I. Which jar is your
> org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl class coming from?
>
> On Fri, Jul 20, 2012 at 3:52 PM, garpinc <ga...@yahoo.com> wrote:
>
>> hmm so are you saying you're not getting an exception?
>>
>> I'm running from within eclipse if that makes a difference.
>>
>>
>>
>>
>> --
>>
>
>
>
> --
> *Rick Curtis*
>
>
--
*Rick Curtis*
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
As am I. Which jar is your
org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl class coming from?
On Fri, Jul 20, 2012 at 3:52 PM, garpinc <ga...@yahoo.com> wrote:
> hmm so are you saying you're not getting an exception?
>
> I'm running from within eclipse if that makes a difference.
>
>
>
>
> --
>
--
*Rick Curtis*
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
hmm so are you saying you're not getting an exception?
I'm running from within eclipse if that makes a difference.
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580686.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
When I run that test, I get null back from this[1] method call.
[1] emf.getConfiguration().getProxyManagerInstance().newCustomProxy(cc,
true);
On Fri, Jul 20, 2012 at 3:15 PM, garpinc <ga...@yahoo.com> wrote:
> Tracing it through it seems it's doing a Class.forName with following
> arguments:
> arg0
> "org.apache.openjpa.util.org
> $apache$xerces$jaxp$datatype$XMLGregorianCalendarImpl$proxy"
> (id=2558)
> arg1 true
> arg2 Launcher$AppClassLoader (id=48)
>
> Any idea's Rick? Or anyone..
>
>
>
>
--
*Rick Curtis*
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
Tracing it through it seems it's doing a Class.forName with following
arguments:
arg0
"org.apache.openjpa.util.org$apache$xerces$jaxp$datatype$XMLGregorianCalendarImpl$proxy"
(id=2558)
arg1 true
arg2 Launcher$AppClassLoader (id=48)
Any idea's Rick? Or anyone..
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580683.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
In fact here is a complete testcase without involving my code at all
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(new Date().getTime());
XMLGregorianCalendar cc =
DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
Properties jpaConf = new Properties();
jpaConf.put("openjpa.Id", "jpastor");
OpenJPAEntityManagerFactorySPI emf =
(OpenJPAEntityManagerFactorySPI)
Persistence.createEntityManagerFactory(jpaConf.getProperty("openjpa.Id"),
jpaConf);
emf.getConfiguration().getProxyManagerInstance().newCustomProxy(cc,
false);
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580681.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
Yep I get exception if I do following:
ReplicationJob job = ReplicationJob.adaptor(rr);
GregorianCalendar gc = new GregorianCalendar();
gc.setTimeInMillis(new Date().getTime());
XMLGregorianCalendar cc =
DatatypeFactory.newInstance().newXMLGregorianCalendar(gc);
OpenJPAEntityManagerFactorySPI emf =
(OpenJPAEntityManagerFactorySPI) getEmf();
emf.getConfiguration().getProxyManagerInstance().newCustomProxy(cc,
false);
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580680.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
Honestly, I haven't had time to try to run with your customer handlers...
I have been looking ProxyManager code and trying to recreate the initial
stack you posted. Here is a small test you can run to see where it is
blowing up:
XMLGregorianCalendar cc = null; // instantiate me!
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
getEmf();
emf.getConfiguration().getProxyManagerInstance().newCustomProxy(cc, false);
// this line should fail for you
I haven't been able to recreate the failure on my machine because
org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl is a final class
and org.apache.openjpa.util.ProxyManagerImpl<eclipse-javadoc:%E2%98%82=openjpa-kernel/src%5C/main%5C/java%3Corg.apache.openjpa.util%7BProxyManagerImpl.java%E2%98%83ProxyManagerImpl>.generateProxyBeanBytecode(...)
skips trying to create a custom proxy for final types.
Thanks,
Rick
On Fri, Jul 20, 2012 at 1:33 PM, garpinc <ga...@yahoo.com> wrote:
> It could be that I didn't implement the AbstractValueHandler correctly. The
> api changed from 2.1.2 to 2.2.. now when I restest on 2.1.2 it doesn't work
> where it did before.. Please see if you think they are correct.. In the
> meantime i'll revert to 2.1.2 and put AbstractValueHandler back to how they
> were to see if it then magically works again
>
>
>
> --
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>
--
*Rick Curtis*
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
It could be that I didn't implement the AbstractValueHandler correctly. The
api changed from 2.1.2 to 2.2.. now when I restest on 2.1.2 it doesn't work
where it did before.. Please see if you think they are correct.. In the
meantime i'll revert to 2.1.2 and put AbstractValueHandler back to how they
were to see if it then magically works again
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580677.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
2.2.0 but I just verified I have the same issue on 2.1.2-SNAPSHOT as well
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580676.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
I should have asked this before, but what version of OpenJPA are you
running?
Thanks,
Rick
On Fri, Jul 20, 2012 at 12:09 PM, garpinc <ga...@yahoo.com> wrote:
> here are the 2 classes involved in the annotation
> package com.cambridgesemantics.anzo.relationalreplicator.openjpaplugin;
>
> import javax.xml.datatype.DatatypeConfigurationException;
> import javax.xml.datatype.DatatypeFactory;
>
> import org.apache.openjpa.jdbc.kernel.JDBCStore;
> import org.apache.openjpa.jdbc.meta.ValueMapping;
> import org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler;
>
> public abstract class XGCAbstractValueHandler extends AbstractValueHandler
> {
> @Override
> public Object toObjectValue(ValueMapping vm, Object val) {
> if (val == null)
> return null;
> try {
> return
> DatatypeFactory.newInstance().newXMLGregorianCalendar(val.toString());
> } catch (DatatypeConfigurationException e) {
> e.printStackTrace();
> return null;
> }
> }
>
> @Override
> public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore
> store) {
> if (val == null || !(val instanceof
> javax.xml.datatype.XMLGregorianCalendar))
> return null;
>
> javax.xml.datatype.XMLGregorianCalendar date =
> (javax.xml.datatype.XMLGregorianCalendar) val;
> return date.toGregorianCalendar().getTime();
> }
>
> }
>
>
> package com.cambridgesemantics.anzo.relationalreplicator.openjpaplugin;
>
> import org.apache.openjpa.jdbc.identifier.DBIdentifier;
> import org.apache.openjpa.jdbc.meta.ValueMapping;
> import org.apache.openjpa.jdbc.schema.Column;
> import org.apache.openjpa.jdbc.schema.ColumnIO;
> import org.apache.openjpa.jdbc.sql.DBDictionary;
> import org.apache.openjpa.meta.JavaTypes;
>
> public class XGCTimestampValueHandler extends XGCAbstractValueHandler {
>
> private static final XGCTimestampValueHandler _instance = new
> XGCTimestampValueHandler();
>
> /**
> * Singleton instance.
> */
> public static XGCTimestampValueHandler getInstance() {
> return _instance;
> }
>
> @Deprecated
> @Override
> public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean
> adapt) {
> DBDictionary dict = vm.getMappingRepository().getDBDictionary();
> DBIdentifier colName = DBIdentifier.newColumn(name, dict != null ?
> dict.delimitAll() : false);
> return map(vm, colName, io, adapt);
> }
>
> public Column[] map(ValueMapping vm, DBIdentifier name, ColumnIO io,
> boolean adapt) {
> Column col = new Column();
> col.setIdentifier(name);
> col.setJavaType(JavaTypes.DATE);
> col.setType(java.sql.Types.TIMESTAMP);
> return new Column[] { col };
> }
>
> }
>
>
>
>
> --
>
>
--
*Rick Curtis*
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
here are the 2 classes involved in the annotation
package com.cambridgesemantics.anzo.relationalreplicator.openjpaplugin;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import org.apache.openjpa.jdbc.kernel.JDBCStore;
import org.apache.openjpa.jdbc.meta.ValueMapping;
import org.apache.openjpa.jdbc.meta.strats.AbstractValueHandler;
public abstract class XGCAbstractValueHandler extends AbstractValueHandler {
@Override
public Object toObjectValue(ValueMapping vm, Object val) {
if (val == null)
return null;
try {
return
DatatypeFactory.newInstance().newXMLGregorianCalendar(val.toString());
} catch (DatatypeConfigurationException e) {
e.printStackTrace();
return null;
}
}
@Override
public Object toDataStoreValue(ValueMapping vm, Object val, JDBCStore
store) {
if (val == null || !(val instanceof
javax.xml.datatype.XMLGregorianCalendar))
return null;
javax.xml.datatype.XMLGregorianCalendar date =
(javax.xml.datatype.XMLGregorianCalendar) val;
return date.toGregorianCalendar().getTime();
}
}
package com.cambridgesemantics.anzo.relationalreplicator.openjpaplugin;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
import org.apache.openjpa.jdbc.meta.ValueMapping;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.ColumnIO;
import org.apache.openjpa.jdbc.sql.DBDictionary;
import org.apache.openjpa.meta.JavaTypes;
public class XGCTimestampValueHandler extends XGCAbstractValueHandler {
private static final XGCTimestampValueHandler _instance = new
XGCTimestampValueHandler();
/**
* Singleton instance.
*/
public static XGCTimestampValueHandler getInstance() {
return _instance;
}
@Deprecated
@Override
public Column[] map(ValueMapping vm, String name, ColumnIO io, boolean
adapt) {
DBDictionary dict = vm.getMappingRepository().getDBDictionary();
DBIdentifier colName = DBIdentifier.newColumn(name, dict != null ?
dict.delimitAll() : false);
return map(vm, colName, io, adapt);
}
public Column[] map(ValueMapping vm, DBIdentifier name, ColumnIO io,
boolean adapt) {
Column col = new Column();
col.setIdentifier(name);
col.setJavaType(JavaTypes.DATE);
col.setType(java.sql.Types.TIMESTAMP);
return new Column[] { col };
}
}
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580674.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is
XMLGregorianCalendar.
Posted by garpinc <ga...@yahoo.com>.
@org.apache.openjpa.persistence.Persistent(fetch =
javax.persistence.FetchType.LAZY)
@org.apache.openjpa.persistence.jdbc.Strategy("com.cambridgesemantics.anzo.relationalreplicator.openjpaplugin.XGCTimestampValueHandler")
public javax.xml.datatype.XMLGregorianCalendar getExpiryDate() throws
org.openanzo.rdf.jastor.JastorException {
--
View this message in context: http://openjpa.208410.n2.nabble.com/Failing-to-persist-a-field-where-the-type-is-XMLGregorianCalendar-tp7580665p7580672.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.
Re: Failing to persist a field where the type is XMLGregorianCalendar.
Posted by Rick Curtis <cu...@gmail.com>.
How are you annotating the XMLGregorianCalendar field in your Entity to be
persistent?
Thanks,
Rick
On Fri, Jul 20, 2012 at 7:52 AM, garpinc <ga...@yahoo.com> wrote:
> I'm having an issue when trying to persist a field where the type is
> XMLGregorianCalendar.
>
> I see a post here
>
> http://vard-lokkur.blogspot.com/2011/04/jpa-and-unmodifiable-collections.html
> which seems to show a similar issue.
>
> Can anyone help me figure out what's going on here?
>
> Getting the following exception at commit time:
> java.lang.IllegalAccessError: class
> org.apache.openjpa.util.org
> $apache$xerces$jaxp$datatype$XMLGregorianCalendarImpl$0$proxy
> cannot access its superclass
> org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
> at serp.bytecode.BCClassLoader.findClass(BCClassLoader.java:50)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:247)
> at
>
> org.apache.openjpa.util.GeneratedClasses.loadBCClass(GeneratedClasses.java:67)
> at
>
> org.apache.openjpa.util.ProxyManagerImpl.getFactoryProxyBean(ProxyManagerImpl.java:452)
> at
>
> org.apache.openjpa.util.ProxyManagerImpl.newCustomProxy(ProxyManagerImpl.java:303)
> at
>
> org.apache.openjpa.kernel.SingleFieldManager.proxy(SingleFieldManager.java:133)
> at
>
> org.apache.openjpa.kernel.StateManagerImpl.proxyFields(StateManagerImpl.java:2921)
> at
> org.apache.openjpa.kernel.PNonTransState.initialize(PNonTransState.java:45)
> at
>
> org.apache.openjpa.kernel.StateManagerImpl.setPCState(StateManagerImpl.java:294)
> at
>
> org.apache.openjpa.kernel.StateManagerImpl.commit(StateManagerImpl.java:1135)
>
>
>
> --
>
--
*Rick Curtis*