Injecting EJB to JSF Converter

Is it possible to inject EJB (or at least EntityManager) to JSF Converter or Validator?
I don't know if i'm missing something or is it just impossible - it works when injecting EJB into Managed Bean.
Thanks.
Sławek S.

Slawek_Sobotka wrote:
Thanks.
So I'll redefine my question to be problem oriented:
I have SelectItem that contains Address object.
I have implemented AddressConverter so that it converts Adress to String simply by using it's id.
How to convert back: from string (address's id) do Address object?Map it. Two general ways are mentioned here: [http://balusc.blogspot.com/2007/09/objects-in-hselectonemenu.html].
I would like to load it form DB...That's a bit too expensive for less or more static data.
Another solutions are:
- SelectItem should contain address.id instead of address. Than no converter is need. My ManagedBean is reposnsible for translating ids do entities. Works but primitive.JSF can't help that HTTP/HTML only understands Strings (by the way, primitives are also already implicitly converted by EL, you only don't know that).
- Converter is created by factory method of Managed Bean. MB sets address list to the converter while creating it. List shouldn't be huge if it is used in GUI.
drawback: loading list in BB twice because converter is used while rendering and while decoding.
- In converter try to possess MB that has EJB and call method that reutrns entities, sth like this: facesContext.getApplication().getELResolver()...Reloading static data on every request makes als no sense.
Retoric question: what for are useful JSF Converters?To convert between Object and String, so that it can be passed through HTTP request/response and displayed/taken in HTML.

Similar Messages

  • How am I able to use an injected EJB in a Managed Bean Constructor?

    JSF 1.2
    EJB 3.0
    Glassfish v1
    Summary:
    Managed bean injected EJB is null when referencing EJB var in constructor.
    Details:
    In my managed bean, I have a constructor that tries to reference an injected EJB, such as:
    public class CustomerBean implements Serializable {
    @EJB private CustomerSessionRemote customerSessionRemote;
    public CustomerBean() {
    List<CustomerRow> results = customerSessionRemote.getCustomerList();
    }The call within the constructor to customerSessionRemote is null - I've double checked this in Netbeans 5.5.
    How am I able to use an injected EJB in a Managed Bean Constructor?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    OK, I was reading the article Web Tier to Go With Java EE 5: A Look at Resource Injection and I understand your statement too.
    Is there any way possible to Inject the EJB prior to the bean instance creation at all?
    Maybe, I need to approach it with the old fashion Java EE 1.4 route and using JNDI in the PostConstruct annotated method to reference the EJB in the managed bean.
    This had to been thought out before, I don't understand why a manged bean's life cycle places any injections at the end of the bean creation.
    Also, now that I understand that the @PostConstruct annotated method will be called by the container after the bean has been constructed and before any business methods of the bean are executed.
    I am trying to reference my EJB as part of the creation of the managed bean.
    What happens: the JSF page loads the managed bean and I need to populate a listbox component with data from an EJB.
    When I try to make the call to the EJB in the listbox setter method, the EJB reference is null.
    Now, I'm not for sure if the @PostConstruct annotation is going to work... hmmmm.
    ** Figured it out. ** I just needed to move the EJB logic that was still in the setter of the component I wanted to populate into the annotated PostConstruct method.

  • How to inject ejb in servlet

    hi all
    How to inject ejb in servlet ?
    please explain how to config my servlet and my paroject
    I have an ear file with two jar files
    Thanks in advance

    hi
    I have this error in my project
    I have an ear file ,two war file and three jar file in it
    and I did configuration
    but there was this error
    14:19:45,398 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[conference-servlet].[enterLet]] Allocate exception for servlet enterLet: javax.naming.NameNotFoundException: ITrmnlAuthenticationBL not bound
    @Remote
    public interface ITrmnlAuthenticationBL{
    @Stateless
    public class TrmnlAuthenticationBL implements ITrmnlAuthenticationBL{
    public class EnterLet extends HttpServlet {
         @EJB(mappedName = "ITrmnlAuthenticationBL")
         private ITrmnlAuthenticationBL trmnlMg;
    please explain my mistake

  • Best way to inject EJB's in Struts 2

    Hi all,
    I'd like to ask you what do you think is the best way to inject EJB's in Struts 2 Actions (and perhaps other struts classes such as type converters).
    I've read and implemented both a Struts 2 Interceptor and used CDI. About CDI I've read there's a discussion whether the injected resource should be a private field or injected through the constructor which would help testing.
    Personally I seem to prefer CDI as it looks a bit simpler after you are familiar a bit with the technology.
    What is your preferred solution and why?

    Make sure you are using JDeveloper with a "regular Oracle DB" and not Oracle XE - Oracle XE doesn't have support for JPublisher.
    And make sure you are trying to invoke this from the database navigator window and not from the connection manager of your application.
    Anton - I think you are mixing JPublisher with something else - maybe with Java stored procedures?
    JPublisher just creates a JDBC wrapper that calls the functions in the DB - it doesn't run inside the DB so I don't get your point about the mini JVM?
    So it basically does exactly what you recommended: "access PL/SQL procedures from java directly?"

  • Injection @EJB  x  InitialContextLookup

    Hello all,
    what is the "lookup" correspondent to this injection:
    @EJB (mappedName="corbaname:iiop:jupiter:3700#ejb/package.HelloRemote")
    Are the following lines?
    InitialContext ic = new InitialContext();
    HelloRemote hello = (HelloRemote) ic.lookup("corbaname:iiop:jupiter:3700#ejb/package.HelloWorld");
    Why these lines dont work? The injection woks fine, but these lines produces an exception:
    "javax.naming.NameNotFoundException [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]"
    I'm trying for one week now to do this dynamic lookup without succeeding. Please, what am I missing?

    If you're running within a Java EE component the portable way to retrieve the EJB is
    to use a component environment lookup, not a direct global lookup. Just add a
    name() attribute to your @EJB.
    @EJB (name="myejbref", mappedName="corbaname:iiop:jupiter:3700#ejb/package.HelloRemote")
    If the lookup is within an EJB, you can use SessionContext.lookup("myejbref");
    Otherwise, instantiate the no-arg InitialContext and lookup ("java:comp/env/myejbref")
    Whenever the code attempts to bypass the Java EE component environment, it opens
    itself up to portability issues. In this case, we try to support many variations of
    direct global JNDI lookups, but Remote 3.0 Interfaces are not direct CosNaming objects,
    so lookup("corbaname:iiop:...") will not work.
    If you have to pass a dynamic string to the lookup you can try the same approach as
    is recommended for non-Java EE environments, where you create a special
    InitialContext that is configured to point to a particular naming service :
    https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#nonJavaEEwebcontainerRemoteEJB
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem injecting ejb in war

    This problem have dogged me for one week but cant seem to know where the problem is.
    i am creating an enterprise with war, ejb and jar.
    i want both web clients and application client to share the code in ejb to ease maintainablility.
    i have a jsf backing bean that is supposed to get some data from an enterprise bean in ejb.
    the backing bean has this method
    public class CategoryController {
    @Stateful
    public class CategoryControllerBean implements CategoryControllerRemote {
        @PersistenceUnit(unitName = "JNationForum-ejbPU")
        private EntityManagerFactory emf;
        private EntityManager getEntityManager() {
            return emf.createEntityManager();
    public List<CategoryDetails> getCategorys(){
             EntityManager em = getEntityManager();
             List<Category> categorys=null;
             try{
                Query q = em.createQuery("select object(o) from Category as o");
                return copyCategorysToDetails(categorys=q.getResultList());
            } finally {
                em.close();
         private List<CategoryDetails> copyCategorysToDetails(List categorys) {
            List<CategoryDetails> detailsList = new ArrayList<CategoryDetails>();
            Iterator i = categorys.iterator();
            while (i.hasNext()) {
                Category category = (Category) i.next();
                CategoryDetails details = new CategoryDetails(
                        category.getCategorypk(),
                        category.getTitle(),
                        category.getDescription(),
                        category.getActive());
                detailsList.add(details);
            return detailsList;
    }it brings this error
    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    javax.naming.NameNotFoundException: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean#com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean not found
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.

    This problem have dogged me for one week but cant seem to know where the problem is.
    i am creating an enterprise with war, ejb and jar.
    i want both web clients and application client to share the code in ejb to ease maintainablility.
    i have a jsf backing bean that is supposed to get some data from an enterprise bean in ejb.
    the backing bean has this method.package com.safarisoftsolutions.jnationforum.war.bean;
    public class CategoryController {
        @EJB
        private CategoryControllerBean categoryControllerBean;
        public DataModel getCategorys() {
                model = new ListDataModel(categoryControllerBean.getCategorys());
                return model;
    }from the above you can see am trying to get a list from categoryControllerBean.getCategorys() which is a enterprise bean whose code is
    public class CategoryController {
    @Stateful
    public class CategoryControllerBean implements CategoryControllerRemote {
        @PersistenceUnit(unitName = "JNationForum-ejbPU")
        private EntityManagerFactory emf;
        private EntityManager getEntityManager() {
            return emf.createEntityManager();
    public List<CategoryDetails> getCategorys(){
             EntityManager em = getEntityManager();
             List<Category> categorys=null;
             try{
                Query q = em.createQuery("select object(o) from Category as o");
                return copyCategorysToDetails(categorys=q.getResultList());
            } finally {
                em.close();
         private List<CategoryDetails> copyCategorysToDetails(List categorys) {
            List<CategoryDetails> detailsList = new ArrayList<CategoryDetails>();
            Iterator i = categorys.iterator();
            while (i.hasNext()) {
                Category category = (Category) i.next();
                CategoryDetails details = new CategoryDetails(
                        category.getCategorypk(),
                        category.getTitle(),
                        category.getDescription(),
                        category.getActive());
                detailsList.add(details);
            return detailsList;
    }it brings this error
    type Exception report
    message
    descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    javax.faces.FacesException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref com.safarisoftsolutions.jnationforum.war.bean.CategoryController/categoryControllerBean@jndi: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@null@com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean@Session@null into class com.safarisoftsolutions.jnationforum.war.bean.CategoryController
    root cause
    javax.naming.NameNotFoundException: com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean#com.safarisoftsolutions.jnationforum.ejb.bean.CategoryControllerBean not found
    note The full stack traces of the exception and its root causes are available in the Sun Java System Application Server 9.1 logs.

  • Injecting ejb impossible using deployment descriptor ?

    Hi.
    I wanted to inject an EJB reference into a JSF manged bean. @EJB annotation worked, but then I tried <ejb-reb> and <injection-target> and EJB reference wasn't injected.
    Looking at the specification, it seems that this is not supported. Is there any other possibility or am I forced to use annotations?

    Hi.
    I wanted to inject an EJB reference into a JSF manged bean. @EJB annotation worked, but then I tried <ejb-reb> and <injection-target> and EJB reference wasn't injected.
    Looking at the specification, it seems that this is not supported. Is there any other possibility or am I forced to use annotations?

  • Parametrized JSF Converter

    Hello
    my question:
    for example i have a h:selectOneMenu, witch present the streets in the any (chose before) town
    this selection in xhtml page looks like
    <h:selectOneMenu id="town_4"     value="#{locationAddAction.street}" immediate="true">
         <f:selectItems value="#{locationAddAction.streetLookup}" />
         <fmedia:streetConverter town="#{locationAddAction.town}" />
    </h:selectOneMenu>in my project i need to convert a string into Street object stored in DB
    but there are can be many streets with the same names, but difference in town reference
    so i need the town attribute in converter
    my converter class extends javax.faces.convert.Converter
    public class StreetConverter implements Converter {
         private LocationService locationService = new LocationService();
         private Town town;
         @Override
         public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
              Town town = locationService.getStreetByNameMatch(town,arg2)
              return town;
         @Override
         public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
              if (arg2 instanceof Street)
                   return ((Street) arg2).getName();
              return null;
         public Town getTown() {
              return town;
         public void setTown(Town town) {
                    this.town = town;
    }i registered my converter with parameter in faces-config.xml
    <converter>
              <converter-id>streetConverter</converter-id>
              <converter-class>package.StreetConverter</converter-class>
              <attribute>
                   <attribute-name>town</attribute-name>
                   <attribute-class>package.Town</attribute-class>
              </attribute>
         </converter>and create my facelet tag
    <tag>
              <tag-name>streetConverter</tag-name>
              <converter>
                   <converter-id>streetConverter</converter-id>
              </converter>
         </tag>PROBLEM:
    any request to my converter (StreetConverter, <fmedia:streetConverter>) set the new creation of my Converter
    but the initialization of "town" field happend only once in creation page (when i'm requesting whole jsf page) and any request to converter is erasing my town parameter, becouse it has been init in another converter object.
    how can i initialize town attribute in all requests to converter ?
    sorry my horrible english
    thanks =)

    Use f:attribute:<h:someComponent>
        <f:converter converterId="streetConverter" />
        <f:attribute name="town" value="#{bean.town}" />
    </h:someComponent>
    public X getAsX(FacesContext context, UIComponent component, Y value) {
        Object town = component.getAttributes().get("town");
    }Alternatively just get the bean from context:
    public X getAsX(FacesContext context, UIComponent component, Y value) {
        Bean bean = (Bean) context.getApplication().evaluateExpressionGet(context, "#{bean}", Bean.class);
        Town town = bean.getTown();
    }

  • Inject EJB using @EJB in Servlet Filter on Weblogic 11g

    Hi All,
    I want to inject the EJB (Local interface) into the Servlet Filter and the EAR is deployed on Weblogic 11g.
    My question is:
    Shall the @EJB Annotation work on Weblogic 11g or it will be ignored in case of Servlet or Servlet Filter?
    OR
    I have to do look up as below and mention the references in web.xml and weblogic xml file:
    I know below code should be used when you have remote interface.
    Hashtable env = new Hashtable();
    env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
    Context ctx = new InitialContext( env );
    ctx.lookup( "myejb" );
    Thanks

    Hi,
    It should work in 11g.
    Regards,
    Kal

  • Dependecy injection EJB into a jsp

    Hello,
    How can I do a dependency injection of and EJB into a jsp?
    When Iu2019m trying to used it (see below), It doesnu2019t work, What Iu2019m doing wrong?
    Also I tried to do a lookup, but I canu2019t do a cast because the classe returned by the lookup is some Proxy class and the only way that Iu2019ve find to access the EJBu2019s methods is through reflection.
    Regards,
    Janeth
    @EJB (name = "crystal.com.co/captura_produccion_ear/CapturaPrimeraEjbBean")
         private CapturaPrimeraEjbRemote capPrimeraEjbRemote;
    if (capPrimeraEjbRemote != null) {
           capPrimeraEjbRemote.test();
    else{
              out.println("null");

    Thank both for the answer, about the lookup:
    Vladimir you are right about implementation, actually I print trough reflection the interfaces of Proxy class, and I obtain this:
    co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote
    javax.ejb.EJBObject
    com.sap.engine.services.ejb3.runtime.ComponentInterface com.sap.engine.services.ejb3.runtime.ReplaceableProxy
    The common code is:
    Properties props = new Properties();
         props.put(Context.INITIAL_CONTEXT_FACTORY,
                   "com.sap.engine.services.jndi.InitialContextFactoryImpl");
         props.put(Context.PROVIDER_URL, "localhost:50004");
         InitialContext ctx = new InitialContext(props);
         Object object = ctx.lookup("crystal.com.co/captura_produccion_ear/REMOTE/CapturaPrimeraEjbBean/co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote");
         out.println(object.getClass());
    If I do injection, itu2019s work correctly:
    Method findAll = object.getClass().getMethod("test", null);
         String listaTurnos = (String) findAll.invoke(object, null);
         out.print(listaTurnos);
    But if I use narrow or cast, it doesnu2019t work (I get a java.lang.ClassCastException):
    co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote capPrimera = (co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote)PortableRemoteObject.narrow(object, co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote.class);
         String listaTurnos = capPrimera.test
         out.print(listaTurnos);
    or the cast:
    co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote capPrimera = (co.com.crystal.eficiencia.primera.CapturaPrimeraEjbRemote)object;
    What I have to do to check the correctly way to do the cast or the narrow? What Iu2019m doing wrong?
    Thanks
    Janeth

  • JSF Converter - bug

    When J associate my converter to HtmlDataTable(h:dataTable) in JSF(JSP) page in 'Design' tab appear problems:
    1) in dataTable there isn't any column visable
    2) everything below dateTable in same Panel Grid aren't visable
    All this affect only 'Design' tab. In 'Source' tab everything is OK and when J run application everithing work like it should.
    Is this bug or can be fixed somehow?

    Hi.
    J solve the problem partly and here is the problem and solution:
    Problem - JDeveloper 10.1.3 have problem in showing table when code look like this:
    <h:dataTable width="350" value="#{infoBean.popular}" var="popular_">
    <h:column>
    <f:facet name="header">
    <h:panelGroup>
    <h:commandLink action="POPULAR">
    <h:outputText value="Najpopularnije"/>
    </h:commandLink>
    </h:panelGroup>
    </f:facet>
    <h:commandLink>
    <h:outputText value="#{popular_}" converter="ProductTitle"/>
    </h:commandLink>
    </h:column>
    </h:dataTable>
    Solution - When J change code to this 'Design' tab shows the table but not the text in 'outputText'(here #{popular_}):
    <h:outputText value="#{popular_}">
    <f:converter converterId="ProductTitle"/>
    </h:outputText>
    Please try this!

  • Injecting ejbs via @Resource

    Hi all,
    I have an ejb that injects a helper ejb like
    @EJB
    Helper help; and whose business method calls the helper beans business method. This works fine.
    Now I try to inject the helper ejb as
    @Resource(name="Helper") 
    Helper help; The first call of the ejb's business method from the client works fine, but the second one throws the following exception (extract):
    org.omg.CORBA.BAD_OPERATION: The delegate has not been set!
    Please, can someone, who has an ejb that injects another ejb, check if he gets the same problem when @EJB is replaced through something like @Resource(name = ...).
    Thanks in advance.
    I googled for the error message and found search results dating from around 2004 where the error was due to a bug in the Java-IDL mapping of an old java version. I'm working with glassfish v2 and java 1.6.

    Hi, thanks for your reply.
    Is there a particular behavior you would like that you don't think is available when using @EJB?No. I read in "EJB 3 in action", 5.2.1 that @Resource can "be used for [...] environment entries, ORB reference and even EJB references" and just tried it out.

  • Problems with ADF when running sample EJB, JPA, JSF Tutorial

    Hi,
    I'm new to jDeveloper.
    I've downloaded the version 11.1.1.2.0 and tried to do my first tutorials with the product.
    I started with the sample 'Build Applications with EJB, JPA and JSF' and run to following problems:
    - Part1: Step 10 expose the EJb as a Data Control
    Here right-click FODFacadeBean.java and choose Create Data Control.
    this option 'Create Data Control' does not come up at all. There is not such option
    - Part 2: Step 1 Add Tag Libraries to a project
    The option to select ' ADF Faces Components 11 '
    does not come up either. I can not see any ADF related options...
    Is there something missing from my installation, as I can not access these ADF components ?
    Should I include the ADF components at some stage during the installation to be able to access these
    or is this some licencing option ?
    I downloaded the product yesterday from the public download site, filename jdevstudio11112install.exe
    Jan-Erik

    Hi,
    I'm new to jDeveloper.Welcome to OTN :)
    I've downloaded the version 11.1.1.2.0 and tried to do my first tutorials with the product.
    I started with the sample 'Build Applications with EJB, JPA and JSF' and run to following problems:
    - Part1: Step 10 expose the EJb as a Data Control
    Here right-click FODFacadeBean.java and choose Create Data Control.
    this option 'Create Data Control' does not come up at all. There is not such optionI just tried and able to see the option (and able to generate the DC from the facade as well). Could you please share the tutorial link to see if you are missing something?
    >
    - Part 2: Step 1 Add Tag Libraries to a project
    The option to select ' ADF Faces Components 11 '
    does not come up either. I can not see any ADF related options...Did you select Fusion Web Application (ADF) Template for creating your application? If yes, the ADF Faces Components 11 tag library would've been added by default (Check out in the list of tag libraries that are already added - before clicking on the Add button).
    -Arun

  • JSF Converter Error

    Hi, I have the following:
    JSF 1.2 RI
    Sun App Server 9 Update 1 Patch 1
    Models:
    public interface Model {
      int getId();
      String getName();
    public class Model1 implements Model {
      public int getId() {
        return 1;
      public String getName() {
        return "One";
    public class Model2 implements Model {
      public int getId() {
        return 2;
      public String getName() {
        return "Two";
    Controller:
    public class TestController {
      private Model model;
      private List<Model> models;
      public TestController() {
        models = new ArrayList<Model>();
        models.add(model = new Model1());
        models.add(new Model2());
      public Model getModel() {
        return model;
      public void setModel(Model model) {
        this.model = model;
      public List<SelectItem> getModels() {
        List<SelectItem> list = new ArrayList<SelectItem>();
        for (Model model : models)
          list.add(new SelectItem(model, model.getName()));
        return list;
      public Model findModel(int id) {
        for (Model model : models) {
          if (model.getId() == id)
            return model;
        return null;
    Converter:
    public class ModelConverter implements Converter {
      public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String string) {
        TestController controller = (TestController) facesContext.getExternalContext().getSessionMap().get("testController");
        return controller.findModel(Integer.parseInt(string));
      public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object object) {
        return String.valueOf(((Model) object).getId());
    View:
    <%@ page contentType="text/html" %>
    <%@ page pageEncoding="UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <title>Test JSF</title>
    </head>
    <body>
    <f:view>
      <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
      <h1>Test JSF</h1>
      <h:form>
        <h:panelGrid columns="2">
          <h:outputText value="Model:"/>
          <h:selectOneMenu value="#{testController.model}">
            <f:selectItems value="#{testController.models}"/>
          </h:selectOneMenu>
        </h:panelGrid>
      </h:form>
    </f:view>
    </body>
    </html>
    faces-config.xml:
    <?xml version='1.0' encoding='UTF-8'?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
                  version="1.2">
      <converter>
        <converter-for-class>com.test.model.Model</converter-for-class>
        <converter-class>com.test.converter.ModelConverter</converter-class>
      </converter>
      <managed-bean>
        <managed-bean-name>testController</managed-bean-name>
        <managed-bean-class>com.test.controller.TestController</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
      </managed-bean>
    </faces-config>
    The problem:
    When I run the app, JSF throws the following error:
    javax.servlet.ServletException: Cannot convert com.test.model.Model2@ba30aa of type class com.test.model.Model2 to class com.test.model.Model1
    root cause
    java.lang.IllegalArgumentException: Cannot convert com.test.model.Model2@ba30aa of type class com.test.model.Model2 to class com.test.model.Model1Is there any limitation on converters to prevent using a single Converter for a base class (or interface like Model) and subclasses (like Model1 and Model2)?
    I've tried this using JSF 1.1 RI, Apache MyFaces 1.1 and the error is still there.
    Thanks!

    This sounds like Issue 442, which was resolved in 1.2_03. If I recall right, V1 P1 is 1.2_02. Please upgrade JSF to 1.2_04 [2]. The download section has an updater for GlassFish.
    [1] https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=442
    [2] https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=7089&expandFolder=7089&folderID=0

  • Is it possible to inject EJB 3.0 SLSB into EntityImpl?

    Hello,
    I'm running JDev Studio Edition Version 11.1.2.3.0.
    Is it possible to inject an EJB 3.0 stateless session bean into an EntityImpl Class via the @EJB annotation? I need to do so in order to use the SLSB to schedule an EJB 3.0 timer.
    If injection is not possible, how do I do a manual lookup?
    Any suggestions with sample config and code would be appreciated.
    Many thanks.

    So you're saying that there are going to be new features in the released product that have not been tested in a beta release? I can't believe you'd go to release without another public beta considering the number of bugs there are in the current public beta never mind what else might be introduced by new features. That aside I appreciate the work of the developers.
    Also, I've seen several posts that refer to bug tracking ids. Where is the bug database? It's hard to know if a bug should be submitted here on this board without knowing which bugs have already been identified. With JDeveloper now available for use by the masses, a public database is essential to keeping message board traffic manageable. An RSS feed for the bug database would be an excellent feature.

Maybe you are looking for

  • How to give Authorization?

    I have created a 'Z' application which consists of create, change and display User interface.Whenever the user selects craete all fields go editable, change will have some fields editable and display all uneditable.I used only one view and i handled

  • Unions in stored procedures

    We've been still using 8i but just had an instance of 9i put up in our development region. We're trying to take a dynamic sql statement with many unions and create a stored procedure. I understand this was a problem in 8i. We're still getting ambiguo

  • How to hide a tab from the existing tabstrip of CRMD_BUS2000111 transaction

    I have to hide competitor tab from the tabstrip of CRMD_BUS2000111 transaction in CRM. I have tried shd0 but since this is not a dialog transaction we cannot create screen variant. After that I tried BUCO transaction.In BUCO I selected Sales Area dat

  • MRP Pricing

    Dear SD Gurus, I have scenario where the client has the MRP price requirement, it is a reverse calculation the MRP price and dealer price is declared in the price list based on these two components you we have to arrive at the base price, has any one

  • Scratch Disck Question

    I have a 150 Raptor 100000rpm 16 cache 500gb 7200rpm 16 cache and 1Tgb 7200 rpm 32 cache My questions wich one I should use as my main hard drive, and wich one I should use as my Photoshop Scratch Disck ? Thinking to have better performance with phot