2

我们使用 Jdeveloper 11.1.1.4 和 WLS 10.3 我尝试根据此链接在我的项目中使用 Hibernate,https: //forums.oracle.com/forums/thread.jspa?threadID= 1063416 我想使用 Hibernate 工具,因为 toplink 和eclipselink 无法解决关于在模式上生成更新 ddl 的问题,他们只能重新创建表 - 而不是真正的更新。

首先我从互联网上得到了相关的罐子:http ://www.2hotfile.com/di-LSBU.png

cglib-2.2
antlr-2.7.6
commons-collections-3.1
dom4j-1.6.1
hibernate3
hibernate-validator-4.1.0.Final
javassist-3.9.0.GA
jta-1.1
slf4j-api-1.5.11
slf4j-nop-1.5.11

然后我将模型项目添加为库依赖项:http ://www.2hotfile.com/di-GMSZ.png

配置persistence.xml如下:

<?xml version="1.0" encoding="windows-1252" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="1.0">
<persistence-unit name="VakkoEJBModel" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/VakkoDS</jta-data-source>

<properties>
<property name="hibernate.jndi.url" value="t3://127.0.0.1:7001" />
<property name="hibernate.connection.datasource" value="jdbc/VakkoDS" />
<property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.current_session_context_class" value="jta" />
</properties>
</persistence-unit>
</persistence>

weblogic-application.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
<weblogic-application>
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.hibernate.*</package-name>
<!-- package-name>org.apache.commons.logging.*</package-name -->
<!-- package-name>org.w3c.dom.*</package-name -->
</prefer-application-packages>
</weblogic-application>
weblogic-ejb-jar.xml
<?xml version = '1.0' encoding = 'UTF-8'?>
<weblogic-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd"
xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar">

weblogic-ejb-jar.xml

</weblogic-ejb-jar>
ejb-jar.xml
<?xml version="1.0" encoding="windows-1252" ?>
<ejb-jar/>

我在 setDomainEnv.cmd 中添加了该行:

set EXT_PRE_CLASSPATH=C:\jarlar\hibernate-3.3.2\antlr-2.7.6.jar;C:\jarlar\hibernate-3.3.2\commons-collections-3.1.jar;C:\jarlar\hibernate-3.3.2\dom4j-1.6.1.jar;C:\jarlar\hibernate-3.3.2\hibernate3.jar;C:\jarlar\hibernate-3.3.2\javassist-3.9.0.GA.jar;C:\jarlar\hibernate-3.3.2\jta-1.1.jar;C:\jarlar\hibernate-3.3.2\slf4j-api-1.5.11.jar;C:\jarlar\hibernate-3.3.2\slf4j-nop-1.5.11.jar;C:\jarlar\hibernate-3.3.2\bytecode\cglib\cglib-2.2.jar;C:\Oracle\Middleware_11.1.1.4\modules\ejb3-persistence-3.3.1.jar;hibernate-validator-4.1.0.Final.jar;

单击这些链接可以查看部署配置文件:http://www.2hotfile.com/di-XV68.png http://www.2hotfile.com/di-8YC9.png http://www.2hotfile.com/ di-ADR4.png

我试图根据这些信息操纵ear文件内容:http: //middlewaremagic.com/weblogic/wp-content/uploads/2010/06/EAR_Application_Diagram.jpg

在 ear\META-INF\application.xml 下

<?xml version = '1.0' encoding = 'windows-1252'?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_5.xsd" version="5" xmlns="http://java.sun.com/xml/ns/javaee">
<display-name>ejb1</display-name>
<module>
<ejb>ejb1.jar</ejb>
</module>
</application>

在 ear\META-INF\weblogic-application.xml 下

<?xml version = '1.0' encoding = 'windows-1254'?>
<weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-application">
<prefer-application-packages>
<package-name>org.hibernate.*</package-name>
<package-name>antlr.*</package-name>
<!-- package-name>org.apache.commons.logging.*</package-name -->
<!-- package-name>org.w3c.dom.*</package-name -->
</prefer-application-packages>
<listener>
<listener-class>oracle.adf.share.weblogic.listeners.ADFApplicationLifecycleListener</listener-class>
</listener>
<listener>
<listener-class>oracle.mds.lcm.weblogic.WLLifecycleListener</listener-class>
</listener>
<library-ref>
<library-name>adf.oracle.domain</library-name>
</library-ref>
</weblogic-application>

ejb1.ear\ejb1.jar\META-INF\ 目录中的文件与模型项目的源文件夹相同(这些文件是由 jdeveloper 部署过程根据前面解释的部署配置文件创建的)

耳朵内容显示该链接:http ://www.2hotfile.com/di-23X6.png

当我在浏览器方法中使用 JDeveloper 或 weblogic/console/ 将项目部署到 weblogic 时。但是出现异常

<10-Dec-2012 16:31:54 o'clock EET> <Warning> <netuix> <BEA-423420> <Redirect is executed in begin or refresh action. Redirect url is /console/console.portal?_nfpb=true&_pageLabel=AppDeploymentsControlPage.> 
<10-Dec-2012 16:32:45 o'clock EET> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1355149965087' for task '2'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(ejb1.jar)
'
weblogic.application.ModuleException: Exception preparing module: EJBModule(ejb1.jar)

at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:469)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
Truncated. see log file for complete stacktrace
Caused By: weblogic.deployment.EnvironmentException: Error processing persistence unit VakkoEJBModel of module ejb1.jar: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit VakkoEJBModel: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence
at weblogic.deployment.BasePersistenceUnitInfoImpl.getPersistenceProvider(BasePersistenceUnitInfoImpl.java:375)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:39)
Truncated. see log file for complete stacktrace
<10-Dec-2012 16:32:45 o'clock EET> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'ejb1'.> 
<10-Dec-2012 16:32:45 o'clock EET> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: Exception preparing module: EJBModule(ejb1.jar)

at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:469)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
Truncated. see log file for complete stacktrace
Caused By: weblogic.deployment.EnvironmentException: Error processing persistence unit VakkoEJBModel of module ejb1.jar: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit VakkoEJBModel: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence
at weblogic.deployment.BasePersistenceUnitInfoImpl.getPersistenceProvider(BasePersistenceUnitInfoImpl.java:375)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:39)
Truncated. see log file for complete stacktrace
<10-Dec-2012 16:32:45 o'clock EET> <Error> <Console> <BEA-240003> <Console encountered the following error weblogic.application.ModuleException: Exception preparing module: EJBModule(ejb1.jar)

at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:469)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:517)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:159)
at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:45)
at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:613)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:184)
at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:58)
at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207)
at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98)
at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747)
at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216)
at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250)
at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:171)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:13)
at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:46)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)
Caused by: weblogic.deployment.EnvironmentException: Error processing persistence unit VakkoEJBModel of module ejb1.jar: Error instantiating the Persistence Provider class org.hibernate.ejb.HibernatePersistence of the PersistenceUnit VakkoEJBModel: java.lang.ClassNotFoundException: org.hibernate.ejb.HibernatePersistence

at weblogic.deployment.BasePersistenceUnitInfoImpl.getPersistenceProvider(BasePersistenceUnitInfoImpl.java:375)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:393)
at weblogic.deployment.BasePersistenceUnitInfoImpl.initializeEntityManagerFactory(BasePersistenceUnitInfoImpl.java:386)
at weblogic.deployment.BasePersistenceUnitInfoImpl.<init>(BasePersistenceUnitInfoImpl.java:158)
at weblogic.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:39)
at weblogic.deployment.AbstractPersistenceUnitRegistry.storeDescriptors(AbstractPersistenceUnitRegistry.java:349)
at weblogic.deployment.AbstractPersistenceUnitRegistry.loadPersistenceDescriptor(AbstractPersistenceUnitRegistry.java:263)
at weblogic.deployment.ModulePersistenceUnitRegistry.<init>(ModulePersistenceUnitRegistry.java:69)
at weblogic.ejb.container.deployer.EJBModule.setupPersistenceUnitRegistry(EJBModule.java:223)
at weblogic.ejb.container.deployer.EJBModule$1.execute(EJBModule.java:324)
at weblogic.deployment.PersistenceUnitRegistryInitializer.setupPersistenceUnitRegistries(PersistenceUnitRegistryInitializer.java:62)
at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:393)

我的错误或不完整是什么?请帮助我并原谅我糟糕的英语。提前致谢

4

1 回答 1