views:

39

answers:

1

I am using Seam 2.0 and I have an instance variable inside my bean as

@In Identity identity 

and when I use identity.getUserName() it throws NullPointerException. Can anyone tell me please what I am missing here additionally?


Update: I have defined bean instance variable as below:

@In Identity identity;

Then in my bean constructor I simply added below line to welcome the user -

System.out.println("Welcome - " +identity.getUsername());

I see below error on my Jboss console :

Caused by: java.lang.NullPointerException
    at com.lntebg.quality.QualityInspectionPlan.<init>(QualityInspectionPlan.java:63)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at org.jboss.seam.Component.instantiateJavaBean(Component.java:1315)
    at org.jboss.seam.Component.instantiate(Component.java:1271)
    at org.jboss.seam.Component.newInstance(Component.java:1973)
    ... 279 more
+1  A: 

Some ideas:

  • Are you injecting Identity inside a Seam component?
  • Seam cannot inject inside the constructor.
  • Do you have these snippets in your components.xml?

<core:init security-enabled="true" />

and

<security:identity />

Markos Fragkakis

related questions