[Building Sakai] Create new Sakai service

David Horwitz david.horwitz at uct.ac.za
Mon Jul 26 03:48:56 PDT 2010


Something to check as well is that your API's are not getting bundled in
the sakai component. If you look in tomcat/components/[my
component]/WEB-INF/lib/

You should only see your impl jars and third party jars. This is
something that can lead to classcast exception

On 07/26/2010 12:23 PM, Steve Swinsburg wrote:
> Hi,
>
> You are on the right path. You need to inject your service into your tool so that it can access it since they are in different classloaders. You do this via Spring. You first setup the service as a bean, then add the Spring listener in your web.xml and an applicationContext.xml to setup your tool as a beans and inject the service beans into it.
>
> Using the app buikder check out the components.xml in the pack module and the web.xml and applicationContext in tool. If you generate a Wicket tool with the app builder you'll get it all.
>
> cheers,
> Steve
>
>
>
>
> On 26/07/2010, at 8:03 PM, Le Nguyen Thach wrote:
>
>   
>> 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
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>>
>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>>     
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"
>   



More information about the sakai-dev mailing list