Solved

Dependency injection - @In attribute requires non-null value

Posted on 2011-02-23
14
586 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
The viewer will learn how to implement Singleton Design Pattern in Java.

776 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