Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Wicket+;弹簧&x2B;JPA&x2B;休眠:未找到持久性单元_Java_Hibernate_Spring_Jpa_Wicket - Fatal编程技术网

Java Wicket+;弹簧&x2B;JPA&x2B;休眠:未找到持久性单元

Java Wicket+;弹簧&x2B;JPA&x2B;休眠:未找到持久性单元,java,hibernate,spring,jpa,wicket,Java,Hibernate,Spring,Jpa,Wicket,我正在使用Wicket+Spring+JPA+Hibernate开发一个web应用程序。这是我第一个使用这种设置的项目,我想我可能犯了一些错误。我发现以下错误:未找到名为“ApplicationEntityManager”的持久化单元 我的persistence.xml文件如下所示: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml

我正在使用Wicket+Spring+JPA+Hibernate开发一个web应用程序。这是我第一个使用这种设置的项目,我想我可能犯了一些错误。我发现以下错误:未找到名为“ApplicationEntityManager”的持久化单元

我的persistence.xml文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>

<persistence version="2.0"
 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">
 <persistence-unit name="ApplicationEntityManager" transaction-type="RESOURCE_LOCAL">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
 </persistence-unit>
</persistence>

org.hibernate.ejb.HibernatePersistence
My applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:property-placeholder location="classpath:jdbc.properties"/>

    <!-- Enable @Transactional support -->
    <tx:annotation-driven/>

    <!-- Enable @AspectJ support -->
    <aop:aspectj-autoproxy/>

    <!-- Scans for @Repository, @Service and @Component -->
    <context:component-scan base-package="org.appfuse"/>
    <context:annotation-config />


 <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<bean id="dataSource" 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}"/>
    <property name="maxActive" value="30"/>
    <property name="maxIdle" value="10"/>
    <property name="maxWait" value="1000"/>
    <property name="defaultAutoCommit" value="true"/>
</bean>    


 <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  <property name="persistenceUnitName" value="ApplicationEntityManager" />
  <property name="dataSource" ref="dataSource" />
  <property name="jpaVendorAdapter">
   <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
    <property name="databasePlatform" value="${jpa.databasePlatform}" />
    <property name="showSql" value="${jpa.showSql}" />
    <property name="generateDdl" value="${jpa.generateDdl}" />
   </bean>
  </property>
 </bean>


 <bean id="transactionManager">
  <property name="entityManagerFactory" ref="entityManagerFactory" />
  <property name="dataSource" ref="dataSource" />
 </bean>

 <aop:config>
        <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))"/>
    </aop:config>

    <tx:advice id="txAdvice">
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="*"/>
        </tx:attributes>
    </tx:advice>     
</beans>

My web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

    <display-name>AppFuse Light</display-name>

    <!-- [INSERT FRAGMENT HERE] -->
    <!-- Define the basename for a resource bundle for I18N -->
    <context-param>
        <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
        <param-value>messages</param-value>
    </context-param>

    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter>
        <filter-name>messageFilter</filter-name>
        <filter-class>org.appfuse.web.MessageFilter</filter-class>
    </filter>

   <filter>
   <filter-name>open.entitymanager.in.view</filter-name>
   <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
 </filter>

    <filter>
        <filter-name>sitemesh</filter-name>
        <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
    </filter>
    <filter>
        <filter-name>wicket</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>org.appfuse.web.Application</param-value>
        </init-param>
        <init-param>
            <param-name>configuration</param-name>
            <param-value>development</param-value>
        </init-param>
    </filter>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext*.xml</param-value>
    </context-param>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>
        <filter-name>messageFilter</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </filter-mapping>

    <filter-mapping>
        <filter-name>sitemesh</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <filter-mapping>  
 <filter-name>open.entitymanager.in.view</filter-name>  
 <url-pattern>/*</url-pattern>  
 </filter-mapping> 

    <filter-mapping>
        <filter-name>wicket</filter-name>
        <url-pattern>/app/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dwr-invoker</servlet-name>
        <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
        <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
        </init-param>
    </servlet>

    <servlet-mapping>
        <servlet-name>dwr-invoker</servlet-name>
        <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
        <error-code>404</error-code>
        <location>/404.jsp</location>
    </error-page>

    <error-page>
        <error-code>500</error-code>
        <location>/error.jsp</location>
    </error-page>

</web-app>

应用保险丝灯
javax.servlet.jsp.jstl.fmt.localizationContext
信息
编码滤波器
org.springframework.web.filter.CharacterEncodingFilter
编码
UTF-8
强制编码
真的
消息过滤器
org.appfuse.web.MessageFilter
open.entitymanager.in.view
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
网站
com.opensymphony.module.sitemesh.filter.PageFilter
边门
org.apache.wicket.protocol.http.WicketFilter
应用程序类名
org.appfuse.web.Application
配置
发展
上下文配置位置
/WEB-INF/applicationContext*.xml
编码滤波器
/*
消息过滤器
/*
要求
向前地
网站
/*
open.entitymanager.in.view
/*  
边门
/应用程序/*
org.springframework.web.context.ContextLoaderListener
dwr调用程序
org.directwebremoting.servlet.DwrServlet
调试
真的
dwr调用程序
/dwr/*
index.jsp
404
/404.jsp
500
/error.jsp

你能看到明显的错误吗?这是标准配置吗?谢谢

确保
persistence.xml
位于正确的位置。在构建路径中,它应该
/META-INF/persistence.xml
,这样在编译的
war
文件中,它应该位于
/WEB-INF/classes/META-INF/persistence.xml
中,确保
persistence.xml
位于正确的位置。在您的构建路径中,它应该
/META-INF/persistence.xml
,这样在编译的
war
文件中,它应该在
/WEB-INF/classes/META-INF/persistence.xml
中结束。您是否检查了persistence.xml是否在META-INF目录中,即persistence.xml应该始终位于{persistence unit root}中/META-INF/目录???

您是否检查了persistence.xml是否在META-INF目录中,即persistence.xml应该始终位于{persistence unit root}/META-INF/目录中???

似乎无法发现任何错误。你有没有可能将项目作为zip文件发布到某个地方?错误的完整堆栈跟踪也会很有帮助。似乎无法真正发现任何错误。你有没有可能把项目作为zip文件发布到某个地方?错误的完整堆栈跟踪也会很有帮助。我已经检查过了,它在那里。我已经检查过了,它在那里。