Announcement Announcement Module
Collapse
No announcement yet.
spring-dm / osgi / spring integration / CannotLoadBeanClassException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring-dm / osgi / spring integration / CannotLoadBeanClassException

    Springframework version: 2.5.6.SEC01
    Spring integration: 1.0.2.SR1

    I'm brand new to OSGi/Spring/Spring integration so it's quite conceivable I am missing something with nothing to do with Spring Integration, but things where going OK with spring-dm until I tried to use spring integrations.

    The exception I am getting is the following: (same in equinox/felix):
    Code:
    [2009-06-16 19:18:00,682] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Ignoring bean class loading failure for bean 'org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor'
    org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor] for bean with name 'org.springframework.integration.internalDefaultConfiguringBeanFactoryPostProcessor' defined in null; nested exception is java.lang.ClassNotFoundException: org.springframework.integration.config.xml.DefaultConfiguringBeanFactoryPostProcessor not found from bundle [com.unwiredappeal.mailgw]
            at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1141)
    ..
    ..
    and my bundle-context-integration.xml file from META-INF/spring:
    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:int="http://www.springframework.org/schema/integration"
        xmlns:mail="http://www.springframework.org/schema/integration/mail"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                http://www.springframework.org/schema/integration
                http://www.springframework.org/schema/integration/spring-integration-1.0.xsd
                http://www.springframework.org/schema/integration/mail
                http://www.springframework.org/schema/integration/mail/spring-integration-mail-1.0.xsd">
            <int:channel id="inboundMail"/>
            <int:service-activator input-channel="inboundMail" ref="myMailHandler"/>
            <mail:imap-idle-channel-adapter store-uri="imaps://[email protected]:[email protected]:993/INBOX/" 
                    channel="inboundMail"/>
    </beans>
    and the bundles loaded into the osgi container:
    Code:
    Framework is launched.
    
    id	State       Bundle
    0	ACTIVE      org.eclipse.osgi_3.4.3.R34x_v20081215-1030
    1	ACTIVE      org.eclipse.osgi.util_3.1.300.v20080303
    2	ACTIVE      org.eclipse.osgi.services_3.1.200.v20070605
    3	ACTIVE      org.apache.felix.configadmin_1.0.1
    4	ACTIVE      org.ops4j.pax.configmanager_0.2.2
    5	ACTIVE      org.ops4j.pax.logging.pax-logging-service_1.3.0
    6	ACTIVE      org.springframework.osgi.extender_1.2.0
    7	ACTIVE      org.springframework.osgi.core_1.2.0
    8	ACTIVE      org.springframework.osgi.io_1.2.0
    9	ACTIVE      org.springframework.aop_2.5.6.SEC01
    10	ACTIVE      org.springframework.transaction_2.5.6.SEC01
    11	ACTIVE      org.springframework.beans_2.5.6.SEC01
    12	ACTIVE      org.springframework.context_2.5.6.SEC01
    13	ACTIVE      org.springframework.core_2.5.6.SEC01
    14	ACTIVE      org.springframework.test_2.5.6.SEC01
    15	ACTIVE      com.springsource.org.aopalliance_1.0.0
    16	ACTIVE      com.springsource.edu.emory.mathcs.backport_3.1.0
    17	ACTIVE      com.springsource.org.apache.log4j_1.2.15
    18	ACTIVE      com.springsource.javax.jms_1.1.0
    19	ACTIVE      com.springsource.javax.transaction_1.1.0
    20	ACTIVE      org.springframework.context.support_2.5.6.SEC01
    21	ACTIVE      org.ops4j.pax.logging.pax-logging-api_1.3.0
    22	ACTIVE      org.springframework.integration_1.0.2.SR1
    23	ACTIVE      org.springframework.integration.adapter_1.0.2.SR1
    24	ACTIVE      org.springframework.integration.mail_1.0.2.SR1
    25	ACTIVE      com.unwiredappeal.mailgw_1.0.0.SNAPSHOT
    26	ACTIVE      javax.mail_1.4.1
    myMailHandler is defined (and from debugging seems to get loaded) from a seperate xml file in the same directory.

    I seem to receive the exception above whenever I try to use the integration name space. If I comment out the int: entries and just leave the mail:imap-idle-channel-adapter, it seems to work OK (except that I receive an error that channel "inboundMail" doesn't exist, but this is to be expected)

    Because I'm new at this, I am not sure what the relevant portions of the log/code/xml files to post, so if you need more please let me know.

    If it makes a difference the project was initially created using pax-construct. I have tried felix 1.8, and equinox 3.4.2 (plus others)

    Thanks in advance for any advice, I've been banging my head all day.

  • #2
    I've done this before succesfully see: http://blog.springsource.com/2009/02...-on-dm-server/.

    Yesterday evening I prepared my demos for OSGi DevCon and they run fine with 1.0.2.SR1. Maybe you can post a dressed down version of your code, so we can check the manifest headers? I'm guessing that since you don't have the Import-Bundle directive (being on plain OSGi) you've missed a package.

    Cheers,
    Iwein

    Comment


    • #3
      I think Iwein's probably right. Can you post your manifests?... at least the imports that would be relevant for any org.springframework.integration.* packages?

      Comment


      • #4
        I currently don't have any spring related imports in my MANIFEST.MF. The import I have in the MANIFEST is:

        Import-Package: com.unwiredappeal.mailgw;version="1.0.0.SNAPSHOT", org.
        slf4j

        I was assuming I didn't need any, and spring-dm handled everything "under the hood". I don't reference any spring classes within my code.

        The interface:
        Code:
        package com.unwiredappeal.mailgw;
        
        public interface MailHandler {
                public void process(String m);
        }
        The implementation:
        Code:
        package com.unwiredappeal.mailgw.internal;
        
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        
        import com.unwiredappeal.mailgw.MailHandler;
        
        public class MailHandlerImpl implements MailHandler {
            private static  final  Logger logger = LoggerFactory.getLogger(MailHandlerImpl.class);
        
            static {
                logger.debug("MailHandlerImpl started.");
            }
                //@Override
                public void process(String m) {
                        logger.debug(m.toString());
                }
        
        }
        and the XML file to export the bean: (This works fine on its own, without trying to add the spring-integration related XML bits);

        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"
          xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
        
          <!-- regular spring configuration file defining the beans for this
               bundle. We've kept the osgi definitions in a separate 
               configuration file so that this file can easily be used
               for integration testing outside of an OSGi environment -->
        
          <bean name="myExampleBean" class="com.unwiredappeal.mailgw.internal.ExampleBeanImpl" />
          <bean name="myMailHandler" class="com.unwiredappeal.mailgw.internal.MailHandlerImpl" />
        
        </beans>

        Comment


        • #5
          Yep, that's your problem then. dm Server handles some things under the hood, but it will not make asumptions about the spring version you wish to use just to name an example.

          If you include an Import-Library: org.springframework.spring and Import-Bundle statements for the Spring Integration stuff you need you should be grand.

          Comment


          • #6
            Originally posted by iwein View Post
            If you include an Import-Library: org.springframework.spring and Import-Bundle statements for the Spring Integration stuff you need you should be grand.
            Thanks, that did the trick. I'm not using spring dm server so I used Require-Bundle instead. (I think Import-Library & bundle are spring dm server specific)

            Code:
            Require-Bundle: org.springframework.beans, org.springframework.core, o
             rg.springframework.integration, org.springframework.integration.adapt
             er, org.springframework.integration.mail
            Not sure if they are all needed, I haven't had a chance to fool around too much yet.

            I think what threw me was the fact that the Spring beans worked without any additional imports/requires, I just made the assumption that Spring Integration would work the same way. If the beans hadn't worked I would probably have tried mucking with the imports straight off.

            Thanks again

            Comment

            Working...
            X