Results 1 to 6 of 6

Thread: SpringDM dependencies

  1. #1

    Default SpringDM dependencies

    Hello there! After reading this forum and getting some help I've started to code our app. My approach was similar to the one the guys at sling (http://sling.apache.org) are using:

    I Have a ContextListener that starts Felix, and an Activator that scans a folder (bundles/) in order to start all the bundles for my app.

    I'm not sure if this is the right way to start up a SpringDM app, but I could not find a clear document on this

    Well, I've put on my bundles the following jars (all taken from Spring DM 1.1.2):

    cglib
    aopalliance
    spring-aop
    spring-beans
    spring-context
    spring-context-support
    spring-core
    spring-osgi-extender
    spring-osgi-core
    spring-osgi-io

    I've also have a dir named corebundles that are started first inside my activator in this dir I've got:

    com.springsource.slf4j.api-1.5.0
    com.springsource.slf4j.log4j-1.5.0
    com.springsource.slf4j.org.apache.commons.logging-1.5.0
    servlet-api.osgi-2.5-SNAPSHOT


    Well, after starting up I get these messages of error:

    Code:
    10:17:50,389 INFO  [STDOUT] ERROR: Error starting osl:com.springsource.slf4j.api-1.5.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0))))
    10:17:50,392 ERROR [STDERR] org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0)))
    10:17:50,392 ERROR [STDERR] 	at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1792)
    10:17:50,392 ERROR [STDERR] 	at org.apache.felix.framework.Felix._startBundle(Felix.java:1652)
    10:17:50,392 ERROR [STDERR] 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
    10:17:50,392 ERROR [STDERR] 	at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
    10:17:50,393 ERROR [STDERR] 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
    10:17:50,393 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:613)
    10:17:50,397 INFO  [STDOUT] ERROR: Error starting osl:com.springsource.slf4j.org.apache.commons.logging-1.5.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0))))
    10:17:50,397 ERROR [STDERR] org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0)))
    10:17:50,397 ERROR [STDERR] 	at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1792)
    10:17:50,397 ERROR [STDERR] 	at org.apache.felix.framework.Felix._startBundle(Felix.java:1652)
    10:17:50,397 ERROR [STDERR] 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
    10:17:50,397 ERROR [STDERR] 	at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
    10:17:50,397 ERROR [STDERR] 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
    10:17:50,397 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:613)
    10:17:50,398 INFO  [STDOUT] ERROR: Error starting osl:com.springsource.slf4j.log4j-1.5.0.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0))))
    10:17:50,398 ERROR [STDERR] org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0)))
    10:17:50,398 ERROR [STDERR] 	at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1792)
    10:17:50,398 ERROR [STDERR] 	at org.apache.felix.framework.Felix._startBundle(Felix.java:1652)
    10:17:50,398 ERROR [STDERR] 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
    10:17:50,398 ERROR [STDERR] 	at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
    10:17:50,398 ERROR [STDERR] 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
    10:17:50,398 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:613)
    10:17:50,401 INFO  [STDOUT] ERROR: Error starting osl:spring-core-2.5.5.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0))))
    10:17:50,401 ERROR [STDERR] org.osgi.framework.BundleException: Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(version>=2.0.0)))
    10:17:50,401 ERROR [STDERR] 	at org.apache.felix.framework.Felix._resolveBundle(Felix.java:1792)
    10:17:50,401 ERROR [STDERR] 	at org.apache.felix.framework.Felix._startBundle(Felix.java:1652)
    10:17:50,401 ERROR [STDERR] 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
    10:17:50,401 ERROR [STDERR] 	at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
    10:17:50,401 ERROR [STDERR] 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
    10:17:50,401 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:613)
    10:17:50,476 INFO  [STDOUT] ERROR: Error starting osl:spring-osgi-extender-1.1.2.jar (org.osgi.framework.BundleException: Activator start error in bundle org.springframework.bundle.osgi.extender [15].)
    10:17:50,476 ERROR [STDERR] java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
    10:17:50,477 ERROR [STDERR] 	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    10:17:50,477 ERROR [STDERR] 	at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    10:17:50,477 ERROR [STDERR] 	at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:203)
    10:17:50,477 ERROR [STDERR] 	at org.springframework.osgi.extender.internal.activator.ContextLoaderListener.<clinit>(ContextLoaderListener.java:253)
    10:17:50,477 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    10:17:50,477 ERROR [STDERR] 	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    10:17:50,477 ERROR [STDERR] 	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    10:17:50,477 ERROR [STDERR] 	at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    10:17:50,477 ERROR [STDERR] 	at java.lang.Class.newInstance0(Class.java:350)
    10:17:50,477 ERROR [STDERR] 	at java.lang.Class.newInstance(Class.java:303)
    10:17:50,477 ERROR [STDERR] 	at org.apache.felix.framework.Felix.createBundleActivator(Felix.java:3548)
    10:17:50,478 ERROR [STDERR] 	at org.apache.felix.framework.Felix._startBundle(Felix.java:1666)
    10:17:50,478 ERROR [STDERR] 	at org.apache.felix.framework.Felix.startBundle(Felix.java:1588)
    10:17:50,478 ERROR [STDERR] 	at org.apache.felix.framework.Felix.setFrameworkStartLevel(Felix.java:1180)
    10:17:50,478 ERROR [STDERR] 	at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:265)
    10:17:50,478 ERROR [STDERR] 	at java.lang.Thread.run(Thread.java:613)
    I'm sorry I'm really lost out here, could someone give me some help?

    Regards

  2. #2
    Join Date
    Jan 2009
    Location
    Frankfurt, Germany
    Posts
    18

    Default

    You are missing a pre-requisite dependency. In this case one repeated error is

    Unresolved constraint in bundle 4: package; (&(package=org.apache.log4j)(version>=1.2.15)(!(ve rsion>=2.0.0))))

    Spring DM 1.1.2 has log4j wrapped inside \spring-osgi-1.1.2\lib\log4j.osgi-1.2.15-SNAPSHOT

    The dependencies you have listed above related to logging are only the SLF4j API and the adapters for LOG4j and Apache Commons Logging. You actually have no log4j provider bundle and that is what the missing dependency is for ...

    As a minimum I always run with the following dependencies

    Spring AOP will need:
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.net.sf.cglib-2.1.3.jar
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.org.aopalliance-1.0.0.jar
    file:C:\dev\org.aspectj.aspectjweaver_1.6.1.jar
    file:C:\dev\org.aspectj_1.6.2.jar
    file:C:\dev\spring-framework-2.5.5\dist\weaving\spring-aspects.jar

    Note that some of these bundles are not provided with Spring DM.

    Logging
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.slf4j.api-1.5.0.jar
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.slf4j.log4j-1.5.0.jar
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.slf4j.org.apache.common s.logging-1.5.0.jar
    file:C:\dev\spring-osgi-1.1.2\lib\log4j.osgi-1.2.15-SNAPSHOT.jar

    Spring Beans needs
    file:C:\dev\spring-osgi-1.1.2\lib\com.springsource.edu.emory.mathcs.backpo rt-3.1.0.jar
    file:C:\dev\knopflerfish_osgi_2.0.4\knopflerfish.o rg\osgi\jars\plugins\org.apache.commons.pool_1.4.0 .jar

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Vinicius, the home page contains links to various materials on how to use Spring DM. Additionally, the distribution contains several samples (both web and non-web) which should not just best practices but also working applications that you can use to bootstrap your development.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Just for the record, all the Spring DM required bundles/libraries are provided by default in the -with-dependencies distribution. For example the aspectjweaver or spring-aspect are not needed. The same goes for org.apache.commons.pool - you can use it if you use the pooling classes from Spring but by otherwise, the library is not needed.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5

    Default

    Thanks all, after the help I got it running. But I'm getting some errors with log4j, after the web app gets deployed:

    Code:
    10:44:30,005 ERROR [STDERR] log4j:ERROR A "org.jboss.logging.appender.FileAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
    10:44:30,005 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by 
    10:44:30,005 ERROR [STDERR] log4j:ERROR [2.0] whereas object of type 
    10:44:30,006 ERROR [STDERR] log4j:ERROR "org.jboss.logging.appender.FileAppender" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@d2068d].
    10:44:30,006 ERROR [STDERR] log4j:ERROR Could not instantiate appender named "FILE".
    10:44:30,006 ERROR [STDERR] log4j:ERROR A "org.apache.log4j.ConsoleAppender" object is not assignable to a "org.apache.log4j.Appender" variable.
    10:44:30,006 ERROR [STDERR] log4j:ERROR The class "org.apache.log4j.Appender" was loaded by 
    10:44:30,006 ERROR [STDERR] log4j:ERROR [2.0] whereas object of type 
    10:44:30,006 ERROR [STDERR] log4j:ERROR "org.apache.log4j.ConsoleAppender" was loaded by [org.jboss.system.server.NoAnnotationURLClassLoader@d2068d].
    10:44:30,006 ERROR [STDERR] log4j:ERROR Could not instantiate appender named "CONSOLE".
    10:44:30,035 ERROR [STDERR] log4j:WARN No appenders could be found for logger (org.springframework.osgi.extender.internal.activator.ContextLoaderListener).
    10:44:30,035 ERROR [STDERR] log4j:WARN Please initialize the log4j system properly.
    It seems to be a problem with jboss class loading. Can I ignore those errors?

    Regards

  6. #6
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I assume you are using OSGi embedded inside JBoss. You have to either boot delegate log4j so that the version in JBoss is loaded or configure JBoss classloaders to stop loading log4j - I'm not familiar with the recent JBoss versions so my advice might make sense or not
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •