使用SpringSource Tool Suite 2.7.1,我在我继承的应用程序(applicationContext.xml
,osgi-context.xml
和module-context.xml
中的几个XML文件的Problems视图中看到此错误项目):
Error occured processing '/video_service/src/main/webapp/WEB-INF/applicationContext.xml':
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.springframework.osgi.config.ReferenceBeanDefinitionParser.class$(ReferenceBeanDefinitionParser.java:68)
at org.springframework.osgi.config.ReferenceBeanDefinitionParser.getBeanClass(ReferenceBeanDefinitionParser.java:68)
at org.springframework.osgi.config.AbstractReferenceDefinitionParser.parseInternal(AbstractReferenceDefinitionParser.java:168)
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1335)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1293)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1325)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:135)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:93)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:376)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:422)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
错误出现在
行<osgi:reference id="facade" interface="ru.focusmedia.odp.pshd.integration.Facade" />
,此界面如下所示:
public interface Facade {
/**
* register callback for {@link InputTriggerFact}
* @param callback
*/
void addNotificationListener(InputCallback callback);
void addNotificationListener(FBCallback callback);
void addNotificationListener(UserCallback callback);
void addNotificationListener(RoleCallback callback);
/**
* unregister callback for {@link InputTriggerFact}
* @param callback
*/
void removeNotificationListener(InputCallback callback);
void removeNotificationListener(FBCallback callback);
void removeNotificationListener(UserCallback callback);
void removeNotificationListener(RoleCallback callback);
/**
* getting input by URL
* @param url
* @return
*/
Input getInput(String url);
/**
* getting output by URL
* @param url
* @return
*/
Output getOutput(String url);
/**
* @param input
* @return current (last) value for input, may be null
*/
Measure getCurrentValue(Input input);
/**
* request current value from input driver
* where value is comming, fire InputTriggerFact to InputCallback
* @param input
*/
void refreshValue(Input input);
/**
* @param input
* @param from
* @param to
* @param limit
* @return list of values for input by dates from - to range, may be null
*/
List<InputTriggerFact> getValues(Input input, Date from, Date to, int limit);
/**
* setting value on output
* @param output
* @param value
*/
public void setValue(Output output, Value<? extends Quantity> value);
}
org.springframework.spring [3.0,3.1)
列在MANIFEST.MF
的导入库部分中。我已经尝试将org.springframework.osgi.service.importer.support
直接添加到导入包中,但这没有帮助。
奇怪的是,这确实不阻止应用程序运行,但我怀疑它可能导致其他问题,所以摆脱这些错误似乎是个好主意。我有什么可以做的吗?
答案 0 :(得分:2)
消息“NoClassDefFoundError:无法初始化类XXX”报告类XXX的上一个类加载尝试失败。要诊断这一点,您需要查找先前故障的堆栈跟踪。它应该包含导致原始类初始化失败的问题的嵌套异常。
原始问题发生在XXX或其他类的静态初始化中。 JVM规范说JVM只会尝试为类运行一次类初始化。如果失败,依赖于它的类和类将处于失败状态以防止它们被使用。如果应用程序代码(在本例中为Spring)然后再尝试通过加载它(或其他依赖它的类)来使用失败的类,则会出现此错误。