Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EJBContainer exception on MDB with no method interface #3411

Closed
ggam opened this issue Nov 11, 2018 · 2 comments
Closed

EJBContainer exception on MDB with no method interface #3411

ggam opened this issue Nov 11, 2018 · 2 comments
Labels
PR: TESTS REQUIRED PR Requires Tests to be merged

Comments

@ggam
Copy link

ggam commented Nov 11, 2018

Description


When an application exception is thrown from a message driven bean method, the EJB container throws an unexpected exception that swallows the original one.

Expected Outcome

The EJB container should obviously not throw any internal exception :)

Current Outcome

I have the following bean which always throws an exception (I'm using Payara Kafka RA):

@MessageDriven(
        activationConfig = {
            @ActivationConfigProperty(propertyName = "clientId", propertyValue = "testClient"),
            @ActivationConfigProperty(propertyName = "groupIdConfig", propertyValue = "test-consumer-group"),
            @ActivationConfigProperty(propertyName = "topics", propertyValue = "test"),
            @ActivationConfigProperty(propertyName = "bootstrapServersConfig", propertyValue = "localhost:9092"),
            @ActivationConfigProperty(propertyName = "enableAutoCommit", propertyValue = "false"),
            @ActivationConfigProperty(propertyName = "retryBackoff", propertyValue = "1000"),
            @ActivationConfigProperty(propertyName = "keyDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"),
            @ActivationConfigProperty(propertyName = "valueDeserializer", propertyValue = "org.apache.kafka.common.serialization.StringDeserializer"),
            @ActivationConfigProperty(propertyName = "pollInterval", propertyValue = "1000"),})
public class TestResource implements KafkaListener {

    @OnRecord
    public void onRecord(ConsumerRecord<String, String> record) {
        throw new IllegalArgumentException("");
    }
}

The following message is logged when a message is received:

[2018-11-11T20:58:48.858+0100] [] [GRAVE] [] [fish.payara.cloud.connectors.kafka.inbound.KafkaResourceAdapter] [tid: _ThreadID=130 _ThreadName=orb-thread-pool-1 (pool #1): worker-1] [timeMillis: 1541966328858] [levelValue: 1000] [[
  
java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at fish.payara.cloud.connectors.kafka.inbound.KafkaWork.run(KafkaWork.java:103)
	at com.sun.enterprise.connectors.work.OneWork.doWork(OneWork.java:107)
	at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$TaskRunner.run(ThreadPoolImpl.java:189)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: javax.ejb.EJBException: Transaction Attribute not found for methodpublic abstract void eu.ggam.kafkatest.__EJB32_Generated__TestResource__Intf__.onRecord(org.apache.kafka.clients.consumer.ConsumerRecord)
	at com.sun.ejb.containers.BaseContainer.getTxAttr(BaseContainer.java:2871)
	at org.glassfish.ejb.mdb.MessageBeanContainer.containerStartsTx(MessageBeanContainer.java:399)
	at org.glassfish.ejb.mdb.MessageBeanContainer.isDeliveryTransacted(MessageBeanContainer.java:713)
	at com.sun.enterprise.connectors.inbound.MessageEndpointInvocationHandler.invoke(MessageEndpointInvocationHandler.java:173)
	at com.sun.proxy.$Proxy288.onRecord(Unknown Source)
	at eu.ggam.kafkatest.__EJB32_Generated__TestResource__Intf____Bean__.onRecord(Unknown Source)
	... 12 more
]]

Debugging the source I found that BaseContainer is invoked with the EJB view method while the invocationInfo map only contains the methods for the original class:
https://github.com/payara/Payara/blob/payara-server-5.183/appserver/ejb/ejb-container/src/main/java/com/sun/ejb/containers/BaseContainer.java#L2866

The problem seems to come from the MessageBeanContainer class, which creates that EJB view in case the listener interface has no methods:
https://github.com/payara/Payara/blob/payara-server-5.183/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/mdb/MessageBeanContainer.java#L178

But then only adds the original class methods to the invocation map:
https://github.com/payara/Payara/blob/payara-server-5.183/appserver/ejb/ejb-full-container/src/main/java/org/glassfish/ejb/mdb/MessageBeanContainer.java#L190

Environment

  • Payara Version: 5.1.183
  • Edition: micro
  • JDK Version: 8
  • Operating System: Fedora
@smillidge
Copy link
Contributor

Can you create a testcase hosted on GitHub that demonstrates the issue then I can investigate?

@smillidge
Copy link
Contributor

Closed due to inactivity. Please provide a test case or a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: TESTS REQUIRED PR Requires Tests to be merged
Projects
None yet
Development

No branches or pull requests

3 participants