CannotLoadBeanClassException:Equinox 捆绑包中的 Hibernate

发布于 2024-11-13 07:13:14 字数 7641 浏览 2 评论 0原文

我正在 Equinox 上开发一个应用程序。我是一个调用 jar 服务器服务的 Web 客户端。这个 jar 集成了 Spring 和 Hibernate。我的 spring 配置文件是:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://www.springframework.org/schema/beans"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:5432/3encult" />
    <property name="password" value="3encult" />
    <property name="username" value="3encult" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    <property name="mappingResources">
        <list>
            <value>
                User.hbm.xml
            </value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <!-- Especificamos el valor minimo del pool de conexiones -->
            <prop key="hibernate.c3p0.minPoolSize">5</prop>
            <!-- Especificamos el valor maximo del pool de conexiones -->
            <prop key="hibernate.c3p0.maxPoolSize">20</prop>
            <!-- El tiempo de vida de cada conexion del pool. -->
            <prop key="hibernate.c3p0.timeout">600</prop>

        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  <property name="sessionFactory" ref="sessionFactory" />  
 </bean>

<bean id="myUserDAO" class="service.User">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>

从我的类中编写:

ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"service/service-dao.xml"});
private SessionFactory sessionFactory = (SessionFactory)context.getBean("sessionFactory");

并且清单将所需的包导入到 Spring 和 Hibernate,如下所示:

Require-Bundle: jdbc+hibernate
Import-Package: org.springframework.orm.hibernate3, org.apache.commons.dbcp, 
 org.springframework.beans.factory.annotation, 
 org.springframework.beans.factory.xml, 
 org.springframework.context,
 org.springframework.core.io,
 org.springframework.context.support

但是,我收到一个异常,表示包找不到该类。但是包 org.springframework.orm.hibernate3 被导入到清单中。

org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [service/service-dao.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.LocalSessionFactoryBean not found from bundle [ZBGWTApp (ZBGWTApp;singleton:=true)]

另外,捆绑包是活动的,当然,它们会导出包:

55      ACTIVE      org.springframework.transaction_2.5.6
56      ACTIVE      org.springframework.orm_2.5.6
57      ACTIVE      org.springframework.jdbc_2.5.6
58      ACTIVE      org.apache.commons.pool_1.5.6
59      ACTIVE      org.apache.commons.dbcp_1.4.0

如果一切看起来都正确的话,我不知道原因是什么。

完整的堆栈跟踪是:

2011-06-07 07:36:59.570:WARN:/:Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.springframework.beans.factory.CannotLoadBeanClassException' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [service/service-dao.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.LocalSessionFactoryBean not found from bundle [ZBGWTApp (ZBGWTApp;singleton:=true)]
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerialationStreamWriter.java:615)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:535)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:390)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at main.java.com.gwt.app.server.GreetingServiceImpl.service(GreetingServiceImpl.java:30)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:318)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:939)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)            
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

提前致谢!

问候!

I am developing an application on Equinox. I an a Web Client that calls a jar server service. This jar integrates Spring and Hibernate. My spring config file is:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns="http://www.springframework.org/schema/beans"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:5432/3encult" />
    <property name="password" value="3encult" />
    <property name="username" value="3encult" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="myDataSource" />
    <property name="mappingResources">
        <list>
            <value>
                User.hbm.xml
            </value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2ddl.auto">create</prop>
            <!-- Especificamos el valor minimo del pool de conexiones -->
            <prop key="hibernate.c3p0.minPoolSize">5</prop>
            <!-- Especificamos el valor maximo del pool de conexiones -->
            <prop key="hibernate.c3p0.maxPoolSize">20</prop>
            <!-- El tiempo de vida de cada conexion del pool. -->
            <prop key="hibernate.c3p0.timeout">600</prop>

        </props>
    </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">  
  <property name="sessionFactory" ref="sessionFactory" />  
 </bean>

<bean id="myUserDAO" class="service.User">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>

From my class I write:

ApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"service/service-dao.xml"});
private SessionFactory sessionFactory = (SessionFactory)context.getBean("sessionFactory");

And the manifest imports the needed packages to Spring and Hibernate, like this:

Require-Bundle: jdbc+hibernate
Import-Package: org.springframework.orm.hibernate3, org.apache.commons.dbcp, 
 org.springframework.beans.factory.annotation, 
 org.springframework.beans.factory.xml, 
 org.springframework.context,
 org.springframework.core.io,
 org.springframework.context.support

However, I get an exception which says the bundle doesn't find the class. But the package org.springframework.orm.hibernate3 is imported in the manifest.

org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [service/service-dao.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.LocalSessionFactoryBean not found from bundle [ZBGWTApp (ZBGWTApp;singleton:=true)]

Also, the bundles are ACTIVE and, of course, they export the packages:

55      ACTIVE      org.springframework.transaction_2.5.6
56      ACTIVE      org.springframework.orm_2.5.6
57      ACTIVE      org.springframework.jdbc_2.5.6
58      ACTIVE      org.apache.commons.pool_1.5.6
59      ACTIVE      org.apache.commons.dbcp_1.4.0

I don't know what is the reason, if all seems right.

The complete stacktrace is:

2011-06-07 07:36:59.570:WARN:/:Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type 'org.springframework.beans.factory.CannotLoadBeanClassException' was not assignable to 'com.google.gwt.user.client.rpc.IsSerializable' and did not have a custom field serializer.For security purposes, this type will not be serialized.: instance = org.springframework.beans.factory.CannotLoadBeanClassException: Error loading class [org.springframework.orm.hibernate3.LocalSessionFactoryBean] for bean with name 'sessionFactory' defined in class path resource [service/service-dao.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org.springframework.orm.hibernate3.LocalSessionFactoryBean not found from bundle [ZBGWTApp (ZBGWTApp;singleton:=true)]
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerialationStreamWriter.java:615)
    at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractializationStreamWriter.java:126)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:153)
    at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:535)
    at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:616)
    at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:390)
    at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
    at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
    at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at main.java.com.gwt.app.server.GreetingServiceImpl.service(GreetingServiceImpl.java:30)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.registry.internal.ServletManager$ServletWrapper.service(ServletManager.java:180)
    at org.eclipse.equinox.http.servlet.internal.ServletRegistration.service(ServletRegistration.java:61)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.processAlias(ProxyServlet.java:126)
    at org.eclipse.equinox.http.servlet.internal.ProxyServlet.service(ProxyServlet.java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.eclipse.equinox.http.jetty.internal.HttpServerManager$InternalHttpServiceServlet.service(HttpServerManager.java:318)
    at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
    at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)
    at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:939)
    at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
    at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)            
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

Thanks in advance!

Regards!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文