[Building Sakai] Create new Sakai service

Le Nguyen Thach nevilarus at gmail.com
Mon Jul 26 03:03:34 PDT 2010


Hi

I need to write a new Sakai service to do some basic business logic in my
project. It supposes to work like some other Sakai services
(UserDirectoryService, SiteService ..etc). I could not find any tutorial on
the internet so I created my service as a Sakai Application ( but with no
tool implementation) using Sakai App Builder. Luckily , It worked. I can
successfully call a test method like this from my Sakai application.
-----
public String testme(){
   return "OK";
}
-----
But I hit a wall when I started putting real task in it.

----Method getMyClass() declared in myservice-api

public MyClass getMyClass();
----

I want to pass the return value to the tool layer in my application . So I
implemented a method like this in myapp-api and my myapp-impl.

----api
public MyClass getServiceClass(int parameter);
-----impl
public MyClass getServiceClass(int parameter){
    return myservice.getMyClass();
}
-------

Then I called it
----tool
MyClass class = logic.getServiceClass(parameter);  //line 1
String x = class.getTitle();
...
----

But it throwed ClassCastException right at line 1. I have searched on
internet and some people said It got something to do with "classloader". I
guess MyClass in myapp and MyClass in myservice had been loaded into
different libraries ( eventhough they have same code). I can't think any
solution here. Could somebody give me some suggestions?

Many thanks !

Le Nguyen Thach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20100726/b58ad15f/attachment.html 


More information about the sakai-dev mailing list