glassfish 和 h2database 问题
Posted
技术标签:
【中文标题】glassfish 和 h2database 问题【英文标题】:glassfish and h2database problem 【发布时间】:2011-06-23 13:35:18 【问题描述】:我构建了一个基于 java 的应用程序。使用休眠 JPA、spring 和 h2database。我在内存模式下使用 h2database,这里是 jdbc 属性:
jdbc.url=jdbc\:h2\:mem\:test_db;DB_CLOSE_DELAY\=-1
jdbc.driverClassName=org.h2.Driver
jdbc.username=sa
jdbc.password=
我在 dataSource.xml 中使用的值如下:
<bean id="basicDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="$jdbc.driverClassName" />
<property name="url" value="$jdbc.url" />
<property name="username" value="$jdbc.username" />
<property name="password" value="$jdbc.password"/>
</bean>
我正在使用两个应用上下文,第一个:
<context:property-placeholder location="classpath*:META-INF/spring/*.properties"/>
<context:component-scan base-package="com.test.webtest">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
<import resource="basicDataSource.xml"/>
第二个:
<context:component-scan base-package="com.test.webtest.persistence.dao.jpa"/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="basicDataSource"/>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven mode="aspectj" transaction-manager="transactionManager"/>
我加载了这两个应用程序。 web.xml 文件中的上下文如下:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:META-INF/spring/applicationContext.xml
classpath*:META-INF/spring/applicationContext-persistence.xml
</param-value>
</context-param>
最后是我的 persistence.xml 配置:
<persistence-unit name="basicPersistenceUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.H2Dialect"/>
<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.connection.charSet" value="UTF-8"/>
<property name="hibernate.show_sql" value="true"/>
</properties>
</persistence-unit>
但是当我尝试将这个jar部署到应用容器时,出现了下一个错误:
[#|2011-06-23T14:41:42.769+0200|WARNING|glassfish3.1|org.apache.catalina.connector.Request|_ThreadID=22;_ThreadName=Thread-2;|PWC4011: Unable to set request character encoding to UTF-8 from context , because request parameters have already been read, or ServletRequest.getReader() has already been called|#]
[#|2011-06-23T14:41:42.909+0200|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=88;_ThreadName=Thread-2;|===== GUI deployment: needUploadToTempfile ======|#]
[#|2011-06-23T14:41:42.925+0200|INFO|glassfish3.1|org.glassfish.admingui|_ThreadID=22;_ThreadName=Thread-2;|======= uploadFileName=webFrontend-1.0-SNAPSHOT.war|#]
[#|2011-06-23T14:41:42.928+0200|INFO|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=88;_ThreadName=Thread-2;|===== filePath=/private/var/folders/m+/m+kO87fOGXS5o7r3iUMGR++++TI/-Tmp-/webFrontend-18640431189413583797.0-SNAPSHOT.war origPath=webFrontend-1|#]
[#|2011-06-23T14:41:47.456+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:47.964+0200|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=88;_ThreadName=Thread-2;|SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".|#]
[#|2011-06-23T14:41:47.964+0200|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=88;_ThreadName=Thread-2;|SLF4J: Defaulting to no-operation (NOP) logger implementation|#]
[#|2011-06-23T14:41:47.965+0200|SEVERE|glassfish3.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=88;_ThreadName=Thread-2;|SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.|#]
[#|2011-06-23T14:41:49.078+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:49.155+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:49.173+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:49.393+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=88;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.|#]
[#|2011-06-23T14:41:49.398+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors|_ThreadID=88;_ThreadName=Thread-2;|RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.|#]
[#|2011-06-23T14:41:49.401+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.gjc.spi|_ThreadID=88;_ThreadName=Thread-2;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.]|#]
[#|2011-06-23T14:41:49.740+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:49.745+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:49.758+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.enterprise.resource.allocator|_ThreadID=88;_ThreadName=Thread-2;|RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.|#]
[#|2011-06-23T14:41:49.759+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.enterprise.connectors|_ThreadID=88;_ThreadName=Thread-2;|RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.|#]
[#|2011-06-23T14:41:49.760+0200|WARNING|glassfish3.1|javax.enterprise.resource.resourceadapter.com.sun.gjc.spi|_ThreadID=88;_ThreadName=Thread-2;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException : Error connecting to server localhost on port 1527 with message Connection refused.]|#]
[#|2011-06-23T14:41:50.108+0200|INFO|glassfish3.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=88;_ThreadName=Thread-2;|PWC1412: WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext|#]
[#|2011-06-23T14:41:50.109+0200|INFO|glassfish3.1|org.springframework.web.context.ContextLoader|_ThreadID=22;_ThreadName=Thread-2;|Root WebApplicationContext: initialization started|#]
[#|2011-06-23T14:41:50.278+0200|INFO|glassfish3.1|org.springframework.web.context.support.XmlWebApplicationContext|_ThreadID=22;_ThreadName=Thread-2;|Refreshing Root WebApplicationContext: startup date [Thu Jun 23 14:41:50 CEST 2011]; root of context hierarchy|#]
[#|2011-06-23T14:41:50.483+0200|INFO|glassfish3.1|org.springframework.beans.factory.xml.XmlBeanDefinitionReader|_ThreadID=22;_ThreadName=Thread-2;|Loading XML bean definitions from URL [file:/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/applicationContext.xml]|#]
[#|2011-06-23T14:41:50.747+0200|INFO|glassfish3.1|org.springframework.context.annotation.ClassPathBeanDefinitionScanner|_ThreadID=22;_ThreadName=Thread-2;|JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning|#]
[#|2011-06-23T14:41:50.750+0200|INFO|glassfish3.1|org.springframework.context.annotation.ClassPathBeanDefinitionScanner|_ThreadID=22;_ThreadName=Thread-2;|JSR-330 'javax.inject.Named' annotation found and supported for component scanning|#]
[#|2011-06-23T14:41:50.892+0200|INFO|glassfish3.1|org.springframework.beans.factory.xml.XmlBeanDefinitionReader|_ThreadID=22;_ThreadName=Thread-2;|Loading XML bean definitions from URL [file:/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/basicDataSource.xml]|#]
[#|2011-06-23T14:41:50.916+0200|INFO|glassfish3.1|org.springframework.beans.factory.xml.XmlBeanDefinitionReader|_ThreadID=22;_ThreadName=Thread-2;|Loading XML bean definitions from URL [file:/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/applicationContext-persistence.xml]|#]
[#|2011-06-23T14:41:50.976+0200|INFO|glassfish3.1|org.springframework.context.annotation.ClassPathBeanDefinitionScanner|_ThreadID=22;_ThreadName=Thread-2;|JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning|#]
[#|2011-06-23T14:41:50.978+0200|INFO|glassfish3.1|org.springframework.context.annotation.ClassPathBeanDefinitionScanner|_ThreadID=22;_ThreadName=Thread-2;|JSR-330 'javax.inject.Named' annotation found and supported for component scanning|#]
[#|2011-06-23T14:41:51.501+0200|INFO|glassfish3.1|org.springframework.beans.factory.config.PropertyPlaceholderConfigurer|_ThreadID=22;_ThreadName=Thread-2;|Loading properties file from file [/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/database.properties]|#]
[#|2011-06-23T14:41:51.515+0200|INFO|glassfish3.1|org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor|_ThreadID=22;_ThreadName=Thread-2;|JSR-330 'javax.inject.Inject' annotation found and supported for autowiring|#]
[#|2011-06-23T14:41:51.579+0200|INFO|glassfish3.1|org.springframework.beans.factory.support.DefaultListableBeanFactory|_ThreadID=22;_ThreadName=Thread-2;|Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@174faf5: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,basicDataSource,PersonDao,entityManagerFactory,transactionManager,org.springframework.transaction.config.internalTransactionAspect]; root of factory hierarchy|#]
[#|2011-06-23T14:41:51.795+0200|INFO|glassfish3.1|org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean|_ThreadID=22;_ThreadName=Thread-2;|Building JPA container EntityManagerFactory for persistence unit 'basicPersistenceUnit'|#]
[#|2011-06-23T14:41:51.802+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:51.808+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:51.811+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:52.592+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:52.594+0200|INFO|glassfish3.1|org.hibernate.validator.engine.resolver.DefaultTraversableResolver|_ThreadID=22;_ThreadName=Thread-2;|Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.|#]
[#|2011-06-23T14:41:52.615+0200|INFO|glassfish3.1|org.springframework.beans.factory.support.DefaultListableBeanFactory|_ThreadID=22;_ThreadName=Thread-2;|Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@174faf5: defining beans [org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,basicDataSource,PersonDao,entityManagerFactory,transactionManager,org.springframework.transaction.config.internalTransactionAspect]; root of factory hierarchy|#]
[#|2011-06-23T14:41:52.657+0200|SEVERE|glassfish3.1|org.springframework.web.context.ContextLoader|_ThreadID=22;_ThreadName=Thread-2;|Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'PersonDao': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:341)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4690)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:534)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5305)
at com.sun.enterprise.web.WebModule.start(WebModule.java:500)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:755)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1980)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1630)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:100)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:286)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
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 org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDeploymentFacility.java:143)
at org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:406)
at org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:100)
at org.glassfish.admingui.common.util.DeployUtil.deploy(DeployUtil.java:76)
at org.glassfish.admingui.common.handlers.DeploymentHandler.deploy(DeploymentHandler.java:191)
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 com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
at com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
at com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150)
at com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98)
at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
at javax.faces.component.UICommand.broadcast(UICommand.java:300)
at com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:223)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
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:680)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [file:/opt/glassfish3/glassfish3/glassfish/domains/domain1/applications/webFrontend-1.0-SNAPSHOT/WEB-INF/classes/META-INF/spring/applicationContext-persistence.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findDefaultEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:529)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findEntityManagerFactory(PersistenceAnnotationBeanPostProcessor.java:495)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.resolveEntityManager(PersistenceAnnotationBeanPostProcessor.java:656)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor$PersistenceElement.getResourceToInject(PersistenceAnnotationBeanPostProcessor.java:629)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:156)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:338)
... 89 more
我注意到日志开头有一个警告。有一些关于拒绝连接到端口 1527 的问题。我的问题是,我必须在 glassfish 上配置一个 JDBC 连接池以在内存 h2database 中使用,还是问题出在其他地方?
【问题讨论】:
你在哪里实例化 h2database? 【参考方案1】:因为你的主要问题是:
javax.persistence.PersistenceException: [PersistenceUnit: basicPersistenceUnit] Unable to build EntityManagerFactory
查看您的 persistence.xml,我认为您应该尝试在其中插入数据库配置属性。我根据 JPA 的其他经验告诉您这一点,但与 Spring 无关(正如我在您与数据源绑定的其他配置文件中看到的那样。)
快速搜索了一下,发现你有两种使用Spring和JPA的方法;更推荐的是你开始使用“LocalContainerEntityManagerFactoryBean”,但没有指向“dataSource”,使用“persistence.xml”文件让它到JPA。
查看此翻译教程了解更多信息:http://translate.google.com.br/translate?hl=en&sl=pt&tl=en&u=http%3A%2F%2Ffabiolnm.blogspot.com%2F2009%2F11%2Fintegracao-spring-x-jpa.html
【讨论】:
我尝试在 tomcat 上运行此配置,并且运行良好。只有我改变的是从“JPA”到“LOCAL_RESOURCES”的事务类型见这篇文章***.com/questions/6473808/… 好的@pierre-tautou。我试图在那里回答你的问题。但是,即使您在此处遇到的这个问题已通过“JPA/RESOURCE_LOCAL”更改得到解决,我还是建议您尝试我喜欢的教程,因为它讨论了 JPA/SPRING 集成的良好实践。如果我的答案很好,请投票! =]【参考方案2】:我在某处听说 Glassfish 无法识别 JDBC 连接池中的空密码。事实上,使用 Tomcat 解决了您的问题。
【讨论】:
以上是关于glassfish 和 h2database 问题的主要内容,如果未能解决你的问题,请参考以下文章