Solved

Dependency injection - @In attribute requires non-null value

Posted on 2011-02-23
14
603 Views
Last Modified: 2012-05-11
Hi experts,

I am working on jboss seam project and having error dependency injection.
I have auto generated Authenticator class :


@Name("authenticator")
public class Authenticator {

       @In(create= true)
	private String projectYear;
...

        public boolean authenticate() {
...

              private projectYear = "2001";
...

         public String getProjectYear() {
		return projectYear;
	}

	public void setProjectYear(String projectYear) {
		this.projectYear = projectYear;
	}
++++++++++++++

Open in new window




I have this error:
@In attribute requires non-null value: authenticator.projectYear


Another question is:

authenticator.getProjectYear():

The above gives me null in other class. Why is that? (I can still set projectYear though.)

thanks,
0
Comment
Question by:dkim18
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
14 Comments
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 34962850
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 34964081
I think its ur Seam version problem ? can you tell which version your using ?
0
 

Author Comment

by:dkim18
ID: 34964105
I am using jboss-4.2.3.GA
0
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 
LVL 92

Expert Comment

by:objects
ID: 34964720
what value is being injected for projectYear
0
 

Author Comment

by:dkim18
ID: 34964734
"2011" or "2010"
0
 
LVL 92

Expert Comment

by:objects
ID: 34964788
where is that value coming from?
0
 

Author Comment

by:dkim18
ID: 34964828
I am setting it Authenticator class.

@Name("authenticator")
public class Authenticator {

...

if ("khsa".equals(credentials.getUsername()) && "khsa2011".equals(credentials.getPassword())) {

                        identity.addRole("khsa2011");
                        
                        projectYear = "2001";

                        return true;
}

************

And I am trying to access projectYear  from other class.
0
 

Author Comment

by:dkim18
ID: 34964835
sorry, it should be:
projectYear = "2011";
0
 
LVL 92

Expert Comment

by:objects
ID: 34964895
but your annotation defines that the value will be injected
If its not being injected then remove the annotation
0
 

Author Comment

by:dkim18
ID: 34964942
I tried removing the annotation. I still get null for this line of code.

authenticator.getProjectYear():
0
 
LVL 92

Expert Comment

by:objects
ID: 34965008
is it getting authenticated?
0
 

Author Comment

by:dkim18
ID: 34965032
no. I am just trying to set projectYear depends on id&password and get that value from other class.
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 34965056
you're setting it in authenticate() from what I can see.
If you're not calling that method, and you're not injecting it then its not going to be set
0
 

Author Closing Comment

by:dkim18
ID: 35416823
the solution wasn't completed.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

687 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question