Announcement Announcement Module
No announcement yet.
Spring 3 web Jars - issue as Bundle - with org.apacje.log4j imports Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 3 web Jars - issue as Bundle - with org.apacje.log4j imports

    My application uses Log4j for logging . I have downloaded log4j bundle version 1.2.15 from spring repository.

    In my application bundle i have import


    When i use Spring 3.0 web related jars i get uses conflict because

    Spring web has imports like

    org.apache.log4j;version=" [1.2.15, 2.0.0)" [org.springframework.web-3.0.0.RELEASE.jar]

    I feel spring resolves to imports from slf4j present in DM server lib.

    How do i solve this issue ?

  • #2
    The slf4j bundles in lib only export slf4j and commons logging packages and not log4j packages.

    I recommend using the Admin Console to explore the state dump that is produced when the uses conflict is detected. You'll be able to see any multiple suppliers of packages and, with a bit of thoughtful analysis, work out what's going on.


    • #3
      I have verified with latest version(2.0.1) of DM kernel and Dm server.

      Dm kernel doesnt export it , but Dm server does have it.


      manifest which exports

      Export-Package: org.apache.log4j;provider="slf4j";version="1.2.15";use


      • #4
        You should be able to use that version of the org.apache.log4j package, but if you must specify a bundle symbolic name, it should of course be "" rather than "".

        (In general, I would avoid specifying bundle symbolic name on a package import as it will tend to constrain the resolver and may give rise to uses constraint violations, but I guess you had some specific reason for doing so.)


        • #5

          My issue came because of multiple bundles exporting "org.apache.log4j"

          In my application i want to use log4j. For this reason i add bundle symbolic name to "" in my application bundles.

          This causes issue whn i use Spring Web bundles which has imports for org.apache.log4j (without any explicit bundle symbolic name), which in some cases resolves to

          This causes uses voilation -

          My app -[uses] - Spring web [uses] -

          My app - [uses] -


          • #6
            So does changing the bundle symbolic name to fix your problem?


            • #7
              Actually i did not change my application bundle to import from This is because i am converting legacy code into bundles which heavily use log4j( functionalities.

              So in my application i would still continue to use imports from log4j bundle(

              Is there any other way i can solve this issue and make spring web bundle also import from this log4j jar(without altering spring web bundle manifest) ?


              • #8
                The problem you face is that the Spring web bundle currently resolves before your application and so its wiring will not depend on your application's requirements.

                You may be able to deploy your application early in the user region, presumably just before the plan com.springsource.server.web. See this thread for some clues about how to do this. If the resolver plays nicely, this will force Spring web to wire consistently with your application. If the resolver doesn't do this, then the approach won't work.

                So this feels risky, but since your application seems to have a heavy dependency on log4j, you may feel that the above experiment is worth the investment in time.

                Hope that helps.


                • #9
                  Isnt it a bad practice for the following two bundles to have same package structure(org.apache.log4j)


         (spring repository)

                  Also these two bundles are not alternative technologies , rather they complement each other.


                  • #10
                    The Enterprise Bundle Repository is intended for broad use in many OSGi environments, so it's not surprising it contains some bundles which would not be of use in a dm Server environment.