Solved

Dependency injection - @In attribute requires non-null value

Posted on 2011-02-23
14
578 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

757 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

21 Experts available now in Live!

Get 1:1 Help Now