Howard i see you have this problem using the converter with primefaces autocomplete, just for curiosity do you have a p:ajax inside of the component? If so can you paste your p:ajax tag? I comment this because i had the same problem like you but i didnt use static in my converter. El 13/04/2013 08:47, "Howard W. Smith, Jr." <smithh032...@gmail.com> escribió:
> Mike, > > On Sat, Apr 13, 2013 at 8:38 AM, Mike Kienenberger <mkien...@gmail.com > >wrote: > > > > > Maybe your problem is that you are missing the no-arg constructor for > > the converter. > > Maybe that was why it worked when it was static. > > > > Interesting. I'm definitely still novice to java, especially use of > 'static', even though i used it, primarily, for adding static strings > throughout the app. All along, I knew that 'static' means that only one > copy will be created/instantiated within/for the parent class. > > I think the static reference was added (by Netbeans, when it generated the > code for me, back in 2011), because of the following: > > Below, you will see that the managed bean has a reference to a stateless > @EJB (DAO), > > @ManagedBean(name = "customerController") > @RequestScoped > public class CustomerController implements Serializable { > > @EJB > private jpa.session.CustomerFacade ejbFacade; > > and, the CustomerControllerConverter.getAsObject() method references the > @EJB which is a member of the managed bean, CustomerController. See below. > > CustomerController controller = (CustomerController) > facesContext.getApplication().getELResolver(). > getValue(facesContext.getELContext(), null, > "customerController"); > return controller.ejbFacade.find(getKey(value)); > > > > > > > > Was there additional information in java.lang.InstantiationException, > > like a root cause? > > > > I'll have to take a look at that, but I see MyFaces ApplicationImpl which > throws the exception, but haven't made my way to looking at > java.lang.InstantiationException, just yet. > > > > > > The two things I would try are > > 1) move it to a separate class > > 2) add a no-arg constructor > > > > > Will try this and let you know. I think it still may be necessary to add > the class as a 'public static' class, so there will be only one instance of > @FacesConverter(forClass = Customer.class) during runtime. > > > > I haven't really written many converters since the annotation support > > was added, but this is what one of the few I did write looks like. > > This was a quick proof of concept thing, so I didn't take the time to > > debug why @FacesConverter(forClass = ) wasn't working for me but > > instead manually specified a converter id in the one place I used the > > converter. > > > > Yeah, I really prefer not to use converter id, or I would have to go all > throughout my xhtml and update, accordingly. Thanks. > > Will share any/all updates, ASAP. Thanks Mike! >