Announcement Announcement Module
Collapse
No announcement yet.
Question on Slices Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on Slices

    Hi,

    Does current slices impl supports deploying from plans and pars?

    I have been trying for a while and haven't been able to attach a slice to a host.

    Looks like HostSelector.bundleMatchesHostName()

    Code:
        private boolean bundleMatchesHostName(Bundle bundle) {
            return this.hostDefinition.getSymbolicName().equals(bundle.getSymbolicName());
        }
    tries to do direct match. With plans and pars that does not work because bundle SymbolicName gets changed to include plan/par name in it.

  • #2
    further research

    Just for testing I changed HostSelector.bundleMatchesHostName() to

    Code:
    private boolean bundleMatchesHostName(Bundle bundle) {
            //return this.hostDefinition.getSymbolicName().contains(bundle.getSymbolicName());
            return bundle.getSymbolicName().endsWith(this.hostDefinition.getSymbolicName());
        }
    I am trying to import osgi services in the child slice. For that purpose I am setting contextClass = ServerOsgiBundleXmlWebApplicationContext
    There are two issues that I found trying to do this:

    1). When initializing child slice ServletContext of the parent is used.
    So child can't have its own RootWebAppContext
    2). When using ServerOsgiBundleXmlWebApplicationContext, bundle context of the host is used vs. the child slice and child DispatcherServlet configurations can't be found.
    Here is web.xml:

    Code:
    <servlet>
            <servlet-name>child-slice</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>
                    WEB-INF/spring/servlet/child-slice-servlet.xml
                </param-value>
            </init-param>
            <init-param>
            <param-name>contextClass</param-name>
            <param-value>com.springsource.server.web.dm.ServerOsgiBundleXmlWebApplicationContext</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>rdr-slice</servlet-name>
            <url-pattern>/app/*</url-pattern>
        </servlet-mapping>
    And here is the exception:

    Code:
    [2009-07-10 18:46:08.667] async-delivery-thread-1  pringframework.beans.factory.xml.XmlBeanDefinitionReader.unknown I Loading XML bean definitions from OSGi resource[WEB-INF/spring/servlet/rdr-slice-servlet.xml|bnd.id=106|bnd.sym=insight.rdr.base.plan-1.0.0.B-SNAPSHOT-com.ptc.insight.runtime.webapp]
    [2009-07-10 18:46:21.040] async-delivery-thread-1         org.springframework.web.servlet.DispatcherServlet.unknown E Context initialization failed
    org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from OSGi resource[WEB-INF/spring/servlet/rdr-slice-servlet.xml|bnd.id=106|bnd.sym=insight.rdr.base.plan-1.0.0.B-SNAPSHOT-com.ptc.insight.runtime.webapp];
    To get it to work somehow (because I am stubborn), I added a check in SliceServletContext ( this is by no means a perfect solution):

    Code:
    public Object getAttribute(String name) {
            if ("osgi-bundlecontext".equals(name)) {
                return this.sliceBundle.getBundleContext();
            }
            return delegate.getAttribute(name);
        }
    This finally allowed me to attach a slice to a host in plan based deployment.

    Comment


    • #3
      Dmitry, this is great stuff! You're right on the bleeding edge of Slices here, many thanks for trying it out and reporting these problems.

      I've opened JIRA issues on your behalf for both the BundleContext problem and the use of Hosts and Slices within a PAR or a scoped plan.

      Comment


      • #4
        applicationContext.xml in Slice in DM Server 2.0 M4

        In my application I am observing that the slice bundle is ignoring the applicationContext.xml in the slice bundle. Instead it is referencing applicationContext.xml is host bundle.

        Is my observation correct ? Or I need to configure my slice bundle so that it will point to its own applicationContext.xml?


        Env:

        Windows XP
        DM Server : 2.0 M4

        Comment


        • #5
          Bundle Context Issue

          Is DMS-1133 fixed in the current DM Server and Slice release ?

          Can you update the slices example with the slice importing an OSGI service ?

          Comment


          • #6
            Yes, DMS-1133 should be fixed in the latest Slices builds.

            It should definitely be possible for a Slice to have its own application context. How have you configured your Slice and its application context handling at the moment?

            Comment


            • #7
              Its working now

              We got it tio work from the solution you posted in the other thread (@Autowired in Slices)

              Comment

              Working...
              X