Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8755047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:46:02+00:00 2026-06-13T13:46:02+00:00

I wrote a converter. I am using CDI and injection parallel. In that case

  • 0

I wrote a converter. I am using CDI and injection parallel. In that case the classes are not injected. How can I make the injection possible?

@FacesConverter(forClass = MyClass.class)

public class MyConverter implements Converter{

    @EJB
    private ClassForEJB classForEJB;

    @Inject
    private ClassForInject classForInject;

// Converter Methods
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:46:04+00:00Added an answer on June 13, 2026 at 1:46 pm

    The @FacesConverter isn’t an eligible injection target. Replace it by @ManagedBean or @Named. As you’d like to use CDI as as well, use @Named.

    @Named
    @ApplicationScoped // I assume that your converter doesn't have any state.
    public class MyConverter implements Converter {
        // ...
    }
    

    You only need to change the way it’s been referenced in the views. You cannot rely on forClass anymore. You’d need to explicitly specify it as #{myConverter}.

    <h:inputSomething ... converter="#{myConverter}" />
    

    or

    <h:inputSomething ...>
        <f:converter binding="#{myConverter}" />
    </h:inputSomething>
    

    If you really need to keep the @FacesConverter in favor of forClass, then you’d need to grab the EJB manually by JNDI. A concrete example is shown in this blog article. I can however not tell that for CDI beans.

    The JSF guys have confirmed this embarrassing oversight and they will make the @FacesConverter an eligible injection target in upcoming JSF 2.2, see also JSF spec issue 763 JSF 2.3.

    See also:

    • How to inject @EJB, @PersistenceContext, @Inject, @Autowired, etc in @FacesConverter?

    Update if you happen to use JSF utility library OmniFaces, or are open to using it, since its version 1.6, when just having OmniFaces JAR in /WEB-INF/lib, all @FacesConverters (and @FacesValidators) in your webapp automatically become eligible for CDI and EJB injection without any extra effort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote an application using Visual Studio 2010 that I configured to run using
Here is v1.0 of the binary_to_decimal converter I wrote. I want to make several
I wrote a simple parallel matrix multiplication using par and pseq . After running
I have some python code that I wrote to convert a python list into
One of my coworkers wrote a .NET windows service that converts .doc to .docx
I have and old(ish) C# method I wrote that takes a number and converts
I've been trying to build a pepXML to mzIdentML converter and using this validator
How do you write a java program using a recursive method that takes in
I have a bunch of diagrams created using a Java diagramming tool that I
I am trying to compile a simple script I wrote using Python3 and PyQt4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.