我正在使用Eclipse中的Servlet,JPA,EJB和JBoss进行项目。如您所见,在我的主题标题中,我的persistence.xml文件有一个错误,但我不知道哪个:
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="TrainingAppEJB-PU">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/MysqlDS</jta-data-source>
<class>fr.entity.Client</class>
<class>fr.entity.Course</class>
<class>fr.entity.CourseSession</class>
<class>fr.entity.Location</class>
<properties>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/gestion_formation"/>
<property name="hibernate.default_schema" value="gestion_formation"/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.password" value="********"/>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="show_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
但是,当我尝试运行我的servlet时,出现以下错误:
16:59:44,498 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/TrainingAppWeb].[Home]] (http--127.0.0.1-8080-2) "Servlet.service()" pour la servlet Home a généré une exception: javax.ejb.EJBException: javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML (line-1 : column -1): cvc-elt.1: Cannot find the declaration of element 'persistence'.
at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:206)
at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:275)
at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.required(CMTTxInterceptor.java:377)
at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invoke(CMTTxInterceptor.java:233)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:47)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:146)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:76)
at utbm.lo54.isession.ManageCourseBeanLocal$$$view11.findAllCourse(Unknown Source) [TrainingAppEJB.jar:]
at utbm.lo54.servlet.HomeServlet.process(HomeServlet.java:47) [classes:]
at utbm.lo54.servlet.HomeServlet.doGet(HomeServlet.java:31) [classes:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.0.Final.jar:1.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:49) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
at java.lang.Thread.run(Thread.java:724) [:1.7.0_40]
Caused by: javax.persistence.PersistenceException: Invalid persistence.xml.
Error parsing XML (line-1 : column -1): cvc-elt.1: Cannot find the declaration of element 'persistence'.
at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:145) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:169) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:313) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55) [hibernate-entitymanager-4.0.0.Beta1.jar:4.0.0.Beta1]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) [hibernate-jpa-2.0-api-1.0.1.Final.jar:1.0.1.Final]
at utbm.lo54.session.ManageCourseBean.getEntityManager(ManageCourseBean.java:36) [TrainingAppEJB.jar:]
at utbm.lo54.session.ManageCourseBean.findAllCourse(ManageCourseBean.java:51) [TrainingAppEJB.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.7.0_40]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [:1.7.0_40]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [:1.7.0_40]
at java.lang.reflect.Method.invoke(Method.java:606) [:1.7.0_40]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptor.java:51)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:45) [jboss-as-jpa-7.0.0.Final.jar:7.0.0.Final]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:44)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewDescription$ComponentDispatcherInterceptor.processInvocation(ViewDescription.java:202)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.as.ejb3.component.session.SessionInvocationContextInterceptor.processInvocation(SessionInvocationContextInterceptor.java:67)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:287)
at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:370)
at org.jboss.ejb3.tx2.impl.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:271)
... 28 more
我该如何解决这个问题
除非您没有复制粘贴整个文件,否则缺少结束标记。附加
</persistence>
在您的persistence.xml中
编辑
您的数据源的JNDI名称似乎是错误的。通常以: java:/
ConfigEmbeddedWebApplicationContext:上下文初始化过程中遇到异常-取消刷新att empt:org.springframework.beans.factory.beanCreationException:创建类路径资源[org/springframework/boot/autoconfiguration/orm/jpa/hibernatejpaAutoConfig
问题内容: 我收到以下错误: 在类路径资源[jpaDaoContext.xml]中定义的名称为’org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0’的bean创建时出错:bean的初始化失败;嵌套的异常是org.springframework.beans.factory.BeanCrea
问题内容: 这是logcat: 与之关联的行是: 可能是什么问题呢?创建数据库就好了。您还需要查看其他代码吗? 更新: 我非常确定此列存在。我用这个查询数据库: 在LogCat中: 因此该列确实存在。 问题答案: 我发现了一个奇怪的解决方案。在中。你所要做的:
我们有一个Spring Boot1.4.1应用程序,当我们创建可运行的jar并尝试运行它时,我们会得到以下堆栈跟踪: 我们也找到了这个问题https://github.com/spring-projects/spring-boot/issues/6635,但根据它,这个问题应该在Spring Boot 1.4.1中修复 注意:我们的模型类中没有注释,我们使用hbm.xml文件进行映射。但是,我们使
问题内容: 我是JPA和Hibernate的新手。阅读一些在线资料后,我现在了解了什么是Hibernate以及如何将其与JPA一起使用。 现在,我正在尝试运行此JPA&Hibernate教程。我已经完成了他们在本教程中提到的所有内容。 我没有Oracle DB,只有MySQL。因此,我对使用JPA和Hibernate的理解进行了一些更改(我不知道它是否正确……在我看来是正确的。) 这是我的 但是我
问题内容: 我有一个JSP文件,我将在Eclipse,Maven和Tomcat的帮助下将其部署在Java项目中。我还有一些其他的JSP文件与此文件几乎相同,尽管它们运行不同的操作。无论如何,当我转到页面时,我已经给出了: Bug是一个自定义类,可以接受结果集--并执行以下操作: 其中BUG_ID,PERSON_OPENED_BY,PERSON_ASSIGNED_TO,TITLE和PROJECT_I