创建 EntityManager 时 INFORMATION_SCHEMA 不存在错误(JPA + SPRING + H2)

发布于 2024-10-21 00:09:38 字数 12256 浏览 6 评论 0原文

我对 JPA (OpenJPA) + Spring (使用 Spring Web MVC 的 Web Flow) + H2 数据库引擎有问题。我为我的简单 Web 应用程序提供了简单的 RegisterDAO。我正在使用依赖项注入将 EntityManagerFactory (通过 @PersistentUnit 注释)注入到我的 RegisterDAO 中。一切看起来都不错(EntityManagerFactory 不为空,它似乎被注入),但是当我尝试从这个工厂创建 EntityManager 时出现问题。 GlassFish(我使用的)抛出一个类似这样的异常(无法以原始方式打印,因为消息是波兰语:)):

org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'register' of flow 'register'
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
Caused by: <openjpa-2.0.1-r422266:989424 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Schema 'INFORMATION_SCHEMA' doesn't exists {SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES} [code=-1, state=42Y07]
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:556)
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:155)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:117)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
    at com.sun.enterprise.container.common.impl.EntityManagerFactoryWrapper.createEntityManager(EntityManagerFactoryWrapper.java:101)
    at umk.dumont.db.dao.RegisterDAO.checkIfLoginIsFree(RegisterDAO.java:156)
    at umk.dumont.services.RegisterService.validateForm(RegisterService.java:95)
    at umk.dumont.models.RegisterFormModel.validateRegister(RegisterFormModel.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:186)
    at org.springframework.webflow.validation.ValidationHelper.invokeValidateMethodForCurrentState(ValidationHelper.java:122)
    at org.springframework.webflow.validation.ValidationHelper.invokeModelValidationMethod(ValidationHelper.java:109)
    at org.springframework.webflow.validation.ValidationHelper.validate(ValidationHelper.java:101)
    at org.springframework.webflow.mvc.view.AbstractMvcView.validate(AbstractMvcView.java:625)
    at org.springframework.webflow.mvc.view.AbstractMvcView.processUserEvent(AbstractMvcView.java:217)
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:248)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:218)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 34 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Schema 'INFORMATION_SCHEMA' doesn't exists {SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES} [code=-1, state=42Y07]
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:273)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:253)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:70)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:305)
    at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
    at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:155)
    at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:175)
    at org.apache.openjpa.jdbc.sql.DBDictionary.prepareStatement(DBDictionary.java:5131)
    at org.apache.openjpa.jdbc.sql.DBDictionary.getSequences(DBDictionary.java:3942)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSequences(SchemaGenerator.java:960)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchema(SchemaGenerator.java:365)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:300)
    at org.apache.openjpa.jdbc.schema.SchemaTool.getDBSchemaGroup(SchemaTool.java:1142)
    at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:348)
    at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:325)
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:504)
    ... 61 more

这很奇怪,因为当我使用 H2 控制台并输入“SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES “一切正常(我看到这组名为 INFORMATION_SCHEMA 的表)。当然,我将这个 sql 语句称为登录用户名,我在 persistence.xml 文件中使用它。

有什么想法吗?

编辑: 我的配置: persistence.xml:

<property name="openjpa.ConnectionDriverName" value="org.h2.Driver"/>
  <property name="openjpa.ConnectionURL" value="jdbc:h2:F:\baza"/>
  <property name="openjpa.ConnectionUserName" value="sa"/>
  <property name="openjpa.ConnectionPassword" value="haslodobazy"/>
  <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO"/>
  <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

spring的applicationCotext.xml:

<jee:jndi-lookup id="entityManagerFactory" jndi-name="myPersistenceUnit"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<bean id="registerDaoImpl" class="umk.dumont.db.dao.RegisterDAO" />

<bean id="service" class="umk.dumont.services.RegisterService">
    <property name="registerDAO" ref="registerDaoImpl"/>
</bean>
<bean class="umk.dumont.models.RegisterFormModel">
    <property name="service" ref="service"/>
</bean> 

web配置:

<persistence-unit-ref>
    <persistence-unit-ref-name>myPersistenceUnit</persistence-unit-ref-name>
    <persistence-unit-name>persistenceUnitNameFromPersistenceXML</persistence-unit-name>
</persistence-unit-ref>

我使用maven,我的依赖项:

<dependencies>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jpa</artifactId>
        <version>2.0.8</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-binding</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-js</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-webflow</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
     <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa</artifactId>
        <version>2.0.1</version>
        <!--<scope>runtime</scope>-->
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.150</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.2</version>
        <scope>test</scope>
    </dependency>

I have a problem with JPA (OpenJPA) + Spring (Web Flow using Spring Web MVC) + H2 database engine. I've got simple RegisterDAO for my simple web application. I am using dependency injection to inject EntityManagerFactory (by @PersistentUnit annotation) to my RegisterDAO. Everything looks ok (EntityManagerFactory is not null, it seems to be injected) but problem occurs when I'm trying to create EntityManager from this factory. GlassFish (which i use) throw an exception something like this (can't print in original, because message is in Polish :)):

org.springframework.webflow.execution.FlowExecutionException: Exception thrown in state 'register' of flow 'register'
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:569)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)
    at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
    at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
    at org.springframework.webflow.mvc.servlet.FlowController.handleRequest(FlowController.java:174)
    at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:788)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:717)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1523)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:188)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:641)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:85)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:185)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:325)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:226)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:165)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
    at java.lang.Thread.run(Thread.java:619)
Caused by: <openjpa-2.0.1-r422266:989424 nonfatal general error> org.apache.openjpa.persistence.PersistenceException: Schema 'INFORMATION_SCHEMA' doesn't exists {SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES} [code=-1, state=42Y07]
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:556)
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:456)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:155)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
    at org.apache.openjpa.jdbc.kernel.JDBCBrokerFactory.newBrokerImpl(JDBCBrokerFactory.java:117)
    at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:212)
    at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:156)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:227)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:154)
    at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:60)
    at com.sun.enterprise.container.common.impl.EntityManagerFactoryWrapper.createEntityManager(EntityManagerFactoryWrapper.java:101)
    at umk.dumont.db.dao.RegisterDAO.checkIfLoginIsFree(RegisterDAO.java:156)
    at umk.dumont.services.RegisterService.validateForm(RegisterService.java:95)
    at umk.dumont.models.RegisterFormModel.validateRegister(RegisterFormModel.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:186)
    at org.springframework.webflow.validation.ValidationHelper.invokeValidateMethodForCurrentState(ValidationHelper.java:122)
    at org.springframework.webflow.validation.ValidationHelper.invokeModelValidationMethod(ValidationHelper.java:109)
    at org.springframework.webflow.validation.ValidationHelper.validate(ValidationHelper.java:101)
    at org.springframework.webflow.mvc.view.AbstractMvcView.validate(AbstractMvcView.java:625)
    at org.springframework.webflow.mvc.view.AbstractMvcView.processUserEvent(AbstractMvcView.java:217)
    at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:248)
    at org.springframework.webflow.engine.ViewState.resume(ViewState.java:218)
    at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
    at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)
    ... 34 more
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Schema 'INFORMATION_SCHEMA' doesn't exists {SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES} [code=-1, state=42Y07]
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:273)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:253)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$000(LoggingConnectionDecorator.java:70)
    at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection.prepareStatement(LoggingConnectionDecorator.java:305)
    at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:186)
    at org.apache.openjpa.lib.jdbc.ConfiguringConnectionDecorator$ConfiguringConnection.prepareStatement(ConfiguringConnectionDecorator.java:155)
    at org.apache.openjpa.lib.jdbc.DelegatingConnection.prepareStatement(DelegatingConnection.java:175)
    at org.apache.openjpa.jdbc.sql.DBDictionary.prepareStatement(DBDictionary.java:5131)
    at org.apache.openjpa.jdbc.sql.DBDictionary.getSequences(DBDictionary.java:3942)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSequences(SchemaGenerator.java:960)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchema(SchemaGenerator.java:365)
    at org.apache.openjpa.jdbc.schema.SchemaGenerator.generateSchemas(SchemaGenerator.java:300)
    at org.apache.openjpa.jdbc.schema.SchemaTool.getDBSchemaGroup(SchemaTool.java:1142)
    at org.apache.openjpa.jdbc.schema.SchemaTool.add(SchemaTool.java:348)
    at org.apache.openjpa.jdbc.schema.SchemaTool.run(SchemaTool.java:325)
    at org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:504)
    ... 61 more

This is strange, because when I use H2 Console and type "SELECT SEQUENCE_SCHEMA, SEQUENCE_NAME FROM INFORMATION_SCHEMA.SEQUENCES" everything is ok (I see this set of tables named INFORMATION_SCHEMA). Of course I call this sql statement logged in username which I use in my persistence.xml file.

Any ideas?

EDIT:
My configs:
persistence.xml:

<property name="openjpa.ConnectionDriverName" value="org.h2.Driver"/>
  <property name="openjpa.ConnectionURL" value="jdbc:h2:F:\baza"/>
  <property name="openjpa.ConnectionUserName" value="sa"/>
  <property name="openjpa.ConnectionPassword" value="haslodobazy"/>
  <property name="openjpa.Log" value="DefaultLevel=TRACE, Tool=INFO"/>
  <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>

applicationCotext.xml for spring:

<jee:jndi-lookup id="entityManagerFactory" jndi-name="myPersistenceUnit"/>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
<bean id="registerDaoImpl" class="umk.dumont.db.dao.RegisterDAO" />

<bean id="service" class="umk.dumont.services.RegisterService">
    <property name="registerDAO" ref="registerDaoImpl"/>
</bean>
<bean class="umk.dumont.models.RegisterFormModel">
    <property name="service" ref="service"/>
</bean> 

web config:

<persistence-unit-ref>
    <persistence-unit-ref-name>myPersistenceUnit</persistence-unit-ref-name>
    <persistence-unit-name>persistenceUnitNameFromPersistenceXML</persistence-unit-name>
</persistence-unit-ref>

I use maven, my dependencies:

<dependencies>
    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.1.2</version>
    </dependency>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-web-api</artifactId>
        <version>6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.0.5.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jpa</artifactId>
        <version>2.0.8</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-binding</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-js</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-webflow</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>
     <dependency>
        <groupId>org.apache.openjpa</groupId>
        <artifactId>openjpa</artifactId>
        <version>2.0.1</version>
        <!--<scope>runtime</scope>-->
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.150</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.2</version>
        <scope>test</scope>
    </dependency>

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如若梦似彩虹 2024-10-28 00:09:38

问题是您实际上使用的是 Apache Derby 而不是 H2。原因:H2中没有这样的错误信息或代码。但是,Apache Derby 在运行此语句时恰好使用此消息和代码。

您能检查一下配置吗?您在某处使用 jdbc:derby:... 而不是 jdbc:h2:...

The problem is that you are actually using Apache Derby and not H2. Reason: there is no such error message or code within H2. However, Apache Derby uses exactly this message and code when running this statement.

Could you please check the configuration? Somewhere you are using jdbc:derby:... instead of jdbc:h2:...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文