• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 650
  • Last Modified:

Dependency injection - @In attribute requires non-null value

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
dkim18
Asked:
dkim18
2 Solutions
 
Sathish David Kumar NCommented:
I think its ur Seam version problem ? can you tell which version your using ?
0
 
dkim18Author Commented:
I am using jboss-4.2.3.GA
0
Independent Software Vendors: 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!

 
objectsCommented:
what value is being injected for projectYear
0
 
dkim18Author Commented:
"2011" or "2010"
0
 
objectsCommented:
where is that value coming from?
0
 
dkim18Author Commented:
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
 
dkim18Author Commented:
sorry, it should be:
projectYear = "2011";
0
 
objectsCommented:
but your annotation defines that the value will be injected
If its not being injected then remove the annotation
0
 
dkim18Author Commented:
I tried removing the annotation. I still get null for this line of code.

authenticator.getProjectYear():
0
 
objectsCommented:
is it getting authenticated?
0
 
dkim18Author Commented:
no. I am just trying to set projectYear depends on id&password and get that value from other class.
0
 
objectsCommented:
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
 
dkim18Author Commented:
the solution wasn't completed.
0

Featured Post

Industry Leaders: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now