1

I have bean with @TransactionAttribute(TransactionAttributeType.NEVER) and method with @TransactionAttribute(TransactionAttributeType.SUPPORTS) but when method is executed looks like sometimes, not always method @TransactionAttribute(TransactionAttributeType.SUPPORTS) annotation is ignored and it failed with this error. I have Jboss EAP 7.3.9 standalone-full application. ORM provided is eclipselink. Code:

 @Stateless
    @TransactionAttribute(TransactionAttributeType.NEVER)
    @Interceptors(ServiceExceptionInterceptor.class)
    public class UserServiceImpl extends GenericCountry<LanguageDefinition> implements UserService {
    
       @Override
        @TransactionAttribute(TransactionAttributeType.SUPPORTS)
        public UserDto getUserByUsername(String username) {
            return userFacade.getUserByUsername(username);
        }
    
    
    public interface UserService {
        UserDto getUserByUsername(String username);
    }

standalone-full.xml datasource section :

<datasources>
                <datasource jta="true" jndi-name="java:/jdbc/test" pool-name="test2" enabled="true" use-java-context="true" use-ccm="true">
                    <connection-url>jdbc:oracle:thin:@localhost:9090:ddjboss</connection-url>
                    <driver>oracle</driver>
                    <pool>
                        <min-pool-size>1</min-pool-size>
                        <max-pool-size>15</max-pool-size>
                        <prefill>true</prefill>
                        <use-strict-min>false</use-strict-min>
                        <flush-strategy>FailingConnectionOnly</flush-strategy>
                        <allow-multiple-users>false</allow-multiple-users>
                    </pool>
                    <security>
                        <user-name>111</user-name>
                        <password>111</password>
                    </security>
                </datasource>

persistence.xml file.

 <persistence-unit name="test" transaction-type="JTA" >
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>jdbc/test2</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
        <!--<properties>-->
        <!--<property name="eclipselink.logging.level.sql" value="FINE"/>-->
        <!--<property name="eclipselink.logging.parameters" value="true"/>-->
        <!--<property name="eclipselink.logging.logger" value="DefaultLogger"/>-->
        <!--</properties>-->
        <properties>
        <property name="eclipselink.target-database" value="Oracle"/>
            <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/>
        </properties>
    </persistence-unit>

Caused by: javax.ejb.EJBException: WFLYEJB0063: Transaction present on server in Never call (EJB3 13.6.2.6) at org.jboss.as.ejb3.tx.CMTTxInterceptor.never(CMTTxInterceptor.java:349) at org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor.processInvocation(LifecycleCMTTxInterceptor.java:62)

What could be the problem? look like sometimes annotation inheritance for @TransactionAttribute is not working.

Ali Karaca
  • 3,365
  • 1
  • 35
  • 41
  • `TxType.SUPPORTS` won't use a transaction if it's outside a transaction context. My guess would be since you tell the bean itself to be `TxType.NEVER`, it's never in a transaction context. – James R. Perkins Jan 17 '23 at 22:01
  • In [this article](https://docs.oracle.com/cd/E19226-01/820-7627/bncik/index.html) Never Attribute If the client is running within a transaction and invokes the enterprise bean’s method, the container **throws a RemoteException**. If the client is not associated with a transaction, the container does not start a new transaction before running the method. – szeak Jan 21 '23 at 14:41
  • So when your client is IN A TRANSACTION and calls your Beans's method, will run into an ERROR. – szeak Jan 21 '23 at 14:50
  • Already answered question [Transaction present on server in Never call](https://stackoverflow.com/questions/32563059/transaction-present-on-server-in-never-call?rq=1) may help understand this exactly same error message: "Transaction present on server in Never call" – szeak Jan 21 '23 at 15:00

0 Answers0