Avatar billede fredand Forsker
21. marts 2003 - 10:23 Der er 1 kommentar og
1 løsning

Nullpointer in waf-part of the petstore

Hello!

I'm looking at the petstore app from sun and now I need help with it. I guess that it is easier to answer this if you are familier to that example app.

In the class RequestProcessor there is a method called processRequest. That method got these 3 lines of code:

ComponentManager sl = (ComponentManager)request.getSession().getAttribute(WebKeys.COMPONENT_MANAGER);
WebController wcc =  sl.getWebController(request.getSession());
eventResponse  = wcc.handleEvent(ev, request.getSession());

I always got a NullPointer at the second line of these 3 lines. The cuase is that there is no COMPONENT_MANAGER manager in the Session.

So I searched throug the Petsore for:
session.setAttribute(WebKeys.COMPONENT_MANAGER
...and found it in a method called sessionCreated in the class DefaultComponentManager.

So I started to search where sessionCreated is called but can't find it. So the COMPONENT_MANAGER seems to never be put into the session.

But to get this to work it has to be done somewhere.

I'm not so familier with this architecture yet so if anyone could explanie how this should be possible or tell me what I have to do I would be most grateful.

Best regards
Fredrik
Avatar billede soelvpil Nybegynder
22. marts 2003 - 17:00 #1
Does the DefaultComponentManager class implement an interface called HttpSessionListener?

If that is the case you should look inside your web.xml file.

It should contain an entry like

<listener>
  <listener-class>full_classname_of_DefaultComponentManager</listener-class>
</listener>

This will cause the sessionCreated method to be called by the webcontainer, each time a new session is created.
Avatar billede fredand Forsker
15. april 2003 - 14:51 #2
Hello!
Yes your answer helped a lot!
Fredrik
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

IT-JOB

Rambøll Management Consulting

Senior Software Engineer

Forsvarsministeriets Materiel- og Indkøbsstyrelse

Cyberdivisionen søger Entreprise Arkitekt

Everllence

Data Engineer

Riskpoint A/S (Riskpoint Solutions Limited)

Senior Developer

Politiets Efterretningstjeneste

Fullstack softwareudvikler i PET