Kafka Listeners are getting active before spring boot application startup for Spring Kafka 2.2.3.RELEASE - spring-kafka

We are using Spring-Kafka 2.2.3.RELEASE in our spring boot application (Spring Boot 2.1.2.RELEASE) and we have some kafka consumers defined in the application as,
#Component
#RefreshScope
#ConditionalOnProperty(prefix = "ord", value = "order-event.messaging.consumer.enabled", havingValue = "true")
public class OrderEventListener {
#KafkaListener(id = "orderEventListener", topics = "#{'${order.consumer.topic}'}")
public void consumeMessageEvent(OrderEvent messageEvent,ConsumerRecord<String, ?> record) {
// do some further processing.
}
}
Now lets jump to the question,
So when I start the application, so on application startup itself, it activates this consumer and tries to connect to broker but broker is not up and running in my system and after timeout, it throws the error
Error creating bean with name 'scopedTarget.orderEventListener'
and shows 'Application run failed' and terminate the process.
Why it requires broker to be up and running at the startup of the
application?
Previously we were using Spring Kafka 1.1.8.RELEASE, and it used to work without starting the broker and application used to start up normally.
Is that the expected behavior ? So the behavior got changed from version 1.1.8 to 2.2.3 ?
Additional Logs,
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.orderEventListener' Initialization of bean failed; nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:584) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$1(AbstractBeanFactory.java:356) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$BeanLifecycleWrapper.getBean(GenericScope.java:390) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:184) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:353) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1083) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.cloud.context.scope.refresh.RefreshScope.eagerlyInitialize(RefreshScope.java:130) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.cloud.context.scope.refresh.RefreshScope.start(RefreshScope.java:121) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:115) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.cloud.context.scope.refresh.RefreshScope.onApplicationEvent(RefreshScope.java:71) ~[spring-cloud-context-2.1.0.RELEASE.jar:2.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:398) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:355) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:163) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.4.RELEASE.jar:5.1.4.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at oal.oracle.apps.ic.coll.ordsbx.Application.main(Application.java:59) [classes/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_161]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_161]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.2.RELEASE.jar:2.1.2.RELEASE]
Caused by: org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata

It is due to a change to the underlying kafka-clients library (since 2.0.0).
Previously, it would block forever, giving the application no control at all, which was unacceptable for many users.
Now, the operation will time out if the broker is not available.
I am not sure why it is failing during bean creation - it should only occur when the container is start()ed later in the application lifecycle. But I see you are using devtools so I am not sure it that is exacerbating the problem - edit the question to show the complete stack trace (you should never truncate stack traces here, since we can't see the complete story).
Normally, this can be avoided by setting autoStartup to false and then starting the container(s) yourself later, in a loop, waiting for the broker to exist.

Related

Grails 3.3.10: running integration tests Error creating bean with name 'com.cabolabs.security.UserController'

I'm trying to create an integration test for a service and keep receiving a controller, that is totally disconnected from the service test, can't be created. Spending a day or so on everything that might cause the issue, and failing miserably, decided to create a project from scratch and start adding line by line.
So I did:
grails create-app test
grails create-domain-class com.cabolabs.security.User
added username and password String fields
grails generate-app com.cabolabs.security.User
grails create-service com.cabolabs.cloud.BalanceUpdate
grails create-integration-test com.cabolabs.cloud.BalanceUpdate
grails test-app com.cabolabs.cloud.BalanceUpdate -integration
That runs OK, the test fails because of the default code, that is not important.
Then I started to add references to services in the UserController, and the BalanceUpdateService, like mailService from the mail plugin.
The test worked as before.
Then I added this line, which I have extensively used in many controllers of my original project:
def config = grailsApplication.config
With that line, the whole thing felt apart and got the error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.cabolabs.security.UserController': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.cabolabs.security.UserController]: Constructor threw exception; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1104)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1080)
at org.spockframework.spring.SpringMockTestExecutionListener.beforeTestMethod(SpringMockTestExecutionListener.java:54)
at org.spockframework.spring.AbstractSpringTestExecutionListener.beforeTestMethod(AbstractSpringTestExecutionListener.java:23)
at org.springframework.test.context.TestContextManager.beforeTestMethod(TestContextManager.java:269)
at org.spockframework.spring.SpringTestContextManager.beforeTestMethod(SpringTestContextManager.java:54)
at org.spockframework.spring.SpringInterceptor.interceptSetupMethod(SpringInterceptor.java:45)
at org.spockframework.runtime.extension.AbstractMethodInterceptor.intercept(AbstractMethodInterceptor.java:28)
at org.spockframework.runtime.extension.MethodInvocation.proceed(MethodInvocation.java:87)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:114)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:57)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:66)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:109)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:147)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:129)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
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: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.cabolabs.security.UserController]: Constructor threw exception; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:154)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1152)
... 34 more
Caused by: java.lang.IllegalStateException: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
at org.springframework.web.context.request.RequestContextHolder.currentRequestAttributes(RequestContextHolder.java:131)
at grails.web.api.WebAttributes$Trait$Helper.currentRequestAttributes(WebAttributes.groovy:45)
at grails.web.api.WebAttributes$Trait$Helper.getGrailsAttributes(WebAttributes.groovy:54)
at grails.web.api.WebAttributes$Trait$Helper.getGrailsApplication(WebAttributes.groovy:134)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:142)
... 36 more
My question is, how can I have the config injected to my controllers and make the integration tests work? Thanks.
I just created a project from scratch and added line by line, it seems adding this to the controller, makes the test for the service fail (which are not connected in any way): def config = grailsApplication.config
Since I used that in many controllers, I tested changing it to Holders.config and that actually worked. I'll report this as a bug to Grails Core.

Getting Error in EntityManagerWrapper.getNonTxEMsFromCurrentInvocation(EntityManagerWrapper.java:276)

I am having my application deployed in EJBContainer in glassfish server. I am calling one method using Callable and future in session bean, and in this method i'm using EntityManager for some transaction but getting an NullPointerException for whenever any call to EntityManager is there. Below is the error stack trace::
Severe: java.lang.NullPointerException
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.getNonTxEMsFromCurrentInvocation(EntityManagerWrapper.java:276)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.getNonTxEMFromCurrentInvocation(EntityManagerWrapper.java:260)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:213)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:455)
at LogisticsEngineSessionBean.getAllPackSerialsForProcess(LogisticsEngineSessionBean.java:3137)
at LogisticsEngineSessionBean.processSalesOutLines(LogisticsEngineSessionBean.java:3462)
at LogisticsEngineSessionBean.lambda$updateSKULocationStatusOnSell$0(LogisticsEngineSessionBean.java:2972)
at LogisticsEngineSessionBean$$Lambda$7/1138463255.call(Unknown Source)
at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Please suggest whether it is because i'm trying to do multi threading or any alternate for this is available. I'm using EclipseLink JPA. This NullPointerException is not within my Code,it is coming in EntityManager which is working fine when i'm not doing MultiThreading. And EntityManager Object is not null, Please read the question properly before giving downvote.

Registering custom oracle

I've followed the oracle example in the corda docs to set up a simple price oracle for our cordapp, but am having an issue when it comes to registering this oracles service within our cordapp.
The error being displayed within our main code is
java.lang.IllegalArgumentException: Corda service com.secLendModel.flow.oracle.Oracle does not exist
By following this error down the line, it appears that this is because in the constructor of our oracle, the code segment below throws a null pointer exception, although the service seems to exist within our main testing code (i.e when I print the oracles advertised services, com.secLendModel.flow.oracle.Oracle is the only service it advertises)
constructor(services: PluginServiceHub) : this(services.myInfo.serviceIdentities(PriceType.type).first(), services)
The error for this constructor code is shown within node startup
W 09:45:34 1 Node.invoke - com.secLendModel.flow.oracle.Oracle does not have a type field, optimistically proceeding with install.
E 09:45:34 1 Node.installCordaServices - Corda service com.secLendModel.flow.oracle.Oracle failed to instantiate
java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:178) ~[kotlin-stdlib-1.1.1.jar:1.1.1]
at com.secLendModel.flow.oracle.Oracle.<init>(Oracle.kt:24) ~[main/:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_131]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_131]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_131]
at net.corda.node.internal.AbstractNode.installCordaService(AbstractNode.kt:322) ~[corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode.installCordaServices(AbstractNode.kt:302) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode.access$installCordaServices(AbstractNode.kt:99) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode$start$3.invoke(AbstractNode.kt:254) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode$start$3.invoke(AbstractNode.kt:99) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode$initialiseDatabasePersistence$3.invoke(AbstractNode.kt:597) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode$initialiseDatabasePersistence$3.invoke(AbstractNode.kt:99) [corda-node-0.13.0.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:69) [exposed-0.5.0.jar:?]
at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:57) [exposed-0.5.0.jar:?]
at net.corda.node.utilities.DatabaseSupportKt.transaction(DatabaseSupport.kt:48) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode.initialiseDatabasePersistence(AbstractNode.kt:596) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.Node.initialiseDatabasePersistence(Node.kt:304) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.AbstractNode.start(AbstractNode.kt:223) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.Node.start(Node.kt:310) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.NodeStartup.startNode(NodeStartup.kt:103) [corda-node-0.13.0.jar:?]
at net.corda.node.internal.NodeStartup.run(NodeStartup.kt:81) [corda-node-0.13.0.jar:?]
at net.corda.node.Corda.main(Corda.kt:11) [corda-node-0.13.0.jar:?]
It appears this node setup happens within the abstractNode class under install corda service. I am not sure if this could be an error here, an issue with the fact the PluginServiceHub is now depreceated or if I am missing a step in my node setup.
The code used to setup the node is as follows
val oracle = startNode(ORACLE, advertisedServices = setOf(ServiceInfo(PriceType.type)))
oracleNode = oracle.get()
//This is what is reporting as empty when instantiating the node, but its definetely not. Could be something to do with abstractNode
println(oracleNode.nodeInfo.serviceIdentities(PriceType.type).first())
setUpNodes()
It should be noted that once all the nodes are setup, the oracle node then displays no services
CN=Oracle SP,O=Oracle SP,L=Brisbane,C=AU started on localhost:20018
While our notary node does display services
CN=Notary Service,O=R3,OU=corda,L=Zurich,C=CH,OU=corda.notary.validating started on localhost:20009
The code for our oracle follows the example code, and it doesnt seem there is any issues with it but I can post if if need be.
This is from an older version of Corda that had the concept of service identities for services such as oracles.
The error message indicates that an exception is being thrown on this line:
`println(oracleNode.nodeInfo.serviceIdentities(PriceType.type).first())`
In particular, it indicates that you are trying to get the first item from a list with no elements, and therefore that the PriceType.type service identity has not been registered correctly.
You have probably failed to register the service identity in the node's node.conf file.

EJB: Method invocation and interfaces

I'm currently upgrade our business javaee environment. A new feature should be implemented which allows to manage maintenance notifications in the webframework that affect other web applications on the same server. The notifications should be transferred using EJB (either the framework send them to the application or the application asks for them).
I tried to implement it based on interfaces. The interfaces are used in the method signatures and the conctret implementations of those interfaces are only known by the webframework respectively the applications.
But all invocations fail with either a ClassNotFoundException (when the framwork sends the notification to the application) or a ClassCastException (when the application ask for new maintenances).
The question: Is it impossible to implement this using interfaces? Do I always need the concret implementations on both sides? The preceeding EJB lookup does work using interfaces (#Remote annotation), so why do I have those exceptions?
Thanks in advance!
I will give you a short overview over my classes so you have more information about what I'm doing:
Interface: IMaintenanceInfo:
This interface will be used for the EJB method invocations and contains the information about a single maintenance.
Interface: IRemoteMaintenanceEJB:
This interface is the #Remote interfaces for the RemoteMaintenanceEJB. This is used by the applications to ask for new maintenances.
Interface: IApplicationEJB:
This interface is used to receive maintenance notifications from the webframework. It is #Remote.
Class: MaintenanceInfoImpl:
This class implements IMaintenanceInfo
Class: RemoteMaintenanceEJBImpl:
This class implements IRemoteMaintenanceEJB
Class: ApplicationEJBInfo:
This class implements IApplicationEJB
When the RemoteMaintenanceEJBImpl sends a MaintenanceInfoImpl to an ApplicationEJBImpl, the following method will be used:
public interface IApplicationImpl {
public void announceMaintenance(IMaintenanceInfo maintenanceInfo);
}
The invocation
remoteApplication.announceMaintenance(new MaintenanceInfoImpl(date/*, ...*/))
Failes with a ClassNotFoundException on the application side as it tries to find the MaintenanceInfoImpl which is only available on the webframework side.
Caused by: java.lang.ClassNotFoundException: package.webapp.wf.framework.MaintenanceInfoImpl from [Module "deployment.CommonDBFrontend.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.jboss.marshalling.cloner.ClassLoaderClassCloner.clone(ClassLoaderClassCloner.java:49)
at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:157)
at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)
at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:186)
at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:134)
at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:267)
Which again raises this exception (JBoss AS 7.1.2)
java.lang.RuntimeException: JBAS014154: Failed to marshal EJB parameters
When the ApplicationEJBImpl asks the RemoteMaintenanceEJBImpl for new maintenances, the following method will be used:
public interface IRemoteMaintenanceEJB {
pubilc List<IMaintenanceInfo> getMaintenances();
}
The invocation failes with the exception
Caused by: java.lang.ClassCastException: package.webapp.wf.framework.MaintenanceInfoImpl cannot be cast to package.webapp.ejb.IMaintenanceInfo
at package.webapp.ejb.impl.ApplicationEJBImpl.announceMaintenance(ApplicationEJBImpl.java:187)
at package.webapp.ejb.impl.ApplicationEJBImpl.initialize(ApplicationEJBImpl.java:96)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_11]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_11]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_11]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_11]
...
implement java.io.Serializable for the class MaintenanceInfoImpl
and also make sure you set serialVersionUID for the same.

EJB Timer IllegalArgumentException

I have an EJB3.0 timer which runs great.During application deployment i see this error in my WL logs,
An exception occurred while registering the MBean null.java.lang.IllegalArgumentException: Registered more than one instance with the same objectName : com.bea:ServerRuntime=admin,Name=weblogic.ejb.timer"
And during undeployment this
An unexpected error was encountered while attempting to remove any EJB Timers from the persistent store for the EJB 'TimerBean(Application: )
I don't use persistence store mechanism.I trigger the timer with servlet context.
We use WL 10.3.1,How can i overcome/catch this exception so,that it wouldn't be displayed during build process.
Thanks
The WLS ejb timers are persisted to a default store. The error messages seem to be related to it. Its likely that the ejb timer from a previous deployment is interfering. Does a server restart resolve this issue? You may want to try your app on WLS 10.3.4 to see if the issue has been resolved.

Resources