cancel
Showing results for 
Search instead for 
Did you mean: 

Getting null point exception when i use modelService.create(Object.class)

Former Member
0 Kudos

when i test this this code as follows: handlingUnitModel = modelService.create(HandlingUnitModel.class) but handlingUnitModel is null,and then throws the exception. can you tell me why? thank you very much.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member387866
Active Contributor
0 Kudos

Hi Devin,

In your-extension-spring.xml where you are defining the bean, have you injected the modelService?

 <bean id="mySpringBeanWithDependency" class="package.MySpringBeanWithDependency">
     <property name="modelService" ref="modelService" />
 </bean>

In your code file do you have the following?

 public class MySpringBeanWithDependancy {
     private ModelService modelService;
     ...
     @Required public void setModelService(ModelService modelService) {
         this.modelService = modelService
     }
 }

Regards,
Luke

Former Member
0 Kudos

yeah,I just coded as you said,but note one,i got this error in My UnitTest,is there difference?

Former Member
0 Kudos

I'm sorry,i didn't say it clearly,after i used this method to produce a Object,but this object is null

former_member387866
Active Contributor
0 Kudos

Hi Devin,

Have you run ant all updatesystem and updated the jUnit tennant too, so that it has your HandlingUnitModel?

Regards, Luke

Former Member
0 Kudos

Hi,

Are you sure modelService is not null?

Former Member
0 Kudos

sure,i debug this process,modelService is not null.

Former Member
0 Kudos

I'm sorry,i didn't say it clearly,after i used this method to produce a Object,but this object is null