Yeah, autoboxing is evil - it's just a compiler convenience thing. If you have:
Boolean closed = null; boolean isClosed() { return closed; } The compiler transforms it to boolean isClosed() { return closed.booleanValue(); } which of course throws an NPE. Steve. -- Steve Eynon On 3 September 2011 16:04, Gunnar Eketrapp <gunnar.eketr...@gmail.com> wrote: > Tapestry may not go wrong! > > It must has to do with autoboxing in method isClosed() in Ledger. > > I was fooled by the debugger and that ledger was shown as null but when > adding log statements I can see that it isn't. > > So I have to read a little bit about aoutoboxing but for sure it was NOT a > T5 problem! > > The call ledger.isClosed() raises a nul pointer but ledgers is not null! > > Sorry for disturbing all of you. > > > 2011/9/3 Gunnar Eketrapp <gunnar.eketr...@gmail.com> > >> BUT it is also a T5 property so that could be T5 related. >> >> The instance seems to created but the T5 property ledger is null after the >> assignment. >> >> >> 2011/9/3 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >> >>> Hum .. sorry .. too early in the morning for me .. Ledger is a hibernate >>> entity class and T5 should not be involved. >>> >>> I'll be right back ... >>> >>> >>> 2011/9/3 Gunnar Eketrapp <gunnar.eketr...@gmail.com> >>> >>>> Hi ! >>>> >>>> I have been happily hacking web sites with T5 for a year and half now and >>>> is more then pleased! >>>> Kudos to all of you for this excellent web framework that makes coding >>>> fun again. >>>> >>>> And I have never ever encountered any defect in the T5 code. >>>> >>>> Now to my problem. >>>> >>>> I just got an error in an onActivate method that looked like it could not >>>> happen. >>>> >>>> When steeping through it in my debugger I really get puzzled. >>>> >>>> A variable assigned inside a block is null after leaving the block. >>>> >>>> It must have something to do with the "plastering" of my code. Or !? >>>> >>>> The error I get is .. >>>> >>>> Caused by: java.lang.NullPointerException >>>> at >>>> utskicket.pages.economy.EditYear._$advised$onActivate_13(EditYear.java:91) >>>> >>>> ... and in the debugger I can see that ledger is null at line 91. >>>> >>>> In the code below I have commented what happens in the debugger. >>>> >>>> Can anyone understand what could cause this error ... >>>> I have stepped through the generated code without seeing anything >>>> strange. It all looks great but when returning ledger is null. >>>> >>>> Do I break any rule / convention with my code !? >>>> >>>> Many many thanks in advance, >>>> Gunnar Eketrapp, Stockholm, Sweden >>>> >>>> Environment: >>>> *jdk 1.6.0_22* >>>> *t5.2.6* >>>> *windows 7 proffesional, 32-bit* >>>> >>>> >>>> @Property >>>> private Ledger ledger; >>>> >>>> @Property >>>> private String notice; >>>> >>>> // >>>> ------------------------------------------------------------------------------ >>>> // -- Tapestry event methods - Tapestry event methods - Tapestry >>>> event methods -- >>>> // >>>> ------------------------------------------------------------------------------ >>>> >>>> @Log >>>> Object onActivate(long groupId, long ledgerId) { >>>> >>>> group = groupDAO.findById(groupId); >>>> if (group == null) >>>> return Index.class; >>>> >>>> if (ledgerId != 0) { >>>> ledger = ledgerDAO.findById(ledgerId); >>>> if (ledger == null) >>>> return Index.class; >>>> if (!same(group.getId(), ledger.getGroup().getId())) >>>> return Index.class; >>>> >>>> hasPrevious = (null != ledgerDAO.findPrevious(ledger)); >>>> hasNext = (null != ledgerDAO.findNext(ledger)); >>>> transactionCount = transactionDAO.countTransactions(ledger); >>>> >>>> } else { >>>> ledger = new Ledger(); * // 1: This one returns null !!!* >>>> Ledger lastLedger = ledgerDAO.findLast(group); >>>> if (null == lastLedger) { >>>> UTDate today = new UTDate(); >>>> ledger.setStartDate(new UTDate(today.getYear(), 1, 1)); >>>> *// 2: This line ends the block!* >>>> ledger.setEndDate(new UTDate(today.getYear(), 12, 31)); >>>> } else { >>>> >>>> ledger.setStartDate(lastLedger.getStartDate().warpYears(1)); >>>> ledger.setEndDate(lastLedger.getEndDate().warpYears(1)); >>>> } >>>> } >>>> >>>> * if (ledger.getClosed()) // 3: And here we crash!* >>>> notice = "Året är stängt och kan inte ändras"; >>>> else { >>>> if (!mayEdit()) >>>> notice = "Endast det senaste året kan ändras."; >>>> else if (!mayEditStarts()) >>>> notice = "Startdagen kan inte ändras då det finns >>>> tidigare år."; >>>> } >>>> >>>> return null; >>>> } >>>> >>>> >>> >>> >>> -- >>> [Hem: 08-715 59 57, Mobil: 070-991 86 42] >>> Allévägen 2A, 132 42 Saltsjö-Boo >>> >> >> >> >> -- >> [Hem: 08-715 59 57, Mobil: 070-991 86 42] >> Allévägen 2A, 132 42 Saltsjö-Boo >> > > > > -- > [Hem: 08-715 59 57, Mobil: 070-991 86 42] > Allévägen 2A, 132 42 Saltsjö-Boo > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org