Solved

Dependency injection - @In attribute requires non-null value

Posted on 2011-02-23
14
582 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
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
 
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 71
why cannot we forward request once the response is committed 2 33
servlet  URL Rewriting 1 27
hibernate insert example 13 13
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

895 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now