无法完成架构更新:java.lang.UnsupportedOperationException:应用程序必须提供JDBC连接

时间:2014-04-22 12:21:50

标签: spring hibernate jpa

我正在尝试使用JPA(Hibernate提供程序)的简单Spring MVC应用程序。 当我运行应用程序时,我遇到以下错误:

   17:30:08,127 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringJpaWebDemo]] (MSC service thread 1-2) Destroying Spring FrameworkServlet 'spring'

   17:30:08,129 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-2) Closing WebApplicationContext for namespace 'spring-servlet': startup date [Tue Apr 22 17:19:32 IST 2014]; root of context hierarchy
   17:30:08,131 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-2) Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c8de07: defining beans [springLoginController,springStudentLinkController,springWebController,springWelcomeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; root of factory hierarchy
   17:30:08,138 INFO  [org.jboss.as.jpa] (MSC service thread 1-1) JBAS011403: Stopping Persistence Unit Service 'SpringJpaWebDemo.war#persistence'
   17:30:08,172 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment SpringJpaWebDemo.war in 46ms
   17:30:08,173 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015876: Starting deployment of "SpringJpaWebDemo.war"
   17:30:09,087 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011401: Read persistence.xml for persistence
   17:30:09,188 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
   17:30:09,192 INFO  [org.jboss.as.jpa] (MSC service thread 1-2) JBAS011402: Starting Persistence Unit Service 'SpringJpaWebDemo.war#persistence'
   17:30:09,193 INFO  [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-2) HHH000204: Processing PersistenceUnitInfo [
name: persistence
...]
   17:30:09,201 WARN  [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-2) HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections
   17:30:09,202 INFO  [org.hibernate.dialect.Dialect] (MSC service thread 1-2) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
   17:30:09,203 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (MSC service thread 1-2) HHH000422: Disabling contextual LOB creation as connection was null
   17:30:09,204 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (MSC service thread 1-2) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
   17:30:09,205 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (MSC service thread 1-2) HHH000397: Using ASTQueryTranslatorFactory
   17:30:09,211 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000228: Running hbm2ddl schema update
   17:30:09,212 INFO  [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000102: Fetching database metadata
   17:30:09,212 ERROR [org.hibernate.tool.hbm2ddl.SchemaUpdate] (MSC service thread 1-2) HHH000299: Could not complete schema update: java.lang.UnsupportedOperationException: The application must supply JDBC connections
at org.hibernate.service.jdbc.connections.internal.UserSuppliedConnectionProviderImpl.getConnection(UserSuppliedConnectionProviderImpl.java:62) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:194) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:178) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:457) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_17]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_17]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_17]

   17:30:09,221 WARN  [org.hibernate.internal.SessionFactoryImpl] (MSC service thread 1-2) HHH000008: JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()
   17:30:09,253 INFO  [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/SpringJpaWebDemo]] (MSC service thread 1-3) Initializing Spring FrameworkServlet 'spring'
   17:30:09,253 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-3) FrameworkServlet 'spring': initialization started
   17:30:09,268 INFO  [org.springframework.web.context.support.XmlWebApplicationContext] (MSC service thread 1-3) Refreshing WebApplicationContext for namespace 'spring-servlet': startup date [Tue Apr 22 17:30:09 IST 2014]; root of context hierarchy
   17:30:09,298 INFO  [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (MSC service thread 1-3) Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-servlet.xml]
   17:30:09,334 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-3) JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
   17:30:09,335 INFO  [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] (MSC service thread 1-3) JSR-330 'javax.inject.Named' annotation found and supported for component scanning
   17:30:09,398 INFO  [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (MSC service thread 1-3) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
   17:30:09,405 INFO  [org.springframework.beans.factory.support.DefaultListableBeanFactory] (MSC service thread 1-3) Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1032e70: defining beans [springLoginController,springStudentLinkController,springWebController,springWelcomeController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.web.servlet.view.InternalResourceViewResolver#0]; root of factory hierarchy
   17:30:09,461 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/show] onto handler [com.controller.SpringLoginController@937c13]
   17:30:09,462 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/show.*] onto handler [com.controller.SpringLoginController@937c13]
   17:30:09,463 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/show/] onto handler [com.controller.SpringLoginController@937c13]
   17:30:09,464 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/student] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,465 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/student.*] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,466 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/student/] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,467 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/studentformsubmit] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,468 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/studentformsubmit.*] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,468 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/studentformsubmit/] onto handler [com.controller.SpringStudentLinkController@6f0093]
   17:30:09,469 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/hello] onto handler [com.controller.SpringWebController@18eb424]
   17:30:09,470 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/hello.*] onto handler [com.controller.SpringWebController@18eb424]
   17:30:09,471 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/hello/] onto handler [com.controller.SpringWebController@18eb424]
   17:30:09,472 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/welcome] onto handler [com.controller.SpringWelcomeController@1d4cb29]
   17:30:09,473 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/welcome.*] onto handler [com.controller.SpringWelcomeController@1d4cb29]
   17:30:09,474 INFO  [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] (MSC service thread 1-3) Mapped URL path [/welcome/] onto handler [com.controller.SpringWelcomeController@1d4cb29]
   17:30:09,515 INFO  [org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-3) FrameworkServlet 'spring': initialization completed in 261 ms
   17:30:09,516 INFO  [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /SpringJpaWebDemo
   17:30:09,648 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018565: Replaced deployment "SpringJpaWebDemo.war" with deployment "SpringJpaWebDemo.war"

我在WEB-INF / lib文件夹中添加了以下jar:

antlr-2.7.7.jar
commons-logging-1.0.4.jar
dom4j-1.6.1.jar
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.2.0.final.jar
hibernate-entitymanager-4.2.0.final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
hibernate-validator-4.3.1.final.jar
javassist-3.15.0-ga.jar
javax.persistence.jar
jboss-logging-3.1.2.GA.jar
jboss-logmanager-1.4.0.final.jar
jboss-transaction-api_1.1_spec-1.0.1.final.jar
log4j-jboss-logmanager-1.0.1.final.jar
mysql-connector-java-5.1.24-bin.jar
org.springframework.asm-3.0.3.RELEASE.jar
org.springframework.beans-3.0.4.RELEASE.jar
org.springframework.context-3.0.3.RELEASE.jar
org.springframework.core-3.0.4.RELEASE.jar
org.springframework.expression-3.0.4.RELEASE.jar
org.springframework.web.servlet-3.0.3.RELEASE.jar
org.springframework.web-3.0.3.RELEASE.jar
servlet-api.jar

这是我的persistence.xml文件:

<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="2.0">
<persistence-unit name="persistence" transaction-type="RESOURCE_LOCAL">

    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <!-- <class>com.geowarin.hibernate.jpa.standalone.model.User</class> -->
    <class>com.entity.Student</class>

    <properties>

        <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" /> 
        <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/bnt" /> 
        <property name="javax.persistence.jdbc.user" value="root" />
        <property name="javax.persistence.jdbc.password" value="bnt123" /> 

        <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
        <property name="hibernate.hbm2ddl.auto" value="update" />

        <!-- <property name="hibernate.hbm2ddl.import_files" value="sql/import-users.sql" /> --> 
        <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.format_sql" value="false" />
    </properties>

</persistence-unit>

我对这些错误一无所知。我是第一次尝试这个。请让我知道我在这个应用程序中做了什么错误。请告诉我是否需要罐子。非常感谢你提前。

0 个答案:

没有答案