JSLEE Discussions
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
Spring cannot load a config file from classpath
Forum Index » Rhino SIP Servlet
Author Message
rmoreira


Joined: 02/07/2013 21:52:27
Messages: 2
Offline

Hi,

I'm using SIP Servlet 1.0.0.2 and Rhino-SDK (version='2.3', release='1.9', build='201305011526', revision='65909') to deploy an application. The application is fully compatible with other Sip Servlet containers (OCCAS and Sailfin) and uses the Spring framework.

After some tweaks, I can now deploy the application in Rhino successfully. However, when I try to activate it, I got the following exception:

In this log we can see that org.springframework.core.io.ClassPathResource.getInputStream is throwing an exception because it can't open the class path resource "spring/core.xml" (path inside SAR: "WEB-INF/classes/spring/spring/core.xml").
After reading some chapters from Rhino documentation, I think that the class loader responsible for loading the SAR is com.opencloud.sipservlet.container.runtime.SarClassLoader.

I build a small test case to understand how SarClassLoader works regarding resource loading and if it is capable of retreiving "spring/core.xml" successfully:

Here are my findings:
  • I can only load the desired SAR resource calling SarClassLoader.getSarResourceAsStream with the full path begining by a slash ("/WEB-INF/classes/spring/core.xml");
  • It's not possible to load the resource using ClassLoader.getResourceAsStream method;
  • org.springframework.core.io.ClassPathResource.getInputStream is using ClassLoader.getResourceAsStream method to get the resource. This method returns a null reference which causes the exception.

  • Is there a workaround for this problem? Am I doing something wrong?

    Thanks in advance.


    Cheers,
    Ricardo
    rbrunton


    Joined: 02/09/2010 14:57:59
    Messages: 75
    Offline

    Hi Ricardo,

    We've provided a new release of SIP Servlet (1.0.0.4) on the Dev Portal that should resolve this issue.

    https://developer.opencloud.com/devportal/display/DWNLD/Rhino+SIP+Servlet+download+page

    Let us know if there are any further issues.

    Cheers, Richard Brunton.
    rmoreira


    Joined: 02/07/2013 21:52:27
    Messages: 2
    Offline

    Hi Richard,

    Thanks for the answer.
    I've tried release 1.0.0.4 and refactored my tests. This release has resolved the SarClassLoader issue because I can now run the following test successfully:

    Nevertheless, when I try to activate my deploy, I still got the same error:

    I still can't understand this result because I was expecting that Spring was using SarClassLoader as ClassLoader.

    Do you have any kind of suggestion to helping me fixing this issue?

    Meanwhile, I will debug Spring framework code to find if they're really using SarClassLoader to load classpath resources.



    Cheers,
    Ricardo Moreira
    ben


    Joined: 27/02/2008 13:51:28
    Messages: 144
    Location: NZ
    Offline

    Hi Ricardo, I'm not very familiar with Spring but I think you'll need to specify the SarClassLoader explicity when you setup your application context. There was a similar issue reported here (https://developer.opencloud.com/forum/posts/list/1182.page), where they used Spring's ClassPathXmlApplicationContext with the SarClassLoader, and got it working.

    Cheers
    Ben

    Ben Evans, Software Engineer, OpenCloud
    [WWW]
     
    Forum Index » Rhino SIP Servlet
    Go to:   
    Powered by JForum 2.1.8 © JForum Team