为什么我的项目没有部署?

时间:2014-02-14 13:52:03

标签: jpa eclipselink persistence.xml tomee

我正在使用eclipselink和tomee来保存数据.. eclipselink 2.42 tomee + 1.6.0

尝试使用transaction-type =“JTA”

时发生 我错过了哪里? thnks ..

当我尝试部署我的项目时,我正在

starting tomcat at localhost has encountered a problem

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<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"
    version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">

        <persistence-unit name="CSVReaderWebPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

        <jta-data-source>csvWebPU</jta-data-source>

        <class>com.project.model.CsvModel</class>

        <properties>
            <property name="eclipselink.logging.level" value="FINE" />
            <property name="eclipselink.logging.level.sql" value="FINE" />
            <property name="eclipselink.logging.parameters" value="true" />
            <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
            <property name="eclipselink.ddl-generation" value="create-tables" />
            <property name="eclipselink.ddl-generation.output-mode" value="database" />
        </properties>
    </persistence-unit>

tomee.xml

<Resource id="csvWebPU" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/test
  UserName root
  Password root
  JtaManaged false
</Resource>

<Resource id="csvWebPU" type="DataSource">
  JdbcDriver com.mysql.jdbc.Driver
  JdbcUrl jdbc:mysql://localhost:3306/test
  UserName root
  Password root
  JtaManaged true
</Resource>

CsvReaderServlet.java

@WebServlet(name = "CsvReaderServlet", urlPatterns = {"/CsvReaderServlet"})
@MultipartConfig
public class CsvReaderServlet extends HttpServlet {

    private static final long serialVersionUID = 1L;
    @Inject
    CsvService csvService;

    public CsvReaderServlet() {
    }

CsvServiceImpl.java

@Stateless
public class CsvServiceImpl implements CsvService {

    @Inject
    CsvRepository csvRepository;

    public void writeCsvFile(CsvModel csvModel) {
        csvRepository.saveCsvFile(csvModel);
    }

CsvModel.java

@Entity
@Table(name="CSVFILE")
public class CsvModel {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private long id;

    @Column(name="DEVICE_ID")
    private String deviceId;

    @Column(name="MESSAGE")
    private String message;

    @Column(name="REGISTRATION_DATE")
    private String date;

1 个答案:

答案 0 :(得分:1)

在TomEE中,您有两个具有相同ID的资源:csvWebPU。只需删除其中一个。