【发布时间】:2015-10-15 01:05:30
【问题描述】:
您好,我正在尝试在使用休眠的项目中使用 spring。我正面临使它工作的问题,我不知道是什么原因造成的。 我试图用 spring 做一个新项目,它工作正常。所以我猜测hibernate和spring有冲突。
我已经搜索了几个小时,他们都说 web.xml 不在 WEB-INF 文件夹中。但我的 web.xml 与 spring-dispatcher-servlet.xml 和 jsp 一起在 WEB-INF 中。
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Test</display-name>
<servlet>
<servlet-name>spring-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
spring-dispatcher-servlet.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.test.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
错误:
07:59:43,043 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final-redhat-1
07:59:43,293 INFO [org.jboss.msc] (main) JBoss MSC version 1.1.5.Final-redhat-1
07:59:43,362 INFO [org.jboss.as] (MSC service thread 1-7) JBAS015899: JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19) starting
07:59:44,521 WARN [org.jboss.as.server.deployment.scanner] (ServerService Thread Pool -- 14) JBAS015005: Reliable deployment behaviour is not possible when auto-deployment of exploded content is enabled (i.e. deployment without use of ".dodeploy"' marker files). Configuration of auto-deployment of exploded content is not recommended in any situation where reliability is desired. Configuring the deployment scanner's auto-deploy-exploded setting to "false" is recommended.
07:59:44,555 INFO [org.xnio] (MSC service thread 1-6) XNIO Version 3.0.10.GA-redhat-1
07:59:44,563 INFO [org.xnio.nio] (MSC service thread 1-6) XNIO NIO Implementation Version 3.0.10.GA-redhat-1
07:59:44,564 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)
07:59:44,581 INFO [org.jboss.remoting] (MSC service thread 1-6) JBoss Remoting version (unknown)
07:59:44,657 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 29) JBAS010280: Activating Infinispan subsystem.
07:59:44,724 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 37) JBAS011800: Activating Naming Subsystem
07:59:44,735 INFO [org.jboss.as.security] (ServerService Thread Pool -- 42) JBAS013171: Activating Security Subsystem
07:59:44,740 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 35) JBAS012605: Activated the following JSF Implementations: [main, 1.2]
07:59:44,746 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 44) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.
07:59:44,749 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 25) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)
07:59:44,774 INFO [org.jboss.as.connector.logging] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (IronJacamar 1.0.26.Final-redhat-1)
07:59:44,795 INFO [org.jboss.as.security] (MSC service thread 1-7) JBAS013170: Current PicketBox version=4.0.19.SP8-redhat-1
07:59:44,808 INFO [org.jboss.as.naming] (MSC service thread 1-8) JBAS011802: Starting Naming Service
07:59:44,809 INFO [org.jboss.as.mail.extension] (MSC service thread 1-3) JBAS015400: Bound mail session [java:jboss/mail/Default]
07:59:44,815 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 46) JBAS015537: Activating WebServices Extension
07:59:45,406 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) JBWEB003001: Coyote HTTP/1.1 initializing on : http-localhost/127.0.0.1:8080
07:59:45,450 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-1) JBWEB003000: Coyote HTTP/1.1 starting on: http-localhost/127.0.0.1:8080
07:59:45,490 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-4) JBAS015012: Started FileSystemDeploymentService for directory /home/patrick/jbdevstudio/runtimes/jboss-eap/standalone/deployments
07:59:45,501 INFO [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on 127.0.0.1:4447
07:59:45,502 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on 127.0.0.1:9999
07:59:45,516 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015876: Starting deployment of "Copy of BEO.war" (runtime-name: "Copy of BEO.war")
07:59:45,798 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
07:59:45,805 INFO [org.jboss.ws.common.management] (MSC service thread 1-8) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.0.Final-redhat-3
07:59:46,865 INFO [org.jboss.as.jpa] (MSC service thread 1-6) JBAS011401: Read persistence.xml for BEO
07:59:47,154 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
07:59:47,155 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
07:59:47,250 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) JBAS010404: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.4)
07:59:47,296 INFO [org.jboss.as.jpa] (ServerService Thread Pool -- 49) JBAS011402: Starting Persistence Unit Service 'Copy of BEO.war#BEO'
07:59:47,459 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 49) HCANN000001: Hibernate Commons Annotations {4.0.1.Final-redhat-2}
07:59:47,470 INFO [org.hibernate.Version] (ServerService Thread Pool -- 49) HHH000412: Hibernate Core {4.2.14.SP1-redhat-1}
07:59:47,472 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 49) HHH000206: hibernate.properties not found
07:59:47,475 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 49) HHH000021: Bytecode provider name : javassist
07:59:47,500 INFO [org.hibernate.ejb.Ejb3Configuration] (ServerService Thread Pool -- 49) HHH000204: Processing PersistenceUnitInfo [
name: BEO
...]
07:59:47,616 WARN [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (ServerService Thread Pool -- 49) HHH000402: Using Hibernate built-in connection pool (not for production use!)
07:59:47,617 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (ServerService Thread Pool -- 49) HHH000115: Hibernate connection pool size: 20
07:59:47,617 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (ServerService Thread Pool -- 49) HHH000006: Autocommit mode: true
07:59:47,618 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (ServerService Thread Pool -- 49) HHH000401: using driver [org.postgresql.Driver] at URL [jdbc:postgresql://localhost:5432/BEO]
07:59:47,619 INFO [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (ServerService Thread Pool -- 49) HHH000046: Connection properties: {user=patrick, password=****, autocommit=true, release_mode=auto}
07:59:47,941 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 49) HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
07:59:47,952 INFO [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (ServerService Thread Pool -- 49) HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
07:59:48,024 INFO [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (ServerService Thread Pool -- 49) HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jta.CMTTransactionFactory
07:59:48,028 INFO [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (ServerService Thread Pool -- 49) HHH000397: Using ASTQueryTranslatorFactory
07:59:48,069 INFO [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 49) HV000001: Hibernate Validator 4.3.1.Final-redhat-1
07:59:48,656 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 49) HHH000228: Running hbm2ddl schema update
07:59:48,656 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 49) HHH000102: Fetching database metadata
07:59:48,658 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 49) HHH000396: Updating schema
07:59:48,690 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 49) HHH000261: Table found: public.accounts
07:59:48,691 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 49) HHH000037: Columns: [password, firstname, user_id, username, lastname]
07:59:48,691 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 49) HHH000108: Foreign keys: []
07:59:48,691 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (ServerService Thread Pool -- 49) HHH000126: Indexes: [accounts_pkey, accounts_username_key]
07:59:48,692 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 49) HHH000232: Schema update complete
07:59:48,761 INFO [org.jboss.web] (ServerService Thread Pool -- 60) JBAS018210: Register web context: /Copy of BEO
07:59:48,778 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Copy of BEO]] (ServerService Thread Pool -- 60) No Spring WebApplicationInitializer types detected on classpath
07:59:48,779 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Copy of BEO]] (ServerService Thread Pool -- 60) No Spring WebApplicationInitializer types detected on classpath
07:59:48,890 INFO [org.jboss.as.server] (ServerService Thread Pool -- 26) JBAS018559: Deployed "Copy of BEO.war" (runtime-name : "Copy of BEO.war")
07:59:48,978 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
07:59:48,979 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
07:59:48,979 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss EAP 6.3.0.GA (AS 7.4.0.Final-redhat-19) started in 6269ms - Started 263 of 301 services (59 services are lazy, passive or on-demand)
【问题讨论】:
-
你能更好地描述这个问题吗?目前尚不清楚它是什么,因此很难帮助修复“它”。
-
看到了这个错误,在类路径上没有检测到 Spring WebApplicationInitializer 类型。他们说如果 web.xml 不在 WEB-INF 文件夹中,就会出现这个问题。但我的项目的 web.xml 在 WEB-INF
-
这看起来就像带有一些警告的典型日志。您是否按照建议启用了 DEBUG 日志?
-
你只有一个弹簧配置-没有ROOT上下文吗?为什么我问你只扫描
controller包。我怀疑你的服务和数据库层配置了spring? -
没有错误,所以请说明您认为应该可以正常工作的不正常工作。
标签: java spring hibernate spring-mvc jpa