cancel
Showing results for 
Search instead for 
Did you mean: 

java.lang.IllegalArgumentException: model object must not be null

Former Member
0 Kudos

Hi,

first of all, my enviroment:

1. DC ejbrecipe (EJB Module), containing the EJB Beans:

- one Entity Bean Cook

- one Session Bean RecipeBean with a local Interface and a method: [code]public Cook getCook();[/code]

- the method implementation:

[code]

Cook c = new Cook();

c.setName("Chefkoch");

return c;

[/code]

2. DC earecipe (Enterprise Application)

- the earecipe is only for the webdynpro component to forward the beans via public parts

3. DC wdrecipe (WebDynpro Application, uses earecipe)

- created a application, with a view

- created a model "MyModel" wich is linked to the EJB Bean

- the Component Controller is linked to the model "MyModel"

- in the Component Controller in "wdDoInit":

[code]

com.test.model.MyModel model = new com.test.model.MyModel();

wdComponentAPI.getModelInstanceMap().putDefaultInstance("com.test.model.MyModel", model);

- the view context is linked to the component controller context

- on the view there is a input fiield, with it's value linked to "Response_RecipeLocal_getCook"

[/code]

when i fire up the application i get:

[code]

java.lang.IllegalArgumentException: model object must not be null

at com.sap.tc.webdynpro.progmodel.context.ModelNodeElement.<init>(ModelNodeElement.java:63)

at recipeapp.comp.wdp.IPublicRecipeComp$IResponse_RecipeLocal_getCookElement.<init>(IPublicRecipeComp.java:296)

at recipeapp.comp.wdp.IPublicRecipeComp$IContextNode.doCreateElement(IPublicRecipeComp.java:53)

at com.sap.tc.webdynpro.progmodel.context.NodeInfo.createElement(NodeInfo.java:1064)

at com.sap.tc.webdynpro.progmodel.context.Node.createElementInternal(Node.java:1047)

[/code]

What am i doing wrong?

regards,

Christian

Message was edited by:

Christian Pelster

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Christian, what is cardinality of your model node? Is it 1..Smth.?

Former Member
0 Kudos

Hi,

its 1..1, as mentioned in the tutorials.

Regards

former_member182372
Active Contributor
0 Kudos

Make it 0..1 and try.

Former Member
0 Kudos

Hi,

thanks for your qucik response, at least the model is null error has gone.

this is how my init looks now:


	  	com.test.model.RecipeModel model = new com.lhsystems.recipe.model.RecipeModel();
	  	wdComponentAPI.getModelInstanceMap().putDefaultInstance("com.test.model.RecipeModel", model);
	
	  	try
	  	{
	  		wdContext.currentRequest_RecipeLocal_getCookElement().modelObject().execute();
	  		wdContext.nodeRequest_RecipeLocal_getCook().invalidate();
	  	}
	  	catch (Exception e)
	  	{
	  	}

but my input field remains empty when i launch my application, i read somewhere that i have to tell the input element that there ist changed content available.

i also debuged the application and noticed that the RecipeBean never gets called.

Regards,

Christian

former_member182372
Active Contributor
0 Kudos

Do you perform binding like Luciano said?

>>2 - At the init method in the controller put these code:

>>RecipeBean recipeBean = //get the sesssion bean instance

>>wdContext.nodeRecipeBean().bind(recipeBean);

Former Member
0 Kudos

hi,

unfortunately not, becuase my wdContext offers no "nodeRecipeBean()" method, do you have a hint how to get it?

Thanks,

Christian

former_member182372
Active Contributor
0 Kudos

>>but my input field remains empty when i launch my application,

Is input field text prperty bound to any context attributes?

Former Member
0 Kudos

Hi,

yes it's bound to:

Request_RecipeLocal_getCook.Response.return.name

Regards,

Christian

former_member182372
Active Contributor
0 Kudos

Try this


try
{
wdContext.currentRequest_RecipeLocal_getCookElement().modelObject().execute();
wdContext.nodeRequest_RecipeLocal_getCook().invalidate();
wdContext.nodeResponse().invalidate();
}
catch (Exception e)
{
}

Former Member
0 Kudos

Hi,

thats more a chat than a forum discussion =).

Anyway, i tried you proposition and and got the following:


java.lang.ClassNotFoundException: com.lhsystems.recipe.RecipeBean ------------------------- Loader Info ------------------------- ClassLoader name: [demo.sap.com/wdrecipe] Living status: alive Direct parent loaders: [system:Frame] [service:servlet_jsp] [service:ejb] [service:tc~cm~ejb~api] [service:sld] [sap.com/tc~wd~api] [demo.sap.com/earecipe] Resources: D:usrsapCE1J01j2eeclusterappsdemo.sap.comwdrecipeservlet_jspwebdynproresourcesdemo.sap.comwdreciperootWEB-INFlibapp.jar ---------------------------------------------------------------

    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:256)
    at com.sap.engine.boot.loader.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:225)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:333)
    at recipeapp.comp.RecipeComp.wdDoInit(RecipeComp.java:114)
    at recipeapp.comp.wdp.InternalRecipeComp.wdDoInit(InternalRecipeComp.java:132)

former_member182372
Active Contributor
0 Kudos

Do you have reference to EAR DC (earecipe) as sharing reference in your WD project (DC)?

Former Member
0 Kudos

Hi,

wdrecipe has a dependency to earecipe and earecipe has a dependency to ebrecipe defined in component properties.

i'm really stuck with this problem.

thanks,

christian

former_member182372
Active Contributor
0 Kudos

>>wdrecipe has a dependency to earecipe

Is it runtime dependency? Set sharing reference explicitly in WD project (right click, properties, references)

Former Member
0 Kudos

Hi,

i tried to set it explicitly, no change. i even referenced te ebrecipe, it didn't change anything.

i can't be so hard to implement this, has anyone followed the student tutorial and sucesfully deploxed the application?

regards,

christian

former_member182372
Active Contributor
0 Kudos

Christian, there is no miracle. If it is not working - must be the reason.

Most probably the reason is that you don`t have reference from your WD project (DC) to EAR containing EJB classes. OR reference is not correct.

To check depedencies go to visual administrator, open service "ClassLoader viewer" (SID->server->services->classloader in the tree on the left pane), select your WD application or EAR and you will see all dependencies. You can also use for getting full name of EAR component which you can use for sharing reference.

Former Member
0 Kudos

Hi,

i looked up the dependencies on the netweaver AS Telnet console:

wdrecipe:


>app_refs_graph demo.sap.com/wdrecipe
+Application References
|
+->+application:demo.sap.com/wdrecipe (STARTED)
   |
   +->+HARD to library:tc~aii~base~offline~facade (loaded)
   |
   +->+HARD to library:tc~bl~jrfc~api (loaded)
   |
   +->+HARD to library:tc~cmi (loaded)
   |
   +->+HARD to application:demo.sap.com/earecipe (STARTED)
   |
   +->+HARD to library:tc~je~webservices~lib (loaded)
   |
   +->+HARD to library:tc~ddic~runtime~facade (loaded)
   |
   +->+HARD to service:tc~je~security~api (started)
   |
   +->+HARD to application:sap.com/tc~wd~api (STARTED)
   |  |
   |  +->+HARD to service:sld (started)
   |  |
   |  +->+HARD to library:com.sap.util.monitor.jarm (loaded)
   |  |
   |  +->+HARD to service:tc~wd~webdynpro (started)
   |  |
   |  +->+HARD to library:tc~aii~base~offline~facade (loaded)
   |  |
   |  +->+HARD to library:tc~graphics~igs (loaded)
   |  |
   |  +->+HARD to library:tc~je~webservices~lib (loaded)
   |  |
   |  +->+HARD to library:tc~cmi (loaded)
   |  |
   |  +->+HARD to library:tc~bl~jrfc~api (loaded)
   |  |
   |  +->+HARD to library:tc~ddic~runtime~facade (loaded)
   |  |
   |  +->+HARD to library:com.sap.lcr.api.cimclient (loaded)
   |  |
   |  +->+HARD to service:tc~je~security~api (started)
   |
   +->+HARD to library:tc~graphics~igs (loaded)
   |
   +->+HARD to service:sld (started)
   |
   +->+HARD to library:com.sap.lcr.api.cimclient (loaded)
   |
   +->+HARD to service:tc~cm~ejb~api (started)

and earecipe


>app_refs_graph demo.sap.com/earecipe
+Application References
|
+->+application:demo.sap.com/earecipe (STARTED)

i found you article on jarclassfinder (/people/maksim.rashchynski/blog/2006/08/14/the-story-about-how-2-eclipse-plugins-helped-me-to-make-a-lot-of-points-on-sdn-forum), the classfinder says the same thing as the java engine, there is a dependencie on RecipeBean.

i wonder how to tell netweaver to use ebrecipe, i inserted a dependencie in the component properties and in the project properties (referned projects) of the wdrecipe but no change.

is ther any ohter place or trick to tell NW to use ebrecipe?

regards,

christian

former_member182372
Active Contributor
0 Kudos

Hmmm, seems like you have correct reference. Are you sure that earecipe`s EAR contains archives with all reqiured classes? Did you try to restart server BTW?

Former Member
0 Kudos

Hi,

I recreated the ebrecipe and the earecipe, and now i can finally run my application.

And after rearangingthe invalidate statements, i saw a whole roundtrip an a result.

Wohooooo! Thank you for your patience!

Regards,

Christian

Answers (1)

Answers (1)

luciano_leitedasilva
Contributor
0 Kudos

Hi Christian,

You have to do something like that:

1 - Use the visual tool to add the model component inside your application

2 - At the init method in the controller put these code:

RecipeBean recipeBean = //get the sesssion bean instance

wdContext.nodeRecipeBean().bind(recipeBean);

..

Regards,

Luciano

Former Member
0 Kudos

Hi,

i read this in another post in this forum, but my problem is, there is no method

nodeRecipeBean()

in

wdContext

, and i have no clue what to do to get this method.

thanks for your answer,

christian