OpenJPA анализирует ошибку запроса после нескольких месяцев работы - PullRequest
0 голосов
/ 05 июля 2018

После нескольких лет использования этого запроса, месяцев после последнего перераспределения, один сервер в нашем кластере WebSphere начал отказывать здесь, и мы не можем понять, в чем дело.

WebSphere 8.5.5.10, последний патч установлен более года назад.

javax.ejb.EJBTransactionRolledbackException: nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: <openjpa-2.2.3-SNAPSHOT-r422266:1737410 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter "SELECT c FROM BatchProcessingPeriodBean c WHERE c.workstationId = ?1 and c.processingTxnId = ?2 and c.periodState = ?3". Error message: The name "BatchProcessingPeriodBean" is not a recognized entity or identifier. Known entity names: []
at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSIException(BusinessExceptionMappingStrategy.java:167)
at com.ibm.ejs.container.BusinessExceptionMappingStrategy.mapCSITransactionRolledBackException(BusinessExceptionMappingStrategy.java:618)
at com.ibm.ejs.container.EJSDeployedSupport.mapCSITransactionRolledBackException(EJSDeployedSupport.java:700)
at com.ibm.ejs.container.EJSContainer.postInvokeRolledbackException(EJSContainer.java:4886)
at com.ibm.ejs.container.EJSContainer.postInvoke(EJSContainer.java:4572)

UPDATE

persistence.xml (src / main / resources / META-INF)

<?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="JDBC_TX">
        <jta-data-source>java:/JDBC_DATASOURCE</jta-data-source>
        <class>com.server.business.period.model.ejb.BatchProcessingPeriodBean</class>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
            <property name="openjpa.ConnectionFactoryName" value="JDBC_DATASOURCE"/>
            <property name="openjpa.ConnectionFactoryMode" value="managed"/>
            <property name="openjpa.TransactionMode" value="managed"/>
        </properties>
    </persistence-unit>
</persistence>

Файл JAR создается с использованием maven и находится в корне файла EAR.

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.server</groupId>
        <artifactId>components-accounting</artifactId>
        <version>1.1.30</version>
    </parent>
    <artifactId>BatchProcessingCounters</artifactId>
    <packaging>ejb</packaging>
    <name>BatchProcessingCounters</name>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.1</ejbVersion>
                    <generateClient>true</generateClient>
                    <clientExcludes>
                        <clientExclude>META-INF/**xmi</clientExclude>
                        <clientExclude>META-INF/**xml</clientExclude>
                    </clientExcludes>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>ejb</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Код объекта:

@Entity
@IdClass(BatchProcessingPeriodPK.class)
@Access(AccessType.PROPERTY)
@Table(name="BATCHPROCESSING_PERIOD")
@NamedQueries({
    @NamedQuery(name="FIND_BY_TXNPERIODSTATE",
    query="SELECT c FROM BatchProcessingPeriodBean c WHERE c.workstationId = ?1 and c.processingTxnId = ?2 and c.periodState = ?3"),
    @NamedQuery(name="FIND_BY_TXNSPERIODSTATE",
    query="SELECT c FROM BatchProcessingPeriodBean c WHERE c.workstationId = ?1 and c.periodState = ?2")
})
public class BatchProcessingPeriodBean extends BatchProcessingPeriod {

    public static final transient String FIND_BY_TXNPERIODSTATE = "FIND_BY_TXNPERIODSTATE";
    public static final transient String FIND_BY_TXNSPERIODSTATE = "FIND_BY_TXNSPERIODSTATE";

    @Override
    @Id
    @Column(name="PERIODID", nullable= false, updatable=false)
    public String getPeriodId() {
        return super.getPeriodId();
    }

    // ... more columns truncated
}

Использование запроса

@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@Resource(name = "jdbc/jconnect", type = DataSource.class)
public class ProcessingPeriodBean implements ProcessingPeriodService {

    @PersistenceContext(unitName = "JDBC_TX")
    private EntityManager entityManager;

    @TransactionAttribute(TransactionAttributeType.SUPPORTS)
    public BatchProcessingPeriod fetchOpenPeriod(String workstationId) {
        Query q = entityManager.createNamedQuery(BatchProcessingPeriodBean.FIND_BY_TXNSPERIODSTATE);
        q.setParameter(1, workstationId);
        q.setParameter(2, BatchPeriodState.OPEN);
        List<BatchProcessingPeriodBean> list = q.getResultList();
        // .. iterating, business logic
    }
}
...