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 528073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:56:56+00:00 2026-05-13T08:56:56+00:00

I am using Seam to inject beans to my controller using @In annotation. The

  • 0

I am using Seam to inject beans to my controller using @In annotation. The injected class has a custom annotation, when calling injectedClass.getClass().getAnnotation(annotationClass) it returns null.

When debug I found that Seam passes a proxy instance so getClass() returns InjectedClass_$$_javassist_seam_5 which doesn’t have my custom annotation.

How I can get my custom annotation from the proxy class?

Here’s how my classes look like:

@CustomAnnotation(value="myvalue")
@Name("myAnnotatedClass")
public class MyAnnotatedClass extends SuperClass {...}

@Scope(ScopeType.SESSION)
@Name("myController")
public class MyController {
     @In("#{myAnnotatedClass}")
     private MyAnnotatedClass myAnnotatedClass;

     public void actionMethod(){
         //call another class which call myAnnotatedClass.getClass().getAnnotation(CustomAnnotation.class)
         //then do some reflection for MyAnnotatedClass fields 
     }
}
  • 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-05-13T08:56:56+00:00Added an answer on May 13, 2026 at 8:56 am

    Good question.

    When you call a method by using Seam, it is intercepted by a proxy. And this one enables @In or @Out-jection. But There is an exception to this rule: it does not work when you call an internal method

    So try this code

    @Name
    public class Service {
    
        @In
        private MyAnnotatedClass myAnnotatedClass;
    
    
        public void myInterceptedMethod() {
            // internal method bypass interceptor
            // So @In or @Out-jection is not enabled
            internalMethod();
        }
    
        private void internalMethod() {
            System.out.println(myAnnotatedClass.getClass().getAnnotation(annotationClass));
        }
    
    }
    

    Added to original answer

    You want to retrieve an annotation from your bean. But, because of method interceptor, myAnnotatedClass.getClass() returns a proxy object, not the bean class itself.

    For each bean class, Seam creates a Component definition, in which is stored in the application context. The name of the attribute follows this pattern: component name plus .component. So if you have a bean like this one

    @Name("myBean")
    public class MyBean {
    
    }
    

    Its Componet definition is stored in the attribute myBean.component

    So inside your method, you can use

    Component myBeanComponentDefinition = (Component) Context.getApplicationContext().get("myBean.component");
    

    Now you can call

    myBeanComponentDefinition.getBeanClass().getAnnotation(CustomAnnotation.class);
    

    regards,

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

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Of course there isn't -- if today's January 31, what… May 13, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer There are legal issues with using Google Maps within J2ME… May 13, 2026 at 7:18 pm
  • Editorial Team
    Editorial Team added an answer The only thing I can think of that would turn… May 13, 2026 at 7:18 pm

Related Questions

I have a strange behaviour going on. I am using Seam and JBPM. When
I am getting a NullReferenceException when SubSonic calls the default contructor for my database.
I am a newbie to Java Web Application development. So far all I have
I am trying to read database scripts in a Jar file so that I
I'm currently working on a performance critical application which incorporates legacy c code (a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.