gpt4 book ai didi

java - Hibernate 4.1.3 Multi-Tenancy 空指针异常

转载 作者:行者123 更新时间:2023-11-29 09:13:49 25 4
gpt4 key购买 nike

我在使用 hibernate 4.1.3 的新 Multi-Tenancy 功能时遇到问题我将 Glassfish 3.1 与 JPA2 和 Hibernate 4.1.3 一起用作提供程序。

这是我的persistence.xml

<persistence version="2.0" 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">
<persistence-unit name="AuroraServicePU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/sqlserver/Aurora</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.default_batch_fetch_size" value="100"/>
<property name="hibernate.cache.use_second_level_cache" value="false"/>
<property name="hibernate.cache.use_query_cache" value="false"/>
<property name="hibernate.tenant_identifier_resolver" value="org.dna.aurora.web.TenantResolver" />
<property name="hibernate.multiTenancy" value="DISCRIMINATOR" />
</properties>
</persistence-unit>
</persistence>

这是我在尝试部署应用程序时遇到的异常。

INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} INFO: HHH000412: Hibernate Core {4.1.3.Final} INFO: HHH000206: hibernate.properties not found INFO: HHH000021: Bytecode provider name : javassist INFO: HHH000204: Processing PersistenceUnitInfo [ name: AuroraServicePU ...] SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method SEVERE: Exception while preparing the app SEVERE: The log message is null. java.lang.NullPointerException at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$MultiTenantConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:260) at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:117) at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2277) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2273) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1742) at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:76) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:205) at org.glassfish.persistence.jpa.PersistenceUnitLoader.(PersistenceUnitLoader.java:119) at org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:213) at org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486) at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:220) at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:166) at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:870) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410) at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240) at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370) at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370) at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067) at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247) at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235) at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:465) at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:222) at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168) at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117) at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234) at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822) at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225) at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90) at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59) at com.sun.grizzly.ContextTask.run(ContextTask.java:71) at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:619)

SEVERE: Exception while preparing the app

更新:我再次阅读了文档并注意到这个重要的信息和平:

DISCRIMINATOR Correlates to the partitioned (discriminator) approach. It is an error to attempt to open a session without a tenant identifier using this strategy. This strategy is not yet implemented in Hibernate as of 4.0 and 4.1. Its support is planned for 5.0.

这真的意味着鉴别器策略现在不可用吗?也许这就是全部问题?

任何帮助都会很棒。谢谢你,伊多。

最佳答案

您还没有指定 Hibernate 应该如何获取连接。您是否阅读过与此相关的文档? http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4583

具体来说: http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4658http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e4702

关于java - Hibernate 4.1.3 Multi-Tenancy 空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10727458/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com