英文:
Maven HeuristicMixedException with Wildfly webapp
问题
如果我尝试使用 `mvn clean install -U` 编译我的 web 应用程序,我会得到以下错误日志。
[INFO] 正在扫描项目...
[INFO]
[INFO] ---------------------< com.mycompany:myproject >---------------------
[INFO] 正在构建 mycompany.com Scheduler 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject ---
[INFO] 正在删除 /home/user/workspace JavaEE/myproject/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] 使用 'UTF-8' 编码来复制过滤资源。
[INFO] 复制了 1 个资源
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myproject ---
[INFO] 检测到更改 - 正在重新编译模块!
[INFO] 正在将 19 个源文件编译到 /home/user/workspace JavaEE/myproject/target/classes
[INFO] -------------------------------------------------------------
[ERROR] 编译错误 :
[INFO] -------------------------------------------------------------
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[10,25] 找不到符号
符号: 类 HeuristicMixedException
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[11,25] 找不到符号
符号: 类 HeuristicRollbackException
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[12,25] 找不到符号
符号: 类 NotSupportedException
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[13,25] 找不到符号
符号: 类 RollbackException
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[14,25] 找不到符号
符号: 类 SystemException
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[15,25] 找不到符号
符号: 类 UserTransaction
位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[31,13] 找不到符号
符号: 类 UserTransaction
位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,49] 找不到符号
符号: 类 NotSupportedException
位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,72] 找不到符号
符号: 类 SystemException
位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,36] 找不到符号
符号: 类 RollbackException
位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,55] 找不到符号
符号: 类 HeuristicMixedException
位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,80] 找不到符号
符号: 类 HeuristicRollbackException
位置: 类 controller.Delete<T>
...
[INFO] 36 个错误
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] 总时间: 3.186 s
[INFO] 完成时间: 2020-04-10T13:50:37+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] 无法执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myproject: 编译失败: 编译失败:
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[10,25] 找不到符号
[ERROR] 符号: 类 HeuristicMixedException
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[11,25] 找不到符号
[ERROR] 符号: 类 HeuristicRollbackException
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[12,25] 找不到符号
[ERROR] 符号: 类 NotSupportedException
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[13,25] 找不到符号
[ERROR] 符号: 类 RollbackException
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[14,25] 找不到符号
[ERROR] 符号: 类 SystemException
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[15,25] 找不到符号
[ERROR] 符号: 类 UserTransaction
[ERROR] 位置: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[31,13] 找不到符号
[ERROR] 符号: 类 UserTransaction
[ERROR] 位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,49] 找不到符号
[ERROR] 符号: 类 NotSupportedException
[ERROR] 位置: 类 controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,72] 找不到符号
[ERROR] 符号
<details>
<summary>英文:</summary>
If I try to compile my webapp with `mvn clean install -U` I get the errorlog below.
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------------< com.mycompany:myproject >---------------------
[INFO] Building mycompany.com Scheduler 0.0.1-SNAPSHOT
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ myproject ---
[INFO] Deleting /home/user/workspace JavaEE/myproject/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ myproject ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ myproject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 19 source files to /home/user/workspace JavaEE/myproject/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[10,25] cannot find symbol
symbol: class HeuristicMixedException
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[11,25] cannot find symbol
symbol: class HeuristicRollbackException
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[12,25] cannot find symbol
symbol: class NotSupportedException
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[13,25] cannot find symbol
symbol: class RollbackException
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[14,25] cannot find symbol
symbol: class SystemException
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[15,25] cannot find symbol
symbol: class UserTransaction
location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[31,13] cannot find symbol
symbol: class UserTransaction
location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,49] cannot find symbol
symbol: class NotSupportedException
location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,72] cannot find symbol
symbol: class SystemException
location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,36] cannot find symbol
symbol: class RollbackException
location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,55] cannot find symbol
symbol: class HeuristicMixedException
location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,80] cannot find symbol
symbol: class HeuristicRollbackException
location: class controller.Delete<T>
...
[INFO] 36 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.186 s
[INFO] Finished at: 2020-04-10T13:50:37+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myproject: Compilation failure: Compilation failure:
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[10,25] cannot find symbol
[ERROR] symbol: class HeuristicMixedException
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[11,25] cannot find symbol
[ERROR] symbol: class HeuristicRollbackException
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[12,25] cannot find symbol
[ERROR] symbol: class NotSupportedException
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[13,25] cannot find symbol
[ERROR] symbol: class RollbackException
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[14,25] cannot find symbol
[ERROR] symbol: class SystemException
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[15,25] cannot find symbol
[ERROR] symbol: class UserTransaction
[ERROR] location: package javax.transaction
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[31,13] cannot find symbol
[ERROR] symbol: class UserTransaction
[ERROR] location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,49] cannot find symbol
[ERROR] symbol: class NotSupportedException
[ERROR] location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[77,72] cannot find symbol
[ERROR] symbol: class SystemException
[ERROR] location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,36] cannot find symbol
[ERROR] symbol: class RollbackException
[ERROR] location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,55] cannot find symbol
[ERROR] symbol: class HeuristicMixedException
[ERROR] location: class controller.Delete<T>
[ERROR] /home/user/workspace JavaEE/myproject/src/main/java/controller/Delete.java:[78,80] cannot find symbol
[ERROR] symbol: class HeuristicRollbackException
[ERROR] location: class controller.Delete<T>
...
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
The `pom.xml` content is
<?xml version="1.0" encoding="UTF-8"?>
<!-- JBoss, Home of Professional Open Source Copyright 2013, Red Hat, Inc.
and/or its affiliates, and individual contributors by the @authors tag. See
the copyright.txt in the distribution for a full listing of individual contributors.
Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>mycompany</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>mycompany.com application</name>
<description>A starter Java EE 7 webapp project for use on JBoss WildFly / WildFly, generated from the jboss-javaee6-webapp archetype</description>
<url>http://wildfly.org</url>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<distribution>repo</distribution>
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
</license>
</licenses>
<properties>
<!-- Explicitly declaring the source encoding eliminates the following
message: -->
<!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered
resources, i.e. build is platform dependent! -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- JBoss dependency versions -->
<version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>
<!-- Define the version of the JBoss BOMs we want to import to specify
tested stacks. -->
<version.jboss.bom>8.2.1.Final</version.jboss.bom>
<!-- other plugin versions -->
<version.compiler.plugin>3.1</version.compiler.plugin>
<version.surefire.plugin>2.16</version.surefire.plugin>
<version.war.plugin>2.5</version.war.plugin>
<!-- maven-compiler-plugin -->
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
<dependencyManagement>
<dependencies>
<!-- JBoss distributes a complete set of Java EE 7 APIs including a Bill
of Materials (BOM). A BOM specifies the versions of a "stack" (or a collection)
of artifacts. We use this here so that we always get the correct versions
of artifacts. Here we use the jboss-javaee-7.0-with-tools stack (you can
read this as the JBoss stack of the Java EE 7 APIs, with some extras tools
for your project, such as Arquillian for testing) and the jboss-javaee-7.0-with-hibernate
stack you can read this as the JBoss stack of the Java EE 7 APIs, with extras
from the Hibernate family of projects) -->
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-tools</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.wildfly.bom</groupId>
<artifactId>jboss-javaee-7.0-with-hibernate</artifactId>
<version>${version.jboss.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- First declare the APIs we depend on and need for compilation. All
of them are provided by JBoss WildFly -->
<!-- Import the CDI API, we use provided scope as the API is included in
JBoss WildFly -->
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the Common Annotations API (JSR-250), we use provided scope
as the API is included in JBoss WildFly -->
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the JAX-RS API, we use provided scope as the API is included
in JBoss WildFly -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the JPA API, we use provided scope as the API is included in
JBoss WildFly -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Import the EJB API, we use provided scope as the API is included in
JBoss WildFly -->
<dependency>
<groupId>org.jboss.spec.javax.ejb</groupId>
<artifactId>jboss-ejb-api_3.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- JSR-303 (Bean Validation) Implementation -->
<!-- Provides portable constraints such as @Email -->
<!-- Hibernate Validator is shipped in JBoss WildFly -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Import the JSF API, we use provided scope as the API is included in
JBoss WildFly -->
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.2_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Now we declare any tools needed -->
<!-- Annotation processor to generate the JPA 2.0 metamodel classes for
typesafe criteria queries -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<scope>provided</scope>
</dependency>
<!-- Annotation processor that raising compilation errors whenever constraint
annotations are incorrectly used. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator-annotation-processor</artifactId>
<scope>provided</scope>
</dependency>
<!-- Needed for running tests (you may also use TestNG) -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- Optional, but highly recommended -->
<!-- Arquillian allows you to test enterprise code such as EJBs and Transactional(JTA)
JPA from JUnit/TestNG -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Maven will append the version to the finalName (which is the name
given to the generated war, and hence the context root) -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<!-- Java EE 7 doesn't require web.xml, Maven needs to catch up! -->
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<!-- The WildFly plugin deploys your war to a local WildFly container -->
<!-- To use, run: mvn package wildfly:deploy -->
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
<version>${version.wildfly.maven.plugin}</version>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<!-- The default profile skips all tests, though you can tune it to run
just unit tests based on a custom pattern -->
<!-- Seperate profiles are provided for running all tests, including Arquillian
tests that execute in the specified container -->
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${version.surefire.plugin}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- An optional Arquillian testing profile that executes tests in your
WildFly instance -->
<!-- This profile will start a new WildFly instance, and execute the test,
shutting it down when done -->
<!-- Run with: mvn clean test -Parq-wildfly-managed -->
<id>arq-wildfly-managed</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<!-- An optional Arquillian testing profile that executes tests in a remote
WildFly instance -->
<!-- Run with: mvn clean test -Parq-wildfly-remote -->
<id>arq-wildfly-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'deployments'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${version.war.plugin}</version>
<configuration>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
The code for the Delete.java source is
package controller;
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
import javax.transaction.NotSupportedException;
import javax.transaction.RollbackException;
import javax.transaction.SystemException;
import javax.transaction.UserTransaction;
import model.EntityType;
import service.LogService;
/** class for deleting SINGLE entities */
public abstract class Delete<T extends EntityType> implements Serializable {
private static final long serialVersionUID = 5315202645032974752L;
@PersistenceUnit
private EntityManagerFactory emf;
private EntityManager entityManager;
@Resource
private UserTransaction ta;
@PostConstruct
private void postConstruct() {
entityManager = emf.createEntityManager();
}
/**
* {@link EntityManager} might be necessary in
* {@link #removeForeignEntities(EntityType)}
*
* @return {@link EntityManager}
*/
public EntityManager getEntityManager() {
return entityManager;
}
/**
* configure targeted face
*
* @return String null (no redirection per default)
*/
protected String redirect() {
return null;
}
/** remove foreign entities from entity {@link T} */
protected void removeForeignEntities(final T entity) {
// remove
}
/**
* delete entity by adding selected record in JSF
*
* <div>e.g.:
*
* <pre>
* <code>
* &lt;h:commandButton action="#{activityDelete.delete(item)}" /&gt;
* </code>
* </pre>
*
* </div>
*
* @return {@link #redirect()}
*/
public String delete(final T entity) throws NotSupportedException, SystemException, SecurityException,
IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException {
LogService.getLogger(this).info(new StringBuffer("delete(T): ").append(entity).toString());
ta.begin();
// type safety already fulfilled by definition <T extends EntityType>
@SuppressWarnings("unchecked")
final T deleteEntity = (T) entityManager.find(entity.getClass(), entity.getId());
removeForeignEntities(deleteEntity);
entityManager.remove(deleteEntity);
ta.commit();
return redirect();
}
}
and for EntityType.java is
package model;
import java.io.Serializable;
/**
* This bean is necessary to inject the entity to the CRUD beans.
*
* This must not be an interface or an abstract class since its not supported
* for the ORM (JBoss) implementation.
*
*
* console warning
*
* <pre>
* console warning "Multiple beans are eligible for injection to the injection point"
* </pre>
*
* Eclipse IDE error
*
* <pre>
* Multiple markers at this line
- Multiple beans are eligible for injection to the injection point [JSR-346
§5.2.2]
- Injection point type cannot be a type variable [JSR-346 §5.2.3]
* </pre>
*/
public class EntityType implements Serializable {
private static final long serialVersionUID = -6260606086182547955L;
public EntityType() {
// default constructor
}
public Long getId() {
return null;
}
}
I guess I can solve this problem with changing `<version.compiler.plugin>3.1</version.compiler.plugin` to `<version.compiler.plugin>3.6</version.compiler.plugin` or `<version.compiler.plugin>3.6.0</version.compiler.plugin` but both gives the same results.
What do I misunderstand and what is here the solution to fix this problem?
</details>
# 答案1
**得分**: 0
我找到了解决方案来解决我的问题。一旦我在“Eclipse IDE”中在“Java Build Path”注册中手动添加了事务API。
我在`pom.xml`中添加了正确API的依赖项。
<!-- https://mvnrepository.com/artifact/org.jboss.spec.javax.transaction/jboss-transaction-api_1.3_spec -->
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.3_spec</artifactId>
<version>2.0.0.Final</version>
</dependency>
在`project/dependencies`节点中。
执行命令`mvn clean install compile -U`的结果为
[INFO] ------------------------------------------------------------------------
[INFO] 构建成功
[INFO] ------------------------------------------------------------------------
[INFO] 总时间: 4.363 秒
[INFO] 完成于: 2020-04-10T16:10:26+02:00
[INFO] ------------------------------------------------------------------------
并且可以部署到wildfly服务器。
附注:在执行命令之前,我还从“Java Build Path”中删除了jboss-transaction-api_1.3_spec-2.0.0.Final.jar。
<details>
<summary>英文:</summary>
I found a solution for my problem. Once I added the transaction api manually in "Eclipse IDE" in the "Java Build Path" register.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/ycXaI.png
I added to the `pom.xml` the dependency for the right api.
<!-- https://mvnrepository.com/artifact/org.jboss.spec.javax.transaction/jboss-transaction-api_1.3_spec -->
<dependency>
<groupId>org.jboss.spec.javax.transaction</groupId>
<artifactId>jboss-transaction-api_1.3_spec</artifactId>
<version>2.0.0.Final</version>
</dependency>
within the `project/dependencies` node.
Executing the command `mvn clean install compile -U` results to
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.363 s
[INFO] Finished at: 2020-04-10T16:10:26+02:00
[INFO] ------------------------------------------------------------------------
and can be deployed to the wildfly server.
P.S.: I also removed the jboss-transaction-api_1.3_spec-2.0.0.Final.jar from the "Java Build Path" before executing the command.
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论