[
https://issues.apache.org/jira/browse/WICKET-1848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12634506#action_12634506
]
Maarten Billemont commented on WICKET-1848:
-------------------------------------------
I was wrong; I did some more digging:
I put the following code above
org/apache/wicket/proxy/LazyInitProxyFactory.java:416:
System.out.println("METHOD " + method + " OF " +
method.getDeclaringClass().getCanonicalName() + " CREATED BY " +
method.getDeclaringClass().getClassLoader());
System.out.println(" => ON " + target + "
CLASS " +
target.getClass().getCanonicalName() +
" EXTENDS " +
target.getClass().getGenericSuperclass() + " IMPLEMENTS " +
Arrays.asList(target.getClass().getGenericInterfaces()) + " CREATED BY " +
target.getClass().getClassLoader());
return method.invoke(target, args); <-- line
416
When running the web application with the new code; I got tossed into my logs:
16:47:54,474 INFO [STDOUT] METHOD public abstract
net.link.safeonline.demo.bank.entity.BankAccountEntity
net.link.safeonline.demo.bank.service.AccountService.createAccount
net.link.safeonline.demo.bank.entity.BankUserEntity,java.lang.String) OF
net.link.safeonline.demo.bank.service.AccountService CREATED BY [EMAIL
PROTECTED]
url=file:/home/devel/safe-online-demo-distribution-1.2-SNAPSHOT/jboss/server/default/tmp/deploy/tmp54088SafeOnlineZDemo.ear
,addedOrder=45}
16:47:54,474 INFO [STDOUT] => ON TransactionServiceBean CLASS $Proxy1057
EXTENDS class java.lang.reflect.Proxy IMPLEMENTS [interface
net.link.safeonline.demo.bank.service.TransactionService, interface
org.jboss.ejb3.JBossProxy] CREATED BY [EMAIL PROTECTED]
url=file:/home/devel/safe-online-demo-distribution-1.2-SNAPSHOT/jboss/server/default/tmp/deploy/tmp54088SafeOnlineZDemo.ear
,addedOrder=45}
16:47:54,474 ERROR [RequestCycle] Method onFormSubmitted of interface
org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
[MarkupContainer [Component id = newAccount, page =
net.link.safeonline.demo.bank.webapp.NewAccountPage, path =
5:newAccount.NewAccountPage$AccountForm, isVisible = true, isVersioned = true]]
threw an exception
...
the rest of the exception you know.
Basically; what we see here is that the "target" variable that the "method" is
being invoked on is NOT an instance of AccountService; but of
TransactionService; which is another one of my service beans. As far as I can
tell wicket-ioc is messing up the Proxies that it's supposed to deserialize.
Note that all service calls to my service beans that happen in the rest of my
wicket application work just fine (so long as they're not in an onSubmit() of a
Form). I assume the onSubmit is just a step too far in the Wicket lifecycle
for the wicket-ioc to handle (seeing as the places where my services do work
fine are all new instances of the Page object that uses them; not deserialized
instances of a submitted Page).
Eg. this one was just fine:
16:47:51,193 INFO [STDOUT] METHOD public abstract java.util.List
net.link.safeonline.demo.bank.service.UserService.getAccounts(net.link.safeonline.demo.bank.entity.BankUserEntity)
OF net.link.safeonline.demo.bank.service.UserService CREATED BY [EMAIL
PROTECTED]
url=file:/home/devel/safe-online-demo-distribution-1.2-SNAPSHOT/jboss/server/default/tmp/deploy/tmp54088SafeOnlineZDemo.ear
,addedOrder=45}
16:47:51,193 INFO [STDOUT] => ON UserServiceBean CLASS $Proxy1054 EXTENDS
class java.lang.reflect.Proxy IMPLEMENTS [interface
net.link.safeonline.demo.bank.service.UserService, interface
org.jboss.ejb3.JBossProxy] CREATED BY [EMAIL PROTECTED]
url=file:/home/devel/safe-online-demo-distribution-1.2-SNAPSHOT/jboss/server/default/tmp/deploy/tmp54088SafeOnlineZDemo.ear
,addedOrder=45}
> IllegalArgumentException while invoking method on injected proxy object
> (object is not an instance of declaring class)
> ----------------------------------------------------------------------------------------------------------------------
>
> Key: WICKET-1848
> URL: https://issues.apache.org/jira/browse/WICKET-1848
> Project: Wicket
> Issue Type: Bug
> Components: wicket, wicket-extensions
> Affects Versions: 1.4-M3
> Reporter: Maarten Billemont
> Assignee: Igor Vaynberg
>
> The problem description:
> I have some EJB service beans which I'd like to use in my wicket application.
> The service beans implement @Local interfaces which all have a public static
> final String BINDING field that contains the JNDI binding of the bean that
> implements them. I use this BINDING field to lookup the bean and inject it
> into my Wicket pages using the JavaEEComponentInjector.
> The problem, however, occurs when accessing methods of these injected bean
> proxy objects. I'm not entirely sure what the cause is and I've noticed the
> issue to be rather unpredictable - probably due to the fact that I really
> don't get what's going wrong.
> In any case; for some reason when I invoke methods on my proxy objects,
> Wicket's proxy object's reflection seems unable to actually perform the call
> on the target object. I know far too little of how proxy objects work
> internally to understand what exactly is going on and what exactly might be
> failing to give any more details than this.
> I'm not sure whether this is an issue in wicket-ioc or wicket-contrib-javaee
> though seeing as the exception originates from within LazyInitProxyFactory
> I'm betting on wicket-ioc (which isn't in the list of components of this
> JIRA?)
> The exception:
> org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface
> org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component
> [Marku
> at
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:193)
> at
> org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73)
> at
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:91)
> at
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1188)
> at org.apache.wicket.RequestCycle.step(RequestCycle.java:1265)
> at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1366)
> at org.apache.wicket.RequestCycle.request(RequestCycle.java:499)
> at
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:387)
> at
> org.apache.wicket.protocol.http.WicketServlet.doPost(WicketServlet.java:145)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
> at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> net.link.safeonline.sdk.auth.filter.ContainerLoginFilter.doFilter(ContainerLoginFilter.java:70)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> net.link.safeonline.sdk.auth.filter.JAASLoginFilter.doFilter(JAASLoginFilter.java:93)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
> at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
> at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
> at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
> at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
> at
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
> at
> org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
> at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
> at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
> at
> org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
> at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
> at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
> at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
> at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
> at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
> at java.lang.Thread.run(Thread.java:595)
> Caused by: java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182)
> ... 34 more
> Caused by: java.lang.IllegalArgumentException: object is not an instance of
> declaring class
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.wicket.proxy.LazyInitProxyFactory$JdkHandler.invoke(LazyInitProxyFactory.java:416)
> at org.apache.wicket.proxy.$Proxy1013.createAccount(Unknown Source)
> at
> net.link.safeonline.demo.bank.webapp.NewAccountPage$AccountForm.onSubmit(NewAccountPage.java:74)
> at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1347)
> at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:797)
> ... 39 more
> The (relevant) Wicket code:
> public class AccountApplication extends WebApplication {
> @Override
> protected void init() {
> addComponentInstantiationListener(new JavaEEComponentInjector(this,
> new IJndiNamingStrategy() {
> private final StandardJndiNamingStrategy defaultStrategy
> = new StandardJndiNamingStrategy();
> @SuppressWarnings("unchecked")
> public String calculateName(String ejbName, Class
> ejbType) {
> try {
> Field bindingField =
> ejbType.getDeclaredField("BINDING");
> Object binding = bindingField.get(null);
> if (binding != null)
> return binding.toString();
> } catch (Exception e) {
> ...
> }
> return this.defaultStrategy.calculateName(ejbName,
> ejbType);
> }
> }));
> }
> ...
> }
> public abstract class LayoutPage extends WebPage {
> @EJB
> transient AccountService accountService;
> ...
> }
> public class NewAccountPage extends LayoutPage {
> ...
> class AccountForm extends Form<String> {
> ...
> @Override
> protected void onSubmit() {
> accountService.createAccount(...);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.