1 year ago
#378151
Rajani Sohoni
Wicket (9.8.0) application, deployed on Payara 5.201 throws exception when method of stateless beans is used
Using wicket version 9.8.0, I am trying to use WicketTester for application containing EJB injection related code. I created application using 'wicket.apache.org/start/quickstart.html', and deployed it on Payara server '5.201'. I added the JavaEEComponentInjector in WebApplication. Deployment was successful, and I was able to see the page on web browser. Complete code is available at https://github.com/rjngshn/WicketTesterEJB
After this I added one stateless bean as follows
package uk.ac.ox.ndph.ckb;
import javax.ejb.Stateless;
/**
* @date 2022-04-01
* @author rajanis
*/
@Stateless
public class ControllerRts {
private static int appId;
private static String rtsPojo;
public void init(String rtsServiceData){
rtsPojo = rtsServiceData;
appId = 2;
}
public static int getAppId() {
return appId;
}
public String getContactMail() {
return "ContactEmail";
}
public String getLoginMessage() {
return "LoginMessage";
}
}
And one singleton bean
package uk.ac.ox.ndph.ckb;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.EJB;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerConfig;
import javax.ejb.TimerService;
/**
* @date 2021-03-29
* @author rajanis
*/
@Singleton
@Startup
public class RTInitializer {
static int MIN_TO_MICRO_SEC = 60 * 1000;
@Resource
private TimerService timerService;
@EJB(name = "ControllerRts")
private ControllerRts mControllerRts;
// Default is 60 minutes
private final int currentFrequency = 60;
@PostConstruct
void init() {
System.out.println("RTInitializer... starting timer with default config");
if (!isEnvironmentSet()) {
System.out.println("RTInitializer:In Init:Environment not set");
return;
}
System.out.println("RTInitializer .. Finished initializing");
setTimer(currentFrequency);
}
/**
* Specifying frequency of sending mails.
* Method to initialize and
*
* @param dur
*/
public void setTimer(int dur) {
System.out.println("RTInitializer: Setting a programmatic timeout for download sweep frequency to " + dur + " minutes from now.");
Timer timer = timerService.createIntervalTimer(dur * MIN_TO_MICRO_SEC, dur * MIN_TO_MICRO_SEC,
new TimerConfig("Created new interval for CDAScheduler", false));
}
/**
* The actual timer method which calls the EJB function to pull email
* requests and sends emails.
*
* @param timer
*/
@Timeout
public void sweepDownloadsAndEmail(Timer timer) {
}
private boolean isEnvironmentSet() {
String rtsServiceData = "Some string to connnect to service";
mControllerRts.init(rtsServiceData);
return true;
}
}
And I referred to the stateless beans as follows in BasicPage
@EJB(name = "ControllerRts")
private ControllerRts mControllerRts;
And invoked its method in 'onInitialize'
add(new Label("helpMessage", mControllerRts.getContactMail()));
Now the deployment as well tests failed.
Exception for deployment was as follows:
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor 'public uk.ac.ox.ndph.ckb.UserPage2()'. An exception has been thrown during construction!
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:194)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:67)
at org.apache.wicket.DefaultMapperContext.newPageInstance(DefaultMapperContext.java:90)
at org.apache.wicket.core.request.handler.PageProvider$Provision.getPage(PageProvider.java:369)
at org.apache.wicket.core.request.handler.PageProvider.getPageInstance(PageProvider.java:170)
at org.apache.wicket.request.handler.render.PageRenderer.getPage(PageRenderer.java:78)
at org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:231)
at org.apache.wicket.core.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:202)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:910)
at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:63)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:294)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:255)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:277)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:208)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:307)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:253)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:211)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:757)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:577)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:158)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.apache.wicket.session.DefaultPageFactory.newPage(DefaultPageFactory.java:175)
... 43 more
Caused by: java.lang.TypeNotPresentException: Type net/sf/cglib/proxy/MethodInterceptor not present
at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1019)
at org.objectweb.asm.SymbolTable.addMergedType(SymbolTable.java:1200)
at org.objectweb.asm.Frame.merge(Frame.java:1299)
at org.objectweb.asm.Frame.merge(Frame.java:1244)
at org.objectweb.asm.MethodWriter.computeAllFrames(MethodWriter.java:1610)
at org.objectweb.asm.MethodWriter.visitMaxs(MethodWriter.java:1546)
at net.sf.cglib.core.CodeEmitter.visitMaxs(CodeEmitter.java:847)
at net.sf.cglib.core.CodeEmitter.end_method(CodeEmitter.java:138)
at net.sf.cglib.proxy.Enhancer.emitGetCallback(Enhancer.java:959)
at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:644)
at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
at net.sf.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:332)
at net.sf.cglib.proxy.Enhancer.generate(Enhancer.java:492)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:96)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:94)
at net.sf.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at net.sf.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61)
at net.sf.cglib.core.internal.LoadingCache.get(LoadingCache.java:34)
at net.sf.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:119)
at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:294)
at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:480)
at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:305)
at org.apache.wicket.proxy.cglib.CglibProxyFactory.createProxy(CglibProxyFactory.java:95)
at org.apache.wicket.proxy.LazyInitProxyFactory.createProxy(LazyInitProxyFactory.java:160)
at org.wicketstuff.javaee.injection.JavaEEProxyFieldValueFactory.getCachedProxy(JavaEEProxyFieldValueFactory.java:149)
at org.wicketstuff.javaee.injection.JavaEEProxyFieldValueFactory.getFieldValue(JavaEEProxyFieldValueFactory.java:79)
at org.apache.wicket.injection.Injector.inject(Injector.java:111)
at org.wicketstuff.javaee.injection.JavaEEComponentInjector.inject(JavaEEComponentInjector.java:68)
at org.wicketstuff.javaee.injection.JavaEEComponentInjector.onInstantiation(JavaEEComponentInjector.java:74)
at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:38)
at org.apache.wicket.application.ComponentInstantiationListenerCollection$1.notify(ComponentInstantiationListenerCollection.java:34)
at org.apache.wicket.util.listener.ListenerCollection.notify(ListenerCollection.java:80)
at org.apache.wicket.application.ComponentInstantiationListenerCollection.onInstantiation(ComponentInstantiationListenerCollection.java:33)
at org.apache.wicket.Component.<init>(Component.java:691)
at org.apache.wicket.MarkupContainer.<init>(MarkupContainer.java:180)
at org.apache.wicket.Page.<init>(Page.java:171)
at org.apache.wicket.Page.<init>(Page.java:135)
at org.apache.wicket.markup.html.WebPage.<init>(WebPage.java:74)
at uk.ac.ox.ndph.ckb.BasePage.<init>(BasePage.java:23)
at uk.ac.ox.ndph.ckb.UserPage2.<init>(UserPage2.java:9)
... 48 more
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor not found by org.objectweb.asm [23]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1597)
at org.apache.felix.framework.BundleWiringImpl.access$300(BundleWiringImpl.java:79)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1982)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at org.objectweb.asm.ClassWriter.getCommonSuperClass(ClassWriter.java:1017)
... 88 more
Can someone please help?
java
ejb
payara
wicketstuff
0 Answers
Your Answer