OpenNTF / org.openntf.domino

Open replacement for lotus.domino package in HCL Domino
Apache License 2.0
65 stars 34 forks source link

JavaHandler is not working in Frames #147

Closed vshashikumar closed 4 years ago

vshashikumar commented 8 years ago

I am using openntf domino api version-2 graph api to develop xpages application. Issue is with javahandler, since gremlin groovy is not supported yet, i have to use javahandlers in frames.

Following is the sample code which defines the framed entity 'ConferenceSession' in which javahandler is implemented using abstract class 'Impl'.

@TypeValue(“ConferenceSession”) @JavaHandlerClass(ConferenceSession.Impl.class) public interface ConferenceSession extends DVertexFrame {

@Property("title") public String getTitle();

@Property("title") public void setTitle(String title);

@AdjacencyUnique(label = "attends", direction = Direction.IN) public Iterable getAttendees();

@AdjacencyUnique(label = "attends", direction = Direction.IN) public Attendee addAttendee(Attendee attendee);

@AdjacencyUnique(label = "attends", direction = Direction.IN) public void removeAttendee(Attendee attendee);

@JavaHandler public long getAttendeesCount();

public abstract class Impl implements ConferenceSession,JavaHandlerContext { public long getAttendeesCount() { long ret = gremlin().in("attends").count(); return ret; } }

}

When the method 'getAttendeesCount' is invoked using framed conferencesession object, it throws the following exception:

com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException:by java.lang.NoClassDefFoundError: javassist.util.proxy.ProxyObject

It behaves the same when one of the javahandlers(asDocument(), asMap(), getEditors()) of DVertexFrame is called.

Is Javahandler supported in this version ?. if yes, can anybody help me on this.

Thanks & Regards Shashikumar V

the-ntf commented 8 years ago

I ran into this recently myself. It's necessary to import the javassist packages into your higher level plugins. For instance, I had to import javassist.util.proxy into my com.redpill.model plugin.

On Wed, Jan 13, 2016 at 9:20 PM, vshashikumar notifications@github.com wrote:

I am using openntf domino api version-2 graph api to develop xpages application Issue is with javahandler, since gremlin groovy is not supported yet, i have to use javahandlers in frames

Following is the sample code which defines the framed entity 'ConferenceSession' in which javahandler is implemented using abstract class 'Impl'

@TypeValue(“ConferenceSession”) @JavaHandlerClass(ConferenceSessionImplclass) public interface ConferenceSession extends DVertexFrame {

@Property https://github.com/Property("title") public String getTitle();

@Property https://github.com/Property("title") public void setTitle(String title);

@AdjacencyUnique(label = "attends", direction = DirectionIN) public Iterable getAttendees();

@AdjacencyUnique(label = "attends", direction = DirectionIN) public Attendee addAttendee(Attendee attendee);

@AdjacencyUnique(label = "attends", direction = DirectionIN) public void removeAttendee(Attendee attendee);

@JavaHandler public long getAttendeesCount();

public abstract class Impl implements ConferenceSession,JavaHandlerContext { public long getAttendeesCount() { long ret = gremlin()in("attends")count(); return ret; } }

}

When the method 'getAttendeesCount' is invoked using framed conferencesession object, it throws the following exception:

comgooglecommonutilconcurrentUncheckedExecutionException: javalangRuntimeException:by javalangNoClassDefFoundError: javassistutilproxyProxyObject

It behaves the same when one of the javahandlers(asDocument(), asMap(), getEditors()) of DVertexFrame is called

Is Javahandler supported in this version ? if yes, can anybody help me on this

Thanks & Regards Shashikumar V

— Reply to this email directly or view it on GitHub https://github.com/OpenNTF/org.openntf.domino/issues/147.

vshashikumar commented 8 years ago

Thanks for the response. Like you said, I made the javassist packages available to my model classes, now it is throwing a different exception. following is the part of the stacktrace.

java.lang.ClassCastException: com.weberon.ConferenceSession$Impl_$$_jvst9f1_2 incompatible with javassist.util.proxy.Proxy at com.tinkerpop.frames.modules.javahandler.JavaHandlerModule.createHandler(JavaHandlerModule.java:125) at com.tinkerpop.frames.modules.javahandler.JavaMethodHandler.processElement(JavaMethodHandler.java:31) at com.tinkerpop.frames.modules.javahandler.JavaMethodHandler.processElement(JavaMethodHandler.java:1) at com.tinkerpop.frames.FramedElement.invoke(FramedElement.java:85) at com.sun.proxy.$Proxy14.getAttendeesCount(Unknown Source) at com.weberon.TestGraph.getAttendeeCount(TestGraph.java:163)

And the following is my 'setupGraph' method.

public static DFramedTransactionalGraph setupGraph() {

try 
{       
    DElementStore sessionStore = new DElementStore();
    sessionStore.setStoreKey("sessions.nsf");
    sessionStore.addType(ConferenceSession.class);

    DElementStore attendeeStore = new DElementStore();
    attendeeStore.setStoreKey("attendees.nsf");
    attendeeStore.addType(Attendee.class);

    DConfiguration config = new DConfiguration();
    DGraph graph = new DGraph(config);

    config.addElementStore(sessionStore);
    config.addElementStore(attendeeStore);  
    config.setDefaultElementStore(sessionStore.getStoreKey());

    JavaHandlerModule jhm = new JavaHandlerModule();
    Module module = new TypedGraphModuleBuilder().withClass(ConferenceSession.class).withClass(Attendee.class).build();

    DFramedGraphFactory factory = new DFramedGraphFactory(jhm, module);
    DFramedTransactionalGraph<DGraph> fg = (DFramedTransactionalGraph<DGraph>) factory.create(graph);
    return fg;

} 
catch (Throwable t) 
{
    XspOpenLogUtil.logError(t);
    return null;
}

}

What additional things need to be done ? if not, kindly let me know where i am going wrong.

Thanks and Regards Shashikumar V

the-ntf commented 8 years ago

I apologize. I only just now saw this response months later. Have you resolved the issue?

vshashikumar commented 8 years ago

First of all, thanks for responding. No, the issue is not yet resolved, I am stuck at that point. Mean while I got gremlin groovy working by adding tinkerpop gremlin groovy jar file and its dependencies to the plugin. It is working like a charm, except for some performance issues with queries involving more documents. Is there any specific reason for gremlin groovy not being included in the plugin ? (let me know if it breaks something, so that I will not consider it for production) and also is there a solution for the issue being reported above..

Thanks and Regards Shashikumar V

paulswithers commented 8 years ago

I've tested the issue with the latest code and it's fixed