JPA 2.1:无法访问数据库

时间:2015-12-19 20:37:37

标签: java spring maven jpa

家伙! 在重建我以前工作的Web项目之后,我遇到了一个问题:在配置之前无法访问数据库。我尝试通过main方法访问DB,但结果是一样的。我有一些项目备份,所有这些备份都无法访问数据库。 在persistence.xml中,我试图提到DB的完整路径,但是没有效果(以前这个配置工作正常)。 不幸的是,没有抛出异常,因此我无法找到问题所在。

配置:JPA 2.1,JDK 1.8.0_60,Maven,Spring 4.1

如果有任何关于如何追踪和解决问题的建议,我将不胜感激。

我的persistence.xml(方案声明被忽略):

    22:27:13.425 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
22:27:13.426 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor'
22:27:13.426 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalRequiredAnnotationProcessor'
22:27:13.426 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalCommonAnnotationProcessor'
22:27:13.426 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor'
22:27:13.426 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
22:27:13.427 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'transactionManager'
22:27:13.427 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating instance of bean 'transactionManager'
22:27:13.437 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Eagerly caching bean 'transactionManager' to allow for resolving potential circular references
22:27:13.451 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
22:27:13.452 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'transactionManager'
22:27:13.454 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Finished creating instance of bean 'transactionManager'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor#0'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'dataSource'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.aop.config.internalAutoProxyCreator'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.interceptor.TransactionInterceptor#0'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.transaction.config.internalTransactionAdvisor'
22:27:13.455 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor'
22:27:13.456 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor'
22:27:13.458 [main]      DEBUG org.springframework.context.support.ClassPathXmlApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [org.springframework.context.support.DefaultLifecycleProcessor@2611b9a3]
22:27:13.459 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
22:27:13.462 [main]      DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemProperties]
22:27:13.463 [main]      DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Searching for key 'spring.liveBeansView.mbeanDomain' in [systemEnvironment]
22:27:13.463 [main]      DEBUG org.springframework.core.env.PropertySourcesPropertyResolver - Could not find key 'spring.liveBeansView.mbeanDomain' in any property source. Returning [null]
22:27:13.463 [main]      DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'superUserServiceImpl'
22:27:13.756 [main]      DEBUG org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler - Creating new EntityManager for shared EntityManager invocation
[EL Info]: 2015-12-19 22:27:13.781--ServerSession(579294521)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.5.0.v20130507-3faac2b
[EL Config]: connection: 2015-12-19 22:27:13.791--ServerSession(579294521)--Connection(2109219177)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>DerbyPlatform
    user name=> ""
    connector=>JNDIConnector datasource name=>null
))
22:27:13.792 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
[EL Config]: connection: 2015-12-19 22:27:14.889--ServerSession(579294521)--Connection(2048102341)--Thread(Thread[main,5,main])--Connected: jdbc:derby:..//RestaurantDB1
    User: APP
    Database: Apache Derby  Version: 10.11.1.2 - (1629631)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.11.1.2 - (1629631)
[EL Config]: connection: 2015-12-19 22:27:14.891--ServerSession(579294521)--Connection(932885627)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>DerbyPlatform
    user name=> ""
    connector=>JNDIConnector datasource name=>null
))
22:27:14.891 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
[EL Config]: connection: 2015-12-19 22:27:14.897--ServerSession(579294521)--Connection(1313799195)--Thread(Thread[main,5,main])--Connected: jdbc:derby:..//RestaurantDB1
    User: APP
    Database: Apache Derby  Version: 10.11.1.2 - (1629631)
    Driver: Apache Derby Embedded JDBC Driver  Version: 10.11.1.2 - (1629631)
[EL Info]: connection: 2015-12-19 22:27:14.989--ServerSession(579294521)--Thread(Thread[main,5,main])--file:/D:/Підготовка до Канади/Джава/Java EE/project/DAily backup/ElectronicRestaurant/target/classes_Restaurant login successful
22:27:15.022 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
22:27:15.145 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
22:27:15.169 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
22:27:15.197 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
22:27:15.218 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
22:27:15.300 [main]      DEBUG org.springframework.jdbc.datasource.DriverManagerDataSource - Creating new JDBC DriverManager Connection to [jdbc:derby:..//RestaurantDB1;create=true]
[EL Fine]: sql: 2015-12-19 22:27:15.304--ServerSession(579294521)--Connection(456785282)--Thread(Thread[main,5,main])--SELECT ID, DATEOFBIRTH, DATEOFCREATION, DATEOFLASTLOGIN, DELIVERYADDRESS, EMAIL, ISACTIVE, LOGIN, NAME, PASSWORD, SURNAME, TYPEOFUSER FROM USERS WHERE (ID = ?)
    bind => [7]
22:27:15.323 [main]      DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
null

我的.log片段:

            <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.framework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.framework.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-agent</artifactId>
            <version>2.5.6.SEC03</version>
        </dependency>
        <!-- JSR-330 -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <!-- EL -->
        <dependency>
            <groupId>org.glassfish.web</groupId>
            <artifactId>el-impl</artifactId>
            <version>2.2</version>
        </dependency>

        <dependency>
            <groupId>com.sun.el</groupId>
            <artifactId>el-ri</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-api</artifactId>
            <version>${jsf.version}</version>
        </dependency>
        <dependency>
            <groupId>com.sun.faces</groupId>
            <artifactId>jsf-impl</artifactId>
            <version>${jsf.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
        </dependency>

        <dependency>
            <groupId>org.eclipse.persistence</groupId>
            <artifactId>eclipselink</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derby</artifactId>
            <version>10.10.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.derby</groupId>
            <artifactId>derbyclient</artifactId>
            <version>10.10.1.1</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.2.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>4.0.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>4.0.3.RELEASE</version>
</dependency>

一些依赖项:

{{1}}

0 个答案:

没有答案