1

Environment:

Wildfly 9.0.1

JSF: jsf-impl-2.2.11-jbossorg-1

WELD: wildfly-weld-9.0.1

I have this scenario:

CustomerController.java

public abstract class CustomerController {

   public String registerCustomer(){
      //Do something and return success page
      return SUCCESS_PAGE;
   }
}

Type1CustomerController.java

@Named
@ViewScoped
public class Type1CustomerController extends CustomerController{

     public String registerCustomer(){
       super.registerCustomer();

      //Special case, just go back to login and allow login
      return SUCCESS_LOGIN_PAGE;
   }
}

Type2CustomerController.java

@Named
@ViewScoped
public class Type2CustomerController extends CustomerController {

   //Does not override the registerCustomer method, but adds some functionlities based on some abstract definitions on the superclass and simply shows success_page
}

CustomerSelectionController.java

@ApplicationScoped
public class CustomerSelectionController {

   @Inject
   private Instance<Type2CustomerController> type2CustomerController;


   @Inject
   private Instance<Type1CustomerController> type1CustomerController;

   @Produces
   @ViewScoped
   @Named("customerController")
   public CustomerController customerController() {
      if(someConditionsAreMet())
         return type1CustomerController.get();

       //Otherwise return type2 customer controller
      return type2CustomerController.get();
   }
}

Now when the Type2CustomerController is selected, everything works fine. When the Type1CustomerController, disaster strikes:

Method not found: class com.mycompany.view.internal.controller.customer.Type1CustomerController$Proxy$_$$_WeldClientProxy.registerCustomer()
    at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109)
    at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)

What can be the issue, that the superclass method, overriden in the Type1Controller is not found by EL?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
maress
  • 3,533
  • 1
  • 19
  • 37
  • Did you use google or similar? I'm sure I've seen articles or even duplicates here with answers – Kukeltje Oct 19 '15 at 22:02
  • @kukeltje am sure if you had seen such duplicates you would have been prudent enough to link them here other downvoting and making an invalid assumption – maress Oct 20 '15 at 06:32
  • I did not downvote... sorry... And no I don't always have the time nor the urge to actually search for the duplicates that I (think I) saw several weeks/months ago. And it might be that the 'duplicates' I think exists are not actually full duplicates. But knowing so is knowledge to. – Kukeltje Oct 20 '15 at 07:35
  • And how is this JSF related? I don't see any facelets code. And calling registerCustomer on 'Type2....' works? Did you read http://docs.jboss.org/cdi/spec/1.2/cdi-spec.html#inheritance? – Kukeltje Oct 20 '15 at 07:41
  • @Kukeltje surely, you dont see the first line of the exception trace? besides, this method is being called from jsf page – maress Oct 20 '15 at 08:26
  • Anyhow, the problem here was that the superclass was package private, and i still cant figure out how package visibility affected one bean and the other was not affected – maress Oct 20 '15 at 08:31
  • Oh yes, I see that first line, but that that does not make clear **how** it is used. The **how** can make a difference in a lot of cases. Regarding the private.. this is **not** in the code above. So we were actually trying to find something that was not there... Tried to **not** call the `super.registerCustomer();` and see if that makes a difference? And are you sure you did not switch the Type2 and Type1 code in the code above? – Kukeltje Oct 20 '15 at 08:57

0 Answers0