2011-02-13 4 views
1

DB에 데이터를 저장하는 osgi 번들 (Virgo 아래)으로 실행되는 매우 간단한 애플리케이션을 빌드하려고합니다. virgo trough webinterface에 항아리를 업로드하려고 할 때 다음 오류가 발생합니다. 내가 명령으로 번들을 만들osgi spring hibernate virgo 예제 ClassNotFoundException : org.hibernate.cfg.Configuration

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.rg/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> 
    <groupId>com.company</groupId> 
    <artifactId>com.company.heartbeat</artifactId> 
    <version>0.1.0</version> 

    <properties> 
     <bundle.name>HeartBeatCheck</bundle.name> 
     <hibernate.version>3.5.6-Final</hibernate.version> 
     <org.springframework.version>3.0.5.RELEASE</org.springframework.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.osgi</groupId> 
      <artifactId>org.osgi.core</artifactId> 
      <version>4.2.0</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.14</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-core</artifactId> 
      <version>${org.springframework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-orm</artifactId> 
      <version>${org.springframework.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-core</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-annotations</artifactId> 
      <version>${hibernate.version}</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-hibernate3</artifactId> 
      <version>2.0.8</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.felix</groupId> 
       <artifactId>maven-bundle-plugin</artifactId> 
       <extensions>true</extensions> 
       <configuration> 
        <instructions> 
         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
         <Bundle-Name>${bundle.name}</Bundle-Name> 
         <Export-Package>${project.artifactId}</Export-Package> 
         <Bundle-Version>${pom.version}</Bundle-Version> 
         <Export-Package>com.company.heartbeat.*</Export-Package> 
        </instructions> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

: "MVN 깨끗한 org.apache.felix 설치합니다 받는다는 - 번들 - 플러그인 : 번들", 또한 내가 모든 프로젝트를 넣어 여기에

[2011-02-13 23:19:26.317] start-signalling-4   org.eclipse.virgo.medic.eventlog.default       DE0006E Start failed for bundle 'com.company.heartbeat' version '0.1.0'. org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'beatDao' defined in URL [bundleentry://63.fwk1755147655/META-INF/spring/heartbeatcheck-context.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://63.fwk1755147655/META-INF/spring/heartbeatcheck-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842) 
    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 org.eclipse.virgo.kernel.agent.dm.ContextPropagatingTaskExecutor$2.run(ContextPropagatingTaskExecutor.java:95) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [bundleentry://63.fwk1755147655/META-INF/spring/heartbeatcheck-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:946) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:890) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189) 
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) 
    ... 20 common frames omitted 
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141) 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:72) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:938) 
    ... 28 common frames omitted 
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration 
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.<init>(LocalSessionFactoryBean.java:189) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126) 
    ... 30 common frames omitted 
Caused by: org.eclipse.virgo.kernel.osgi.framework.ExtendedClassNotFoundException: org.hibernate.cfg.Configuration in KernelBundleClassLoader: [bundle=org.springframework.orm_3.0.0.RELEASE] 
    at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:139) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248) 
    ... 36 common frames omitted 
Caused by: java.lang.ClassNotFoundException: org.hibernate.cfg.Configuration 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422) 
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410) 
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107) 
    at org.eclipse.virgo.kernel.userregion.internal.equinox.KernelBundleClassLoader.loadClass(KernelBundleClassLoader.java:135) 
    ... 37 common frames omitted 

내 치어 파일입니다 dependencies jars를 server/repository/usr/디렉토리에 복사합니다.

저는 얼마 전 osgi를 배우기 시작했는데, 아마도 가장 잘못된 것 일 것입니다.

답변

3

마지막으로 문제가 해결되었습니다. 나는 springsource에서 osgi-ready로 hibernate와 mysql libs를 대체했다.

<instructions> 
    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
    <Bundle-Name>${bundle.name}</Bundle-Name> 
    <Bundle-Version>${pom.version}</Bundle-Version> 
    <Export-Package>${project.artifactId}.*</Export-Package> 
    <Import-Bundle>com.springsource.org.hibernate</Import-Bundle> 
    </instructions> 

을 그리고 처녀 자리로드 번들 및 최대 절전 모드 사용할 수 있습니다

<dependency> 
     <groupId>com.mysql.jdbc</groupId> 
     <artifactId>com.springsource.com.mysql.jdbc</artifactId> 
     <version>5.1.6</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>com.springsource.org.hibernate</artifactId> 
     <version>3.3.2.GA</version> 
    </dependency> 

또한 내가 (그래서 올바른 매니페스트가 생성)에 명령 부분을 구축 변경되었습니다.

1

hibernate3.jar 파일에 대한 언급이 누락되었습니다. 이 파일은 Hibernate 3 바이너리 패키지의 루트 디렉토리에있다.

는 도움이되기를 바랍니다.

+0

죄송합니다. 수락을 취소하고 더 ​​나은 해결책을 찾았습니다. 그러나 당신의 충고는 나를 올바른 길로 가게했습니다. –