Hi,
I'm facing a lot of difficulties using Jackrabbit 1.4 and hope someone
will help me.
1 - Instantiating a TransientRepository using JDK 1.5 throws a
"java.lang.UnsupportedClassVersionError: Bad version number in .class
file" (Jackrabbit should support JDK 1.4 at least, isn't it?)
2 - Define a simple node class using @Node annotation without specify
"discriminator=false" will result in a "Unknown mixin type
ocm:discriminator for mapped class class Type; nested exception is
javax.jcr.nodetype.NoSuchNodeTypeException:
{http://jackrabbit.apache.org/ocm}discriminator"; eg:
@Node
public class Type {
@Field(path=true) private path;
@Field(uuid=true) private uuid;
@Field private String description;
// Getter and setter follows..
}
3 - What's wrong in following code? (throws "Node type: nt:unstructured
has no descriptor" on getObject(String)):
@Node(discriminator=false, jcrSuperTypes="nt:base",
jcrMixinTypes="mix:referenceable")
public class Type {
@Field(path=true) private String path;
@Field(uuid=true) private String uuid;
@Field private String description;
// Getter and setter follows..
}
@Node(discriminator=false, jcrMixinTypes="mix:versionable")
public class Element {
@Field(path=true) private String path;
@Bean(converter=ReferenceBeanConverterImpl.class) private Type type;
// Getter and setter follows..
}
public class Main {
public static void main(String[] args) {
Logger logger = Logger.getLogger(Main.class.getName());
ArrayList<Class> classes = null;
ObjectContentManager ocm = null;
Mapper mapper = null;
Session session = null;
Repository repository = null;
try {
repository = new TransientRepository();
session = repository.login(new SimpleCredentials("user",
"pass".toCharArray()));
try {
session.getWorkspace().getNamespaceRegistry().registerNamespace("ocm",
"http://jackrabbit.apache.org/ocm");
} catch (NamespaceException nsce) {
logger.info(nsce.getMessage());
}
classes = new ArrayList<Class>();
classes.add(Type.class);
classes.add(Element.class);
mapper = new AnnotationMapperImpl(classes);
ocm = new ObjectContentManagerImpl(session, mapper);
Type type = new Type();
type.setPath("/primary");
type.setDescription("My primary element type");
ocm.insert(type);
ocm.save();
Element element = new Element();
element.setPath("/first-element");
element.setType((Type) ocm.getObject("/primary"));
ocm.insert(element);
ocm.save();
} catch (Exception e) {
logger.severe(e.getMessage());
}
}
}
I'm searching on this ML and looking at test code but everything seems
so easy and clean that I really not able to find something wrong.
Please help, thank you.
--
GaS