![]() |
![]() |
|
| Index | Recent Threads | Unanswered Threads | Who's Online | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 12
|
|
| Author |
|
|
Newbie Joined: Apr 24, 2009 Post Count: 3 Status: Offline |
I somebody ! I am trying to persist in a new empty (non-existing) XML datastore and I get the exception : Exception in thread "main" java.lang.IllegalArgumentExceptionAt first glance it seems to be a JAXB 2.1 issue ... my persistence.xml file is : <?xml version="1.0" encoding="UTF-8"?>Note there are 2 persistence units : source then target. I am trying to do something like replicate tables from one RDBMS Datastore to an XML Datastore ... /**The "myfile.xml" is created from scratch but is empty (even no header). When the first "persist" attempt occurs I suppose it fails because of empty file. My question is : is there a way to previously create the schema or initialize this target XML file ? thanks. |
||
|
|
Expert UK Joined: Mar 13, 2004 Post Count: 5686 Status: Offline |
1. Mentioning the class that you're persisting cos it may have something to do with it .2. Why not start with no XML file ? that's the situation we use in our tests. Schema elements are added when an object is persisted. 3. Why not just build up from persisting a new object into XML (omit the RDBMS part for now) ? 4. You don't need "auto-start" in the XML store; you already specified the class in your persistence-unit. ---------------------------------------- -Andy ![]() ![]() |
||
|
|
Expert Belgium Joined: Mar 12, 2004 Post Count: 2991 Status: Offline |
you can raise a bug. the node is null and should a NucleusObjectNotFoundException ---------------------------------------- Erik Bengtson ![]() |
||
|
|
Expert Belgium Joined: Mar 12, 2004 Post Count: 2991 Status: Offline |
issue created http://www.jpox.org/servlet/jira/browse/NUCXML-31 ---------------------------------------- Erik Bengtson ![]() |
||
|
|
Newbie Joined: Apr 24, 2009 Post Count: 3 Status: Offline |
I Andy & Erik, thanks for your answers and guidelines. 1. Mentioning the class that you're persisting cos it may have something to do with it. sorry Andy, you are right, see the Entity bean below ... please note I tried to persist alternatively into xml and excel datastore (using @Extension) and, strangely, I have got the same kind of problem with excel datastore (changing file URL to excel:file:myfile.xls). It suggest me I forget something important about schema initialization... but what ? package datanucleous.xa;2. Why not start with no XML file ? that's the situation we use in our tests. Schema elements are added when an object is persisted. Launching with an empty xml file or launching with NO file (let datanucleus process create it) has the same effect. 3. Why not just build up from persisting a new object into XML (omit the RDBMS part for now) ? My goal was initially to test copy from one datastore to an other using the same Entity Bean ! Following your advice I omitted the RDBMS part and it works fine now ! But, obviously, I had to comment the @TableGenerator/@GeneratedValue annotations, which are not supported in XML datastore context, and set "id" manually to succeed. Nevertheless I think an Entity Bean should be usable without any changes accross multiple datastores of different types. It seems not be possible. Actually, I think that is the reason why my full use case doesn't work. What do you think about ? |
||
|
|
Expert UK Joined: Mar 13, 2004 Post Count: 5686 Status: Offline |
Well JDO is actually the spec that was designed to work with multiple datastores and to allow such things, and it does allow that (e.g package-mysql.orm, package-xml.orm). JPA was not designed for this. That said, DataNucleus would allow you to have persistence-unit 1 for RDBMS with an orm.xml at a particular place in the CLASSPATH, and then have persistence-unit 2 for XML at a different place in the CLASSPATH, and in these orm.xml files you could put value-generation for RDBMS, and not for XML. You cannot expect to put such datastore-specific info in annotations and things to just work If you used JDO (or with JPA, doing as I said above) you could do what you want to do (value generation in MySQL, and just use the id as specified by the user in XML). In fact you can see this exact idea in use in our test suite http://datanucleus.svn.sourceforge.net/viewvc...trunk/test.jdo.replicate/ where we have a convenience JDOReplicationManager and replicate RDBMS to XML, and vice-versa. ---------------------------------------- -Andy ![]() ![]() |
||
|
|
Newbie Joined: Apr 24, 2009 Post Count: 3 Status: Offline |
Thank you again Andy. You really help me to get a good overview of Datanuleus. I achieved my goal with success. I will continue to explore it ... Just a question : using the following code (to copy my RDBMS datastore to an XML datastore) ... JPAReplicationManager replicator = new JPAReplicationManager(r.emf1, r.emf2);... I encountered the exception ... Exception in thread "main" java.lang.IllegalArgumentException: Type ("[Ljava.lang.Object;") is not that of an entity but needs to be for this operationI succeed to copy my RDBMS datastore by other ways but I failed using the dedicated JPAReplicationManager. For me it sounds like a bug ... Is it a known bug (or a known clumsiness from newbies ) ? I didn't find anything about on forum nor Jira. Do you want I build a test case respectful to your rules as described on "Problem Reporting" page ?bye TBR |
||
|
|
Newbie Peru Joined: Jan 30, 2010 Post Count: 5 Status: Offline |
Hi, I am new to Datanucleus, I am doing some tests with the XML datastore and I am facing the same problem as TBR with a 2.0.0 version. The error happens when I try to read an entity from the store, and at the time I do that the XML datastore contains only one entity from a different type. I am using Spring JdOTemplate but I don't think it has any impact. The beginning of the stack trace is : Thanks for your help, Cimballi |
||
|
|
Expert UK Joined: Mar 13, 2004 Post Count: 5686 Status: Offline |
Hi, The forum posting guide is very clear; demonstrate a problem using valid DataNucleus testcase defined at http://www.datanucleus.org/project/problem_reporting.html The previous poster didn't do that either, and without it we just don't have the time ---------------------------------------- -Andy ![]() ![]() ---------------------------------------- [Edit 1 times, last edit by andy at Jan 30, 2010 12:50:22 PM] |
||
|
|
Newbie Peru Joined: Jan 30, 2010 Post Count: 5 Status: Offline |
Hi Andy, Sure, I didn't took time the read the recommandations... On another side I explored my problem and I can give you more informations. The problem appears on this code : super.getJdoTemplate().getObjectById(this.entityClass, entityId); For sure, the entity associated to this id doesn't exist in the repository, but the problem is that it is raising an IllegalArgumentException. It seems the root of the pb is in org.datanucleus.store.xml.XMLUtils, the findNode method, line 244 : node = (Node) xpath.evaluate(expression, doc, XPathConstants.NODE); Here, as the node doesn't exist, the evaluation returns null, and later the null value is passed to JaxB which generates an IllegalArgumentException. I am not sure but maybe there should be a test for a null value and then throws a NucleusObjectNotFoundException like for the post of the other user, but it was a different case. Appart from that, there is something I don't undertand, it seems that the default JDO behavior is to throw an exception when calling getObjectById and the object doesn't exist. But so, is there a simple way to test if an ID is already in use or not ? For example, a mehod which returns a boolean or null. Thanks, Cimballi |
||
|
|
|
|
|
Current timezone is GMT May 17, 2012 12:28:46 PM |