yuanji200603
2012-07-30 11:44 阅读 499
已采纳

SpringDm为什么老报java.lang.ClassNotFoundException

请各位大侠熟悉osgi的帮忙解决
异常
[code ="java"]
Exception in thread "SpringOsgiExtenderThread-2" org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.ibatis.SqlMapClientFactoryBean] for bean with name 'sqlMapClient' defined in URL [bundleentry://266.fwk2279771/META-INF/spring/data-source.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.ibatis.SqlMapClientFactoryBean not found from bundle [Contact (Contact)]
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1144)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:524)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1177)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:758)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:422)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.NoClassDefFoundError: org.springframework.orm.ibatis.SqlMapClientFactoryBean not found from bundle [Contact (Contact)]
at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:112)
at org.springframework.osgi.util.BundleDelegatingClassLoader.loadClass(BundleDelegatingClassLoader.java:156)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:211)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:385)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138)
... 11 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/beans/factory/FactoryBean
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClassHoldingLock(ClasspathManager.java:626)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:608)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:562)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:486)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClass(ClasspathManager.java:459)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.findLocalClass(DefaultClassLoader.java:216)
at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:400)
at org.eclipse.osgi.internal.loader.SingleSourcePackage.loadClass(SingleSourcePackage.java:35)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:464)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.eclipse.osgi.internal.loader.BundleLoader.loadClass(BundleLoader.java:345)
at org.eclipse.osgi.framework.internal.core.BundleHost.loadClass(BundleHost.java:229)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadClass(AbstractBundle.java:1207)
at org.springframework.osgi.util.BundleDelegatingClassLoader.findClass(BundleDelegatingClassLoader.java:99)
... 16 more
Caused by: java.lang.ClassNotFoundException: org.springframework.beans.factory.FactoryBean
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[/code]

项目结构
[img]http://dl.iteye.com/upload/attachment/0071/5377/c79ecbc1-53d9-3e64-af47-c9a6e0331319.jpg[/img]

MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Contact
Bundle-SymbolicName: Contact
Bundle-Version: 1.0.0.qualifier
Export-Package: com.javaworld.sample.osgi.spring.contact
Bundle-ClassPath: .,
lib/commons-dbcp-1.2.2.jar,
lib/commons-pool-1.4.jar,
lib/mysql-connector-java-5.0.8-bin-g.jar,
lib/commons-io-1.0.jar,
lib/commons-lang-20030203.000129.jar,
lib/aspectjtools-1.6.12.jar
Import-Package: javax.servlet;version="2.4.0",
javax.servlet.http;version="2.4.0",
org.apache.jasper,
org.osgi.framework;version="1.4.0",
org.springframework.orm.ibatis;version="2.5.6.SEC03",
org.springframework.orm.ibatis.support;version="2.5.6.SEC03",
org.springframework.osgi.web.context.support;version="1.2.0.rc1",
org.springframework.web.context;version="2.5.6",
org.springframework.web.context.support;version="2.5.6"
Require-Bundle: org.springframework.osgi.core;bundle-version="1.2.0",
org.springframework.osgi.io;bundle-version="1.2.0",
org.springframework.beans;bundle-version="2.5.6",
org.springframework.context;bundle-version="2.5.6",
org.springframework.core;bundle-version="2.5.6"
DynamicImport-Package: org.springframework.osgi.web.context.support.*,
org.springframework.web.context.*

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    ferry_passion ferry_passion 2012-07-31 11:21

    应该是你的org.springframework.ormbundle没有起来

    点赞 评论 复制链接分享
  • vvv_110 vvv_110 2012-07-30 17:54

    bundleentry://266.fwk2279771/META-INF/spring/data-source.xml文件里面定义的bean的名字是'sqlMapClient' 的语句有问题。 或许定义这个bean的时候指向的这个类就不存在。 或者这个类里面引用的某个类不存在

    点赞 评论 复制链接分享

相关推荐