You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Krzysztof <ya...@gmail.com> on 2011/05/06 11:43:29 UTC

Proxy of custom strategy nullifies all its fields - was: XMLValueHandler strategy not supported in Postgres?

Hi Milosz,
Thanks for the hints.
Actually I was too quick with reporting success: storing xml works
perfectly, but retrieval is broken.

I can see that even my XMLValueHandler returns proper unmarshaled object,
all fields are nullified by MyTypeHoldingXML.pcReplaceField(int) of the xml
field.
This happens both on detachement/commit and retrieval - I can see object is
replaced with a proxy that has all values null.


Thread [main] (Suspended (breakpoint at line 2201 in StateManagerImpl))	
	StateManagerImpl.replaceObjectField(PersistenceCapable, int) line: 2201	
	Run&lt;INPUT,OUTPUT&gt;.pcReplaceField(int) line: not available
<-------this nullifies XML field by creating proxy with all fields being
null
	StateManagerImpl.replaceField(PersistenceCapable, FieldManager, int) line:
3161	
	StateManagerImpl.storeObjectField(int, Object) line: 2596	
	StateManagerImpl.storeField(int, Object, FieldManager) line: 2692	
	StateManagerImpl.storeField(int, Object) line: 875	
	StateManagerImpl.store(int, Object) line: 871	
	HandlerFieldStrategy.load(OpenJPAStateManager, JDBCStore,
JDBCFetchConfiguration, Result) line: 189	
	FieldMapping.load(OpenJPAStateManager, JDBCStore, JDBCFetchConfiguration,
Result) line: 928	
	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
JDBCFetchConfiguration, Result, FieldMapping) line: 1123	
	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
JDBCFetchConfiguration, Result) line: 1067	
	JDBCStoreManager.initializeState(OpenJPAStateManager, PCState,
JDBCFetchConfiguration, ConnectionInfo) line: 438	
	JDBCStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 333	

DataCacheStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
PCState, FetchConfiguration, Object) line: 112	
	DataCacheStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 360	
	ROPStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
PCState, FetchConfiguration, Object) line: 112	
	ROPStoreManager.initialize(OpenJPAStateManager, PCState,
FetchConfiguration, Object) line: 57	
	FinalizingBrokerImpl(BrokerImpl).initialize(StateManagerImpl, boolean,
FetchConfiguration, Object) line: 1022	
	FinalizingBrokerImpl(BrokerImpl).find(Object, FetchConfiguration, BitSet,
Object, int, FindCallbacks) line: 980	
	FinalizingBrokerImpl(BrokerImpl).find(Object, boolean, FindCallbacks) line:
897	
	DelegatingBroker.find(Object, boolean, FindCallbacks) line: 223	
	EntityManagerImpl.find(Class<T>, Object) line: 478	
	


I will create Jira but this is quite urgent so would appreciate any
suggestions..
Best regards,
Krzysztof

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337026.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields -was:XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Yes indeed!
What is interesting it was enough to just add setters to the root object,
all nested levels are populated properly.

Big thanks for the hints!

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337408.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields -was:XMLValueHandler strategy not supported in Postgres?

Posted by Miłosz Tylenda <mt...@o2.pl>.
Krzysztof,

I think the missing setters is the problem even if you use XmlAccessType.FIELD. Add the setters and try it. You can also check what happens if you switch to XmlAccessType.PROPERTY. The user manual mentions some JAXB plugins which could generate setters [1].

Milosz

[1] http://openjpa.apache.org/builds/latest/docs/manual/manual.html#ref_guide_xmlmapping

> Milosz,
> Will try now with 8.3jdbc3 that is included with openjpa. I have been using
> jdbc4 for a while without any problems (no XML however). 
> 
> JAXB classes use @XmlAccessorType(XmlAccessType.FIELD) everywhere - so there
> are getters, no setters. Do you think this could be a problem?
> 
> I tried to test the snapshot sources with PG9 but it did not build for me,
> some problem with openbooks example (tried on OSX).
> 
> ...
> [INFO] OpenJPA JEST ...................................... SUCCESS [1.771s]
> [INFO] OpenJPA Aggregate Jar ............................. SUCCESS [6.712s]
> [INFO] OpenJPA Aggregate Jar with Dependencies ........... SUCCESS [3.900s]
> [INFO] OpenJPA Project Docs and Assemblies ............... SUCCESS [25.596s]
> [INFO] OpenJPA Examples .................................. SUCCESS [0.061s]
> [INFO] OpenJPA Examples - Simple ......................... SUCCESS [1.174s]
> [INFO] OpenJPA Examples - image-gallery .................. SUCCESS [1.802s]
> [INFO] OpenJPA Examples - OpenBooks ...................... FAILURE [0.424s]
> [INFO] OpenJPA Integration Tests ......................... SKIPPED
> [INFO] OpenJPA Integration Tests - Daytrader ............. SKIPPED
> [INFO] OpenJPA Integration Tests - Examples .............. SKIPPED
> [INFO] OpenJPA Integration Tests - SLF4JLogFactory ....... SKIPPED
> [INFO] OpenJPA Integration Tests - JPA TCK ............... SKIPPED
> [INFO] OpenJPA Integration Tests - Bean Validation ....... SKIPPED
> [INFO] OpenJPA Integration Tests - JMX Platform MBeans ... SKIPPED
> [INFO] OpenJPA tools ..................................... SKIPPED
> [INFO] OpenJPA Maven Plugin .............................. SKIPPED
> [INFO]
> ------------------------------------------------------------------------
> [INFO] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] Total time: 2:25.570s
> [INFO] Finished at: Fri May 06 13:04:43 CEST 2011
> [INFO] Final Memory: 49M/240M
> [INFO]
> ------------------------------------------------------------------------
> [ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-antrun-plugin:1.3:run (genmodel) on project
> openbooks: An Ant BuildException has occured: The following error occurred
> while executing this line:
> [ERROR]
> /Users/knienart/gaia/openjpa/openjpa-examples/openbooks/build.xml:116: ***
> Error:
> [ERROR] The directory for OpenJPA libraries can not be located at
> /Users/knienart/.m2/repository/org/apache/openjpa/openjpa-all/2.2.0-SNAPSHOT.
> [ERROR] Make sure openjpa.lib property value is correct in build.properties
> file.
> [ERROR] -> [Help 1]
> [ERROR] 
> [ERROR] To see the full stack trace of the errors, re-run Maven with the -e
> switch.
> [ERROR] Re-run Maven using the -X switch to enable full debug logging.
> [ERROR] 
> [ERROR] For more information about the errors and possible solutions, please
> read the following articles:
> [ERROR] [Help 1]
> http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
> [ERROR] 
> [ERROR] After correcting the problems, you can resume the build with the
> command
> [ERROR]   mvn <goals> -rf :openbooks
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337236.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
> 

Re: Proxy of custom strategy nullifies all its fields - was:XMLValueHandler strategy not supported in Postgres?

Posted by Krzysztof <ya...@gmail.com>.
Milosz,
Will try now with 8.3jdbc3 that is included with openjpa. I have been using
jdbc4 for a while without any problems (no XML however). 

JAXB classes use @XmlAccessorType(XmlAccessType.FIELD) everywhere - so there
are getters, no setters. Do you think this could be a problem?

I tried to test the snapshot sources with PG9 but it did not build for me,
some problem with openbooks example (tried on OSX).

...
[INFO] OpenJPA JEST ...................................... SUCCESS [1.771s]
[INFO] OpenJPA Aggregate Jar ............................. SUCCESS [6.712s]
[INFO] OpenJPA Aggregate Jar with Dependencies ........... SUCCESS [3.900s]
[INFO] OpenJPA Project Docs and Assemblies ............... SUCCESS [25.596s]
[INFO] OpenJPA Examples .................................. SUCCESS [0.061s]
[INFO] OpenJPA Examples - Simple ......................... SUCCESS [1.174s]
[INFO] OpenJPA Examples - image-gallery .................. SUCCESS [1.802s]
[INFO] OpenJPA Examples - OpenBooks ...................... FAILURE [0.424s]
[INFO] OpenJPA Integration Tests ......................... SKIPPED
[INFO] OpenJPA Integration Tests - Daytrader ............. SKIPPED
[INFO] OpenJPA Integration Tests - Examples .............. SKIPPED
[INFO] OpenJPA Integration Tests - SLF4JLogFactory ....... SKIPPED
[INFO] OpenJPA Integration Tests - JPA TCK ............... SKIPPED
[INFO] OpenJPA Integration Tests - Bean Validation ....... SKIPPED
[INFO] OpenJPA Integration Tests - JMX Platform MBeans ... SKIPPED
[INFO] OpenJPA tools ..................................... SKIPPED
[INFO] OpenJPA Maven Plugin .............................. SKIPPED
[INFO]
------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 2:25.570s
[INFO] Finished at: Fri May 06 13:04:43 CEST 2011
[INFO] Final Memory: 49M/240M
[INFO]
------------------------------------------------------------------------
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.3:run (genmodel) on project
openbooks: An Ant BuildException has occured: The following error occurred
while executing this line:
[ERROR]
/Users/knienart/gaia/openjpa/openjpa-examples/openbooks/build.xml:116: ***
Error:
[ERROR] The directory for OpenJPA libraries can not be located at
/Users/knienart/.m2/repository/org/apache/openjpa/openjpa-all/2.2.0-SNAPSHOT.
[ERROR] Make sure openjpa.lib property value is correct in build.properties
file.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please
read the following articles:
[ERROR] [Help 1]
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the
command
[ERROR]   mvn <goals> -rf :openbooks

--
View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337236.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Proxy of custom strategy nullifies all its fields - was:XMLValueHandler strategy not supported in Postgres?

Posted by Miłosz Tylenda <mt...@o2.pl>.
Krzysztof,

Did you try your case with OpenJPA-provided XMLValueHandler and a JDBC driver from 8.x line?

Does your JAXB entity have setters for all persistent fields and collections?

Cheers,
Milosz


> Hi Milosz,
> Thanks for the hints.
> Actually I was too quick with reporting success: storing xml works
> perfectly, but retrieval is broken.
> 
> I can see that even my XMLValueHandler returns proper unmarshaled object,
> all fields are nullified by MyTypeHoldingXML.pcReplaceField(int) of the xml
> field.
> This happens both on detachement/commit and retrieval - I can see object is
> replaced with a proxy that has all values null.
> 
> 
> Thread [main] (Suspended (breakpoint at line 2201 in StateManagerImpl))	
> 	StateManagerImpl.replaceObjectField(PersistenceCapable, int) line: 2201	
> 	Run&lt;INPUT,OUTPUT&gt;.pcReplaceField(int) line: not available
> <-------this nullifies XML field by creating proxy with all fields being
> null
> 	StateManagerImpl.replaceField(PersistenceCapable, FieldManager, int) line:
> 3161	
> 	StateManagerImpl.storeObjectField(int, Object) line: 2596	
> 	StateManagerImpl.storeField(int, Object, FieldManager) line: 2692	
> 	StateManagerImpl.storeField(int, Object) line: 875	
> 	StateManagerImpl.store(int, Object) line: 871	
> 	HandlerFieldStrategy.load(OpenJPAStateManager, JDBCStore,
> JDBCFetchConfiguration, Result) line: 189	
> 	FieldMapping.load(OpenJPAStateManager, JDBCStore, JDBCFetchConfiguration,
> Result) line: 928	
> 	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
> JDBCFetchConfiguration, Result, FieldMapping) line: 1123	
> 	JDBCStoreManager.load(ClassMapping, OpenJPAStateManager,
> JDBCFetchConfiguration, Result) line: 1067	
> 	JDBCStoreManager.initializeState(OpenJPAStateManager, PCState,
> JDBCFetchConfiguration, ConnectionInfo) line: 438	
> 	JDBCStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 333	
> 
> DataCacheStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
> PCState, FetchConfiguration, Object) line: 112	
> 	DataCacheStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 360	
> 	ROPStoreManager(DelegatingStoreManager).initialize(OpenJPAStateManager,
> PCState, FetchConfiguration, Object) line: 112	
> 	ROPStoreManager.initialize(OpenJPAStateManager, PCState,
> FetchConfiguration, Object) line: 57	
> 	FinalizingBrokerImpl(BrokerImpl).initialize(StateManagerImpl, boolean,
> FetchConfiguration, Object) line: 1022	
> 	FinalizingBrokerImpl(BrokerImpl).find(Object, FetchConfiguration, BitSet,
> Object, int, FindCallbacks) line: 980	
> 	FinalizingBrokerImpl(BrokerImpl).find(Object, boolean, FindCallbacks) line:
> 897	
> 	DelegatingBroker.find(Object, boolean, FindCallbacks) line: 223	
> 	EntityManagerImpl.find(Class<T>, Object) line: 478	
> 	
> 
> 
> I will create Jira but this is quite urgent so would appreciate any
> suggestions..
> Best regards,
> Krzysztof
> 
> --
> View this message in context: http://openjpa.208410.n2.nabble.com/XMLValueHandler-strategy-not-supported-in-Postgres-tp6331286p6337026.html
> Sent from the OpenJPA Users mailing list archive at Nabble.com.
>