felix-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remo Liechti <remo.liec...@swisslog.com>
Subject How to deal with container provided dependencies
Date Thu, 04 Aug 2016 15:04:46 GMT
 Hi guys

I am using weblogic 12.1.2 that uses a felix (standard shipped with oracle) so that developers
can embed osgi applications into a j2ee application.
So far, I am able to boot certain osgi bundles and activate them. However, loading of the
log4j infrastructure creates some struggle:
1) Either, the main bundle with its activator is not loaded due to missing log4j jars (scope:
provided)
2) Or the init of the log4j appenders fail because there are two log4j jars on the classpath.
However, the bundle is active but does not write logfiles, so tracking errors is hard.

The question here is: How can I tell the osgi bundles to use the container provided jar files
instead of explicitly requesting the jars to be shipped with the web application?
I already have tried to tell the application to prefer libraries that are shipped with the
app over the container libs, but this creates more issues than it solves with other libraries
(weblogic.xml):
    <wls:container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </wls:container-descriptor>
So this is not a solution. Any idea appreciated!

Details:

1)
POM.xml:
========
          <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
            <scope>provided</scope>
        </dependency>

Error during starting of the main bundle:
==================================
Current bundle com.kuka.vms.server has state START_ACTIVATION_POLICY Failed:
org.osgi.framework.BundleException: Unresolved constraint in bundle com.kuka.vms.server [85]:
Unable to resolve 85.0: missing requirement [85.0] osgi.wiring.package; (&(osgi.wiring.package=com.kuka.nav.multicast)(version>=1.0.0))
[caused by: Unable to resolve 44.0: missing requirement [44.0] osgi.wiring.package; (&(osgi.wiring.package=com.kuka.util)(version>=2.0.0))
[caused by: Unable to resolve 12.0: missing requirement [12.0] osgi.wiring.package; (&(osgi.wiring.package=org.slf4j)(version>=1.7.0))]]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3826) at org.apache.felix.framework.Felix.startBundle(Felix.java:1868)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944) at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:931)
at com.swisslog.wm6.test.TestServlet.processRequest(TestServlet.java:78) at com.swisslog.wm6.test.TestServlet.doGet(TestServlet.java:276)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731) at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3363)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564) at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295) at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)



2)
POM.xml (no scope any longer)
=========
<dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.0</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>


Error during start of the main bundle:
===============================
java.lang.ClassCastException: org.apache.log4j.RollingFileAppender cannot be cast to org.apache.log4j.Appender
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:248)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:906)
at com.kuka.internal.VMSActivator.start(VMSActivator.java:41)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at weblogic.osgi.internal.OSGiBundleImpl.start(OSGiBundleImpl.java:35)
[...]
log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.ClassCastException: org.apache.log4j.ConsoleAppender cannot be cast to org.apache.log4j.Appender
at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:248)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:906)
at com.kuka.internal.VMSActivator.start(VMSActivator.java:41)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at weblogic.osgi.internal.OSGiBundleImpl.start(OSGiBundleImpl.java:35)
at weblogic.osgi.internal.OSGiAppDeploymentExtension.startAll(OSGiAppDeploymentExtension.java:61)
at weblogic.osgi.internal.OSGiAppDeploymentExtension.deployBundlesIntoFramework(OSGiAppDeploymentExtension.java:146)
at weblogic.osgi.internal.OSGiAppDeploymentExtension.prepare(OSGiAppDeploymentExtension.java:229)
at weblogic.application.internal.flow.AppDeploymentExtensionFlow.prepare(AppDeploymentExtensionFlow.java:23)
[...]


Thanks,
Remo
This message may contain legally privileged or confidential information and is therefore addressed
to the named persons only. The recipient should inform the sender and delete this message,
if he/she is not named as addressee. The sender disclaims any and all liability for the integrity
and punctuality of this message. The sender has activated an automatic virus scanning, but
does not guarantee the virus free transmission of this message.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Mime
View raw message