Question

i am using eclipselink and tomee for save data.. eclipselink 2.42 tomee+ 1.6.0

it occurs when try to use transaction-type="JTA"

where am i missing ? thnks..

when i try to deploy my project i am getting

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;
Was it helpful?

Solution

In TomEE you have two resources with the same ID: csvWebPU. Just remove one of them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top