jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Todd Seiber" <todd.sei...@gmail.com>
Subject Re: Jackrabbit and OCM XML mapping troubles
Date Tue, 30 Dec 2008 17:55:18 GMT
Add this to your XML to handle the parser exception.

<!DOCTYPE jackrabbit-ocm PUBLIC "-//The Apache Software Foundation//DTD
Repository//EN"
"http://jackrabbit.apache.org/dtd/jackrabbit-ocm-1.4.dtd">

I thought 1.4 registered the ocm mixin but I could be wrong. Try registering
it yourself. This is its CND.

[ocm:discriminator] mixin
- ocm:classname (string) mandatory



On Tue, Dec 30, 2008 at 12:36 PM, Gaetano Sferra <gsferra@imnet.it> wrote:

> Hi again,
>
> as suggested in my previous post, I left the OCM annotations way to follow
> the XML mapping one but I always got a lot of errors.
> The wish is the same: have two POJOs, Type and Element so an element
> instance have a reference to it's type.
>
> Errors are:
> - org.xml.sax.SAXParseException: Document root element "jackrabbit-ocm",
> must match DOCTYPE root "null"
> - "Unknown mixin type ocm:discriminator for mapped class class
> com.imnet.oam.cm.Type; nested exception is
> javax.jcr.nodetype.NoSuchNodeTypeException: {
> http://jackrabbit.apache.org/ocm}discriminator<http://jackrabbit.apache.org/ocm%7Ddiscriminator>
> "
>
> Java classes are really simple, just two "beans":
> public class Type {
>   private String path;
>   private String uuid;
>   private String name;
>   private String description;
>   // Getters and setters follows...
> }
>
> public class Element {
>   private String path;
>   private String uuid;
>   private String name;
>   private String description;
>   private Type type;
>   // Getters and setters follows...
> }
>
> Here is my XML mapping file:
> <?xml version="1.0" encoding="UTF-8"?>
> <jackrabbit-ocm>
>  <class-descriptor className="Type" jcrType="my:type"
> jcrSuperTypes="nt:base" jcrMixinTypes="mix:referenceable">
>   <field-descriptor fieldName="path" path="true"/>
>   <field-descriptor fieldName="uuid" uuid="true"/>
>   <field-descriptor fieldName="name" jcrName="my:name"
> jcrMandatory="true"/>
>   <field-descriptor fieldName="description" jcrName="my:description"/>
>  </class-descriptor>
>  <class-descriptor className="Element" jcrType="my:element"
> jcrSuperTypes="nt:base" jcrMixinTypes="mix:versionable">
>   <field-descriptor fieldName="path" path="true"/>
>   <field-descriptor fieldName="uuid" uuid="true"/>
>   <field-descriptor fieldName="name" jcrName="my:name"
> jcrMandatory="true"/>
>   <field-descriptor fieldName="description" jcrName="my:description"/>
>   <bean-descriptor
>     fieldName="type"
>     jcrName="my:type"
>     proxy="false"
>     jcrType="my:type"
>     jcrMandatory="true"
>     jcrOnParentVersion="IGNORE"
>
> converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl"
>   />
>  </class-descriptor>
> </jackrabbit-ocm>
>
> The application main methods registers all needed namespaces ("ocm", "my",
> etc...), instantiates a new ObjectContentManagerImpl (successfully) and
> tries to do something like this:
> Type type = new Type()
> type.setPath("/bar")
> type.setName("Bar");
> type.setDescription("A bar");
> ocm.insert(type); <-- This throws a
> ocm.save();
>
> Element element = new Element()
> element.setPath("/foo")
> element.setName("Foobar");
> element.setDescription("Foo bar");
> element.setType((Type) ocm.getObject("/bar"));
> ocm.insert(element);
> ocm.save();
>
> I really have no other ideas, I hope in yours... thank you!
> --
> GaS
>



-- 
Todd Seiber
830 Fishing Creek Rd.
New Cumberland, PA 17070

h. 717-938-5778
c. 717-497-1742
e. todd.seiber@gmail.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message