Announcement Announcement Module
Collapse
No announcement yet.
Using BlazeDS with OSGi Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using BlazeDS with OSGi

    Are the BlazeDS bundles found in the Spring OSGi bundle repository usable for general OSGi application development? I have installed the BlazeDS bundles and the dependencies, but I can find no documentation on how to use it. The Spring BlazeDS documentation doesn't mention OSGi.

  • #2
    The BlazeDS bundles in the repository should be correctly packaged for use in OSGi with the correct manifests and so forth, but we have not extensively tested them in an OSGi environment to ensure that the BlazeDS code isn't doing anything that might cause problems in OSGi. This is something we will investigate more deeply before the final release of Spring BlazeDS Integration, but nailing down the general featureset is a higher priority at the moment. We'd be happy to receive any feedback on the results you have using it in this environment, and any issues you might encounter.

    As for configuration and setup, once you have the proper bundles installed, configuration should be similar to running any other Spring MVC based application in such an environment, and really shouldn't stray too far from the existing non-OSGi example.

    Comment


    • #3
      Hello,

      I was trying to test BlazeDS integration in DM Server when I found these bugs :

      in com.springsource.flex.messaging.services.remoting and com.springsource.flex.messaging.services.http bundles there is a bad manifest entry for the host bundle :

      Code:
      Fragment-Host: com.springsource.flex.messaging;bundle-version="[3.2.0.3978, 3.2.0.3798]"
      it would be
      Code:
      Fragment-Host: com.springsource.flex.messaging;bundle-version="[3.2.0.3978, 3.2.0.3978]"
      After modification this avoids problem like :
      Code:
      Direct constraints which are unresolved:
      Missing host com.springsource.flex.messaging_[3.2.0.3978,3.2.0.3798].
      Then I tried to relaunch the server, while the two fragments are now attached, my web module fr.webskin.maquette.web.flex does not start and I have this error :
      Code:
      Cannot resolve: fr.webskin.maquette.web.flex
        Resolver report:
          Bundle: fr.webskin.maquette.web.flex_1.0.0 - Missing Constraint: Import-Package: org.springframework.flex.messaging; version="[1.0.0.M1,1.0.0.M1]"
          Bundle: org.springframework.flex_1.0.0.M1 - Uses Conflict: Import-Package: flex.messaging; version="[3.2.0,4.0.0)"
            Possible Supplier: com.springsource.flex.messaging_3.2.0.3978 - Export-Package: flex.messaging; version="3.2.0.3978"
              Possible Conflicts: 
            Possible Supplier: com.springsource.flex.messaging_3.2.0.3978 - Export-Package: flex.messaging; version="3.2.0.3978"
              Possible Conflicts: flex.messaging.util
            Possible Supplier: com.springsource.flex.messaging_3.2.0.3978 - Export-Package: flex.messaging; version="3.2.0.3978"
              Possible Conflicts: flex.messaging.endpoints,flex.messaging.log,flex.messaging.client,flex.messaging.security,flex.messaging.util,flex.messaging.messages,flex.messaging.config,flex.management.runtime.messaging.log,javax.servlet,flex.messaging.services,flex.messaging.services.messaging,flex.messaging.cluster,javax.servlet.http
      Anyone has got an idea ?


      ps : the last installed bundles :
      Code:
      82      INSTALLED   org.springframework.flex_1.0.0.M1
      83      RESOLVED    com.springsource.flex.messaging_3.2.0.3978
                          Fragments=84, 85, 86
      84      RESOLVED    com.springsource.flex.messaging.services.remoting_3.2.0.3978
                          Master=83
      85      RESOLVED    com.springsource.flex.messaging.services.http_3.2.0.3978
                          Master=83
      86      RESOLVED    com.springsource.flex.messaging.common_3.2.0.3978
                          Master=83
      87      RESOLVED    com.springsource.edu.emory.mathcs.backport_2.2.0
      88      RESOLVED    com.springsource.org.jgroups_2.5.1
      89      RESOLVED    org.springframework.aspects_2.5.6.A
      90      RESOLVED    org.springframework.jms_2.5.6.A

      Comment


      • #4
        I've actually been testing this myself the last couple of days. In addition to the problem with the BlazeDS bundle manifests (which I will try to get corrected in the repository today), I had a couple of mistakes in the manifest for org.springframework.flex as well. Beyond that, I had to make a few minor code changes to work with the dm Server environment. All of this was committed yesterday and should be available in last night's CI build if you want to try it out: http://s3.amazonaws.com/dist.springf....0.0.CI-56.zip

        Here are the pertinent imports from my test app's manifest (this should just be a starting point as the app is fairly bare bones at the moment):
        Code:
        Import-Bundle: org.springframework.flex;version="[1.0.0,1.0.0.RELEASE]",
         org.springframework.web.servlet;version="[2.5.6.A,2.5.6.A]",
         com.springsource.flex.messaging;version="[3.2.0.3978,3.2.0.3978]",
         com.springsource.flex.messaging.common;version="[3.2.0.3978,3.2.0.3978]",
         com.springsource.flex.messaging.services.http;version="[3.2.0.3978,3.2.0.3978]",
         com.springsource.flex.messaging.services.remoting;version="[3.2.0.3978,3.2.0.3978]"

        Comment


        • #5
          Thank you it works. (my test bundle is started)

          To save time for those who wants to know all the dependencies implied by the use of :
          Code:
          <bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" />
          here they are (to put in repository/bundles/usr):

          Code:
          org.springframework.flex-1.0.0.CI-56.jar
          com.springsource.flex.messaging.common-3.2.0.3978.jar
          com.springsource.flex.messaging-3.2.0.3978.jar
          com.springsource.flex.messaging.services.remoting-3.2.0.3978.jar (see discussion above to repair MANIFEST.MF)
          com.springsource.flex.messaging.services.http-3.2.0.3978.jar (IDEM)
          and

          Code:
          com.springsource.org.apache.xalan-2.7.0.jar
          com.springsource.org.jgroups-2.5.1.jar
          com.springsource.org.apache.bcel-5.2.0.jar
          com.springsource.org.apache.xerces-2.8.1.jar
          com.springsource.org.apache.xmlcommons-1.3.3.jar
          com.springsource.org.apache.xml.resolver-1.2.0.jar
          com.springsource.org.apache.commons.httpclient-3.1.0.jar
          com.springsource.org.apache.commons.codec-1.3.0.jar
          com.springsource.edu.emory.mathcs.backport-2.2.0.jar
          Edit :

          and also

          Code:
          org.springframework.security-2.0.4.A.jar
          com.springsource.org.apache.commons.collections-3.2.0.jar
          Last edited by Webskin; Feb 5th, 2009, 12:14 PM. Reason: Missed imports

          Comment


          • #6
            Hello,

            I succeeded to integrate "New Spring/BlazeDS Integration Test Drive" tutorial of Christophe Coenraets (http://coenraets.org/blog/2009/01/ne...on-test-drive/) in DM Server environment.

            Some modifications have to be performed anyway. I had some problems to load JDBC driver "org.h2.Driver" because of the use of Class.forName (incompatible with OSGi environement to load external bundle class) so I used instead apache DBCP. Here it is the bundle list you must have in /repository/bundles/usr :

            Code:
            org.springframework.flex-1.0.0.CI-56.jar
            com.springsource.flex.messaging.common-3.2.0.3978.jar
            com.springsource.flex.messaging-3.2.0.3978.jar
            com.springsource.flex.messaging.services.remoting-3.2.0.3978.jar (see discussion above to repair MANIFEST.MF)
            com.springsource.flex.messaging.services.http-3.2.0.3978.jar (IDEM)
            com.springsource.org.apache.xalan-2.7.0.jar
            com.springsource.org.jgroups-2.5.1.jar
            com.springsource.org.apache.bcel-5.2.0.jar
            com.springsource.org.apache.xerces-2.8.1.jar
            com.springsource.org.apache.xmlcommons-1.3.3.jar
            com.springsource.org.apache.xml.resolver-1.2.0.jar
            com.springsource.org.apache.commons.httpclient-3.1.0.jar
            com.springsource.org.apache.commons.codec-1.3.0.jar
            com.springsource.edu.emory.mathcs.backport-2.2.0.jar
            org.springframework.security-2.0.4.A.jar
            com.springsource.org.apache.commons.collections-3.2.0.jar
            
            com.springsource.org.h2-1.0.71.jar
            com.springsource.org.apache.commons.dbcp-1.2.2.osgi.jar
            com.springsource.org.apache.commons.pool-1.4.0.jar
            Now : here it is the application context you must have in your web module :

            Code:
            <?xml version="1.0" encoding="UTF-8"?>
            <beans xmlns="http://www.springframework.org/schema/beans"
            	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
            	xmlns:context="http://www.springframework.org/schema/context"
            	xsi:schemaLocation="http://www.springframework.org/schema/beans 
                                       http://www.springframework.org/schema/beans/spring-beans.xsd
                                       http://www.springframework.org/schema/context 
                                       http://www.springframework.org/schema/context/spring-context.xsd">
            
            
            	<!-- Maps request paths at /* to the BlazeDS MessageBroker -->
            	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            	    <property name="mappings">
            	        <value>
            	            /*=mySpringManagedMessageBroker
            	        </value>
            	    </property>
            	</bean>
            	
            	<!-- Dispatches requests mapped to a MessageBroker -->
            	<bean class="org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter"/>
            
            	<!-- Bootstraps and exposes the BlazeDS MessageBroker -->
            	<bean id="mySpringManagedMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" />	
            
                <!-- Implementation of ProductDAO using low-level JDBC -->
                <bean id="productDAO" class="flex.spring.samples.product.ProductDAO" >
                    <constructor-arg ref="dataSource"/>
                </bean>
                
            	<!-- Expose the productDAO bean for BlazeDS remoting -->
            	<bean id="product" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
            	    <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
            	    <property name="service" ref="productDAO"/>
            	</bean>
                
                <!-- Implementation of ContactDAO using Spring's JdbcTemplate -->
                <bean id="contactDAO" class="flex.spring.samples.contact.ContactDAO" >
                    <constructor-arg ref="dataSource"/>
                </bean>
                
            	<!-- Expose the contactDAO bean for BlazeDS remoting -->
            	<bean id="contact" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
            	    <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
            	    <property name="service" ref="contactDAO"/>
            	</bean>
            
                <!-- Implementation of CompanyDAO using Spring's JdbcTemplate -->
                <bean id="companyDAO" class="flex.spring.samples.company.CompanyDAO" >
                    <constructor-arg ref="dataSource"/>
                    <constructor-arg ref="industryDAO"/>
                </bean>
                
            	<!-- Expose the companyDAO bean for BlazeDS remoting -->
            	<bean id="company" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
            	    <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
            	    <property name="service" ref="companyDAO"/>
            	</bean>
            
                <!-- Implementation of IndustryDAO using Spring's JdbcTemplate -->
                <bean id="industryDAO" class="flex.spring.samples.industry.IndustryDAO" >
                    <constructor-arg ref="dataSource"/>
                </bean>
                
            	<!-- Expose the IndustryDAO bean for BlazeDS remoting -->
            	<bean id="industry" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter">
            	    <property name="messageBroker" ref="mySpringManagedMessageBroker"/>
            	    <property name="service" ref="industryDAO"/>
            	</bean>
            
            	<!-- Create and populate the tables if the springflexdemodb database -->
            	<bean id="dbInit" class="flex.spring.samples.util.DatabaseInitializer">
                    <constructor-arg ref="dataSource"/>
            	</bean>
                
                <!-- Simple Spring-managed DataSource for embedded h2 database (http://www.h2database.com). H2 is used instead of HSQLDB in this Test Drive
                	 because it has better support for retrieving autogenerated keys using the JDBC 3 approach which is used by Spring's JdbcTemplate.
                	 The "jdbc:h2:~/sprinflexdemodb/sprinflexdemodb" URL points to a springflexdemodb database in the springdemodb directory 
                	 under the user's directory (represented by ~). H2 creates the database automatically if it doesn't exists, in which case, the dbInit bean
                	 takes care of creating and populating the sample tables.  
            	-->
            	 <!-- Not OSGi compliant
                <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                    <property name="driverClassName" value="org.h2.Driver" />
                    <property name="url" value="jdbc:h2:~/sprinflexdemodb/sprinflexdemodbmic" />
                </bean>
                -->
            
            		
            	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
            		p:driverClassName="org.h2.Driver" p:url="jdbc:h2:~/sprinflexdemodb/sprinflexdemodb"/>
            
            </beans>
            The manifest to use :
            Code:
            Manifest-Version: 1.0
            Bundle-Version: 1.0.0
            Bundle-Name: Webskin Flex Bundle
            Bundle-ManifestVersion: 2
            Bundle-SymbolicName: fr.webskin.maquette.web.flex
            Module-Type: Web
            Import-Library: org.springframework.spring;version="[2.5.6.A,2.5.6.A]"
            Web-ContextPath:  coenraets <-- choose what you want but don't forget to fullfill the same string in your flex project context root
            Web-DispatcherServletUrlPatterns: /spring/*
            Import-Bundle: org.springframework.flex;version="[1.0.0.CI-56,1.0.0.CI-56]",
             com.springsource.flex.messaging;version="[3.2.0.3978,3.2.0.3978]",
             com.springsource.flex.messaging.common;version="[3.2.0.3978,3.2.0.3978]",
             com.springsource.flex.messaging.services.http;version="[3.2.0.3978,3.2.0.3978]",
             com.springsource.flex.messaging.services.remoting;version="[3.2.0.3978,3.2.0.3978]",
             com.springsource.org.apache.commons.dbcp;version="[1.2.2.osgi,1.2.2.osgi]",
             com.springsource.org.h2;version="[1.0.71,1.0.71]"
            Import-Package: javax.sql
            Here, the procedure proposed by Christophe Coenraets (and modified by me) to simply test Christophe Coenraets samples :
            Code:
            Opening the Samples Source Code in Flex Builder 3
            Create a Flex Builder project for each sample application you  are interested in. 
            There are several approaches to create a Flex Builder project  for a Flex application that works with BlazeDS. We describe a simple approach here:
            - Select File>New>Project... in the Flex Builder menu. 
            - Expand Flex Builder, select Flex Project and click Next. 
            - Provide a project name. Use the exact name of the sample  folder. For example spring-blazeds-101. 
            - Specify C:\spring-blazeds-testdrive\projects\flex as the Project location. 
            - Select Web Application as the application type.
            - Select J2EE as the application server type.
            - Check use remote object access service.
            - Uncheck Create combined Java/Flex project using WTP.
            - Click Next. 
            - Make sure the root folder for LiveCycle Data Services matches the root folder of your BlazeDS web application. If you are using the Tomcat integrated server on Windows, the settings should look similar  to this (you may need to adjust the exact folder based on your own  settings): 
            Root Folder: C:\workspaceDMServer\coenraets.web.module\src\main\resources\MODULE-INF or directly in DM server work directory  D:\springsource-dm-server-1.0.1.RELEASE\work\com.springsource.server.deployer\Module\coenraets.web.module.jar-0\coenraets.web.module.jar\MODULE-INF 
            Root URL: http://localhost:8080
            Context Root: /coenraets/ (as said before choose the context you want)
            - Click Validate Configuration, then Finish.
            Enjoy yourself.

            MickaŽl.

            Comment


            • #7
              Hello,

              I have successfully done the Flex+BlazeDS+Spring integration. Now I am interested in Flex+BlazeDS+ Spring OSGI integration.

              I have following questions in my mind.

              1. Do I require BlazeDS in OSGI bundle format?
              As I understand, BlazeDS is server based java remoting and web messaging technology. It is just a destination to register the java service to be accessed by flex client.

              2. How and where should I register my service with BlazeDS?
              Following is the code scenario.
              a) HelloService interface bundle
              b) HelloServiceImpl as implementation of HelloService bundle.
              I have created two xml files in HelloServiceImpl bundle to keep the Spring context (module-context.xml) and OSGI context (osgi-contect.xml) separate.
              c) Flex client which should access HelloService exposed by BlazeDS.
              d) I am using SpringSource DM server.

              Any help appreciated.
              Rahul

              Comment

              Working...
              X