我正在关注SLF4J异常,我试过从pom.xml中删除slf4j依赖项,仍然存在,有人可以帮忙吗?
异常抛出如下: 。 。
" org.osgi.framework.BundleException: Exception in oracle.acs.assessment.PatchDataExtractionActivator.start() of bundle oracle.acs.mf.PatchDataExtractionBundle. at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1018) > at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974) > at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346) > at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260) > at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252) > at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:260) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:606) > at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150) > at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:291) > at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:276) > at com.sun.svc.container.admin.cli.Console.run(Console.java:85) > at java.lang.Thread.run(Thread.java:724) Caused by: java.lang.NoSuchMethodError: > org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V > at org.apache.log4j.Category.log(Category.java:288) > at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199) > at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:412) > at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:350) > at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) > at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) > at oracle.acs.assessment.util.SpringHelper.initContext(SpringHelper.java:34) > at oracle.acs.assessment.util.SpringHelper.getBean(SpringHelper.java:57) > at oracle.acs.assessment.PatchDataExtractionActivator.start(PatchDataExtractionActivator.java:50) > at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999) > at java.security.AccessController.doPrivileged(Native Method) > at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993) > ... 14 more Nested Exception: java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg / SLF4J /标记; Ljava /郎/字符串; ILjava /郎/字符串; Ljava /郎/ Throwable的;)V
at org.apache.log4j.Category.log(Category.java:288) at org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199) at org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:412) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:350) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93) at oracle.acs.assessment.util.SpringHelper.initContext(SpringHelper.java:34) at oracle.acs.assessment.util.SpringHelper.getBean(SpringHelper.java:57) at oracle.acs.assessment.PatchDataExtractionActivator.start(PatchDataExtractionActivator.java:50) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:999) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252) at org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:260) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:291) at org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:276) at com.sun.svc.container.admin.cli.Console.run(Console.java:85) at java.lang.Thread.run(Thread.java:724) Nested Exception: java.lang.NoSuchMethodError:
org.slf4j.spi.LocationAwareLogger.log(Lorg / SLF4J /标记; Ljava /郎/字符串; ILjava /郎/字符串; Ljava /郎/ Throwable的;)V 在org.apache.log4j.Category.log(Category.java:288) 在org.apache.commons.logging.impl.Log4JLogger.info(Log4JLogger.java:199) 在org.springframework.context.support.AbstractApplicationContext.prepareRefresh(AbstractApplicationContext.java:412) 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:350) 在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:139) 在org.springframework.context.support.ClassPathXmlApplicationContext。(ClassPathXmlApplicationContext.java:93) at oracle.acs.assessment.util.SpringHelper.initContext(SpringHelper.java:34) 在oracle.acs.assessment.util.SpringHelper.getBean(SpringHelper.java:57) at oracle.acs.assessment.PatchDataExtractionActivator.start(PatchDataExtractionActivator.java:50) 在org.eclipse.osgi.framework.internal.core.BundleContextImpl $ 2.run(BundleContextImpl.java:999) at java.security.AccessController.doPrivileged(Native Method) 在org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:993) 在org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:974) 在org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:346) 在org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:260) 在org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:252) 在org.eclipse.osgi.framework.internal.core.FrameworkCommandProvider._start(FrameworkCommandProvider.java:260) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 在org.eclipse.osgi.framework.internal.core.FrameworkCommandInterpreter.execute(FrameworkCommandInterpreter.java:150) 在org.eclipse.osgi.framework.internal.core.FrameworkConsole.docommand(FrameworkConsole.java:291) 在org.eclipse.osgi.framework.internal.core.FrameworkConsole.console(FrameworkConsole.java:276) 在com.sun.svc.container.admin.cli.Console.run(Console.java:85) 在java.lang.Thread.run(Thread.java:724)
我的Pom文件是
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>oracle.acs.mf</groupId>
<artifactId>assessment</artifactId>
<version>all</version>
<relativePath>../pom.xml</relativePath>
</parent>
<groupId>oracle.acs.mf</groupId>
<artifactId>PatchDataExtractionBundle</artifactId>
<version>${assmnt.version}</version>
<packaging>bundle</packaging>
<name>Sun IT Services :: Monitoring Framework :: PatchDataExtractionBundle Bundle</name>
<description>PatchDataExtractionBundle OSGi bundle project.</description>
<properties>
<slf4j.version>1.6.1</slf4j.version>
<logback.version>1.0.11</logback.version>
</properties>
<dependencies>
<dependency>
<groupId>com.sun.cs</groupId>
<artifactId>transport</artifactId>
<version>2.5.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.mf</groupId>
<artifactId>MonitoringFrameworkBundle</artifactId>
<version>3.0-SNAPSHOT</version>
<!--<scope>provided</scope>-->
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>oracle.acs.platform</groupId>
<artifactId>MonitoringFrameworkBundle</artifactId>
<!--<version>all</version>-->
<version>3.5.999</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>2.5.4</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.4</version>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>2.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>oracle.jdbc</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.1.0.5.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
<version>3.5.0.v20090520</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
<optional>true</optional>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>oracle.acs.mf</groupId>
<artifactId>assessment-common</artifactId>
<version>2.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Bundle-Activator>oracle.acs.assessment.PatchDataExtractionActivator</Bundle-Activator>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<!-- include the complete set of transitive dependencies -->
<Embed-Transitive>true</Embed-Transitive>
<Embed-Directory>META-INF/lib</Embed-Directory>
<!-- Custom entries
<CONFIG_FILE>/${install.config.dir}/patch_assessment.properties</CONFIG_FILE>-->
<Export-Package>
oracle.acs.assessment.service.*;oracle.acs.assessment.entity.*;version=${project.version}
</Export-Package>
<Import-Package>
org.osgi.service.http,
org.osgi.framework;version="1.3.0",
org.eclipse.osgi.framework.console, *;resolution:=optional
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
答案 0 :(得分:5)
我假设你正在使用Maven 3.x.因此,在POM中添加<dependencyManagement>
部分,在其中配置slf4j的实际版本(这将在您的父POM中,因此所有模块都使用这些覆盖):
<properties>
<slf4j.version>1.7.5</slf4j.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- Since slf4j is a bridge, you need an implementation of it that would
redirect all calls to slf4j or JCL. Following is to perform logging using
the basic implementation, choose your preferred implementation
(it seems you were using logback). -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</dependencyManagement>
然后,在你的模块的POM中,使用主<dependencies>
部分中的依赖项,如下所示(我建议也删除其他依赖项中的排除项,Maven应该能够选择正确的版本,因为你已经压倒了它):
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<!-- Other dependencies -->
...
</dependencies>
现在从项目的根目录执行mvn clean install
。