[Texo] Map cannot be persisted [message #1008167] |
Mon, 11 February 2013 09:00 |
Bastian Wagenfeld Messages: 183 Registered: January 2013 |
Senior Member |
|
|
Hi,
I'm trying to generate and save test data via the Texo ModelDataGenerator. The problem is, that Texo does not find an implementation for the map contained in one of the classes. In detail: There is a class User that contains a class Property, that has the super type Identifiable (as from the Texo examples) and the Instance Type name java.util.Map$Entry. The data generation succeeds, but then the following exception is thrown on the server:
java.lang.IllegalArgumentException: No implementation class for classifier org.eclipse.emf.ecore.impl.EClassImpl@19835cb (name: MetaData) (instanceClassName: java.util.Map$Entry) (abstract: false, interface: false)
at org.eclipse.emf.texo.model.ModelResolver.getImplementationClass(ModelResolver.java:255)
at org.eclipse.emf.texo.server.store.EntityManagerObjectStore.get(EntityManagerObjectStore.java:58)
at org.eclipse.emf.texo.resolver.DefaultObjectResolver.fromUri(DefaultObjectResolver.java:236)
at org.eclipse.emf.texo.json.JSONModelConverter.fromUri(JSONModelConverter.java:60)
at org.eclipse.emf.texo.json.BaseJSONModelConverter.resolveObject(BaseJSONModelConverter.java:120)
at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:107)
at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:85)
at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:74)
at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:91)
at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:45)
at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:111)
at org.eclipse.emf.texo.server.web.WebServiceHandler.doPut(WebServiceHandler.java:125)
at org.eclipse.emf.texo.server.web.WebServiceServlet.doPut(WebServiceServlet.java:73)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
The code for the generation looks like this:
public static void main(String[] args) {
ePackages = new ArrayList<EPackage>();
ePackages.add(UsersPackage.eINSTANCE);
IdentifiablePackage.eINSTANCE.eClass();
final List<EClass> eClasses = DataGeneratorUtils
.getRootEClasses(ePackages);
gen.setStartEClasses(eClasses);
gen.setEPackages(ePackages);
gen.setMaxDepth(5);
gen.setCollectionSize(2);
gen.setDataSize(5);
gen.setMaxObjects(1000);
gen.setEPackages(ePackages);
gen.generateTestData();
ComponentProvider.getInstance().register(JSONEObjectStore.class,
JSONEObjectStoreWithAuthentication.class);
EMFJSONConverter conv = ComponentProvider.getInstance().newInstance(
EMFJSONConverter.class);
JSONArray array = ComponentProvider.getInstance().newInstance(
JSONArray.class);
try {
URL url = new URL("http://localhost:8080/texo/jsonws");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("PUT");
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
for (EObject obj : gen.getAllEObjects()) {
array.put(conv.convert(obj));
}
OutputStreamWriter writer = new OutputStreamWriter(
connection.getOutputStream());
writer.write(array.toString());
writer.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String json = reader.readLine();
} catch (Exception e) {
}
Indeed, no implementation class for the Property class is generated by the Texo model generator, but I think this is the correct behaviour. Does anybody have an idea, what could be the originator of this exception?
Best regards
Bastian
|
|
|
Re: [Texo] Map cannot be persisted [message #1008265 is a reply to message #1008167] |
Mon, 11 February 2013 15:00 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Bastian,
This seems to be a bug/missing feature. Indeed no class should be generated for the map entries, so that's correct. I
wonder why my earlier testcase did not give an exception on maps, it persists maps and reads them again.
Can you share the model with me? Can I add it to the testsuite also?
Then I can try to reproduce it locally.
gr. Martin
On 02/11/2013 10:00 AM, Bastian Wagenfeld wrote:
> Hi,
>
> I'm trying to generate and save test data via the Texo ModelDataGenerator. The problem is, that Texo does not find an
> implementation for the map contained in one of the classes. In detail: There is a class User that contains a class
> Property, that has the super type Identifiable (as from the Texo examples) and the Instance Type name
> java.util.Map$Entry. The data generation succeeds, but then the following exception is thrown on the server:
>
> java.lang.IllegalArgumentException: No implementation class for classifier org.eclipse.emf.ecore.impl.EClassImpl@19835cb
> (name: MetaData) (instanceClassName: java.util.Map$Entry) (abstract: false, interface: false)
> at org.eclipse.emf.texo.model.ModelResolver.getImplementationClass(ModelResolver.java:255)
> at org.eclipse.emf.texo.server.store.EntityManagerObjectStore.get(EntityManagerObjectStore.java:58)
> at org.eclipse.emf.texo.resolver.DefaultObjectResolver.fromUri(DefaultObjectResolver.java:236)
> at org.eclipse.emf.texo.json.JSONModelConverter.fromUri(JSONModelConverter.java:60)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.resolveObject(BaseJSONModelConverter.java:120)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:107)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.doConvert(BaseJSONModelConverter.java:85)
> at org.eclipse.emf.texo.json.BaseJSONModelConverter.convert(BaseJSONModelConverter.java:74)
> at org.eclipse.emf.texo.server.service.json.JSONServiceContext.getRequestData(JSONServiceContext.java:91)
> at org.eclipse.emf.texo.server.service.UpdateInsertModelOperation.internalExecute(UpdateInsertModelOperation.java:45)
> at org.eclipse.emf.texo.server.service.ModelOperation.execute(ModelOperation.java:59)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPost(WebServiceHandler.java:111)
> at org.eclipse.emf.texo.server.web.WebServiceHandler.doPut(WebServiceHandler.java:125)
> at org.eclipse.emf.texo.server.web.WebServiceServlet.doPut(WebServiceServlet.java:73)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
> at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
> at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
> at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
> at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
> at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581)
> at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
> at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
> at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
> at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
> at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
> at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
> at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
> at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> at java.lang.Thread.run(Thread.java:722)
>
> The code for the generation looks like this:
>
> public static void main(String[] args) {
> ePackages = new ArrayList<EPackage>();
> ePackages.add(UsersPackage.eINSTANCE);
> IdentifiablePackage.eINSTANCE.eClass();
>
> final List<EClass> eClasses = DataGeneratorUtils
> .getRootEClasses(ePackages);
>
> gen.setStartEClasses(eClasses);
>
> gen.setEPackages(ePackages);
> gen.setMaxDepth(5);
> gen.setCollectionSize(2);
> gen.setDataSize(5);
> gen.setMaxObjects(1000);
> gen.setEPackages(ePackages);
> gen.generateTestData();
>
> ComponentProvider.getInstance().register(JSONEObjectStore.class,
> JSONEObjectStoreWithAuthentication.class);
>
> EMFJSONConverter conv = ComponentProvider.getInstance().newInstance(
> EMFJSONConverter.class);
> JSONArray array = ComponentProvider.getInstance().newInstance(
> JSONArray.class);
>
> try {
> URL url = new URL("http://localhost:8080/texo/jsonws");
>
> connection = (HttpURLConnection) url.openConnection();
> connection.setRequestMethod("PUT");
> connection.setDoInput(true);
> connection.setDoOutput(true);
> connection.setUseCaches(false);
> for (EObject obj : gen.getAllEObjects()) {
> array.put(conv.convert(obj));
> }
>
> OutputStreamWriter writer = new OutputStreamWriter(
> connection.getOutputStream());
> writer.write(array.toString());
> writer.flush();
>
> BufferedReader reader = new BufferedReader(new InputStreamReader(
> connection.getInputStream()));
> String json = reader.readLine();
> } catch (Exception e) {
> }
>
> Indeed, no implementation class for the Property class is generated by the Texo model generator, but I think this is the
> correct behaviour. Does anybody have an idea, what could be the originator of this exception?
>
> Best regards
> Bastian
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
Re: [Texo] Map cannot be persisted [message #1011097 is a reply to message #1011096] |
Mon, 18 February 2013 21:09 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
And here is the commit with the added testcase to Texo:
http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/commit/?id=e35ff3c4c12e87588df0eaaae9f2988f014b5ac4
gr. Martin
On 02/18/2013 10:07 PM, Martin Taal wrote:
> Hi Bastian,
> I added a testcase for this. The reason that the/your testcode fails is that the json array contains Map entries. This
> is related to the fact that the for loop iterates over all generated EObjects (including the Map entries). The correct
> way is to get the generated top/root objects and place these in the json array.
> The following is the working/correct for-loop:
> for (EObject obj : gen.getResult()) {
> obj.eSet(obj.eClass().getEStructuralFeature("db_version"), null);
> array.put(conv.convert(obj));
> }
>
> The first line in the for loop is used to set the version to null, otherwise the server-side logic will think that the
> object already exists in the database and will throw an error (as the merge operation then fails).
>
> gr. Martin
>
> On 02/12/2013 07:17 AM, Bastian Wagenfeld wrote:
>> Hi Martin,
>>
>> I sent you an email with the model. Thanks!
>>
>> Best regards
>> Bastian
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Texo] Map cannot be persisted [message #1011798 is a reply to message #1011758] |
Wed, 20 February 2013 09:17 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Bastian,
I guess the nullable issue is that with a single table inheritance mapping many types are stored in one table, when
persisting an object the columns used for other classes are nullified (resulting in errors if they are not null).
In another EMF-->RDB solution (Teneo) I solve this by explicitly making these columns nullable. It is strange that this
is not solved by standard orms.
In any case there seems to be a bug that the inheritance strategy does not change the orm.xml. Where/how did you set the
inheritance strategy?
gr. Martin
On 02/20/2013 08:57 AM, Bastian Wagenfeld wrote:
> Hey Martin,
>
> thanks for that... like always :)
> Unfortunately the EntityManager now fails while persisting the generated code due to SQL constraint violations. It seems
> the EntityManager tries to "null" non-nullable cells in the database. For test purposes we tried to change the
> inheritance strategy. Changing the strategy in all of the six annotationsmodels doesn't make any difference in the
> generated orm.xml files (if we generate the JPA annotated model code the right annotations are set). But the
> annotationsmodel files are used correctly apart from that, for example: if we add an annotation for the table naming it
> also affects the generated orm.xml. If we only change the inheritance strategy the generated orm.xml files are
> absolutely identical for each strategy. Is that the right behaviour? If it is, where does the inheritance strategy have
> to be set?
>
> Sorry for bothering you again... :?
> Best regards Bastian
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Texo] Map cannot be persisted [message #1011809 is a reply to message #1011806] |
Wed, 20 February 2013 09:45 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Bastian,
Seems to be a bug, can you enter a bugzilla for it?
gr. Martin
On 02/20/2013 10:38 AM, Bastian Wagenfeld wrote:
> Hi Martin,
>
> I set the inheritance annotation in each annotationsmodel file for the used ecores on the package level. But it doesn't
> work, if I set it on the entity level, neither.
> For example the xml for one of the models looks (partially) like this:
> <?xml version="1.0" encoding="UTF-8"?>
> <annotationsmodel:AnnotatedModel xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:annotationsmodel="http://www.eclipse.org/emf/texo/annotations/model"
> xmlns:ormannotations="http://www.eclipse.org/emf/texo/orm/ormannotations">
> <annotatedEPackages>
> <ePackage href="test.ecore#/"/>
> <ePackageAnnotations xsi:type="ormannotations:EPackageORMAnnotation" generated="true"
> generateFullDbSchemaNames="false" maximumSqlNameLength="255" lowerCasedNames="false" upperCasedNames="false"
> enforceUniqueNames="false" useJoinTablesForContainment="false" useJoinTablesForNonContainment="true"
> generateJavaAnnotations="false" addOrderColumnToListMappings="false" renameSQLReservedNames="false"
> uniqueEntityNames="true" setDelimitedIdentifierTagInORM="true">
> <inheritance strategy="SINGLE_TABLE"/>
> </ePackageAnnotations>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="test.ecore#//Test"/>
> <eClassAnnotations xsi:type="ormannotations:EClassORMAnnotation" generated="true">
> <entity class=...
>
> The interesting thing is that the JPA code annotations are set correctly.
>
> Bastian
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03300 seconds