cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

NullPointerException when calling getDescription()

sdrzewiczewski
7-Bedrock

NullPointerException when calling getDescription()

During an ECN workflow i have an expression robot to set some wf variables. this is my code snippet

wt.change2.WTChangeOrder2 ecn = (wt.change2.WTChangeOrder2)primaryBusinessObject;
number=ecn.getNumber();

try {
description = ecn.getDescription();
} catch (NullPointerException e) {
description = ";
}


if the description of the ECN is not populated it throws an NullPointerException which i thought I was catching.

Any thoughts?

5 REPLIES 5

Check the workflow cache directory to make sure that your changes are
compiled. Better yet, delete the cache and restart the server and see if it
still gives the error.

*codebase/wt/workflow/expr*/


Regards,
Prathap <">http://goo.gl/LuT5>



On Mon, Oct 11, 2010 at 3:58 PM, Stephen Drzewiczewski <
-> wrote:

> During an ECN workflow i have an expression robot to set some wf variables.
> this is my code snippet
>
> wt.change2.WTChangeOrder2 ecn =
> (wt.change2.WTChangeOrder2)primaryBusinessObject;
> number=ecn.getNumber();
>
> try {
> description = ecn.getDescription();
> } catch (NullPointerException e) {
> description = ";
> }
>
>
> if the description of the ECN is not populated it throws an
> NullPointerException which i thought I was catching.
>
> Any thoughts?
>

Ok... a little embarrassed...



I had a test product on my test server that had a copy of the lifecycle
and workflow for that ecn object...



If I had tested my org wf change on any other product it would have
worked as expected. Once I disabled the Product level wf and lifecycle
it obviously started working.



That was moderately annoying!



Thanks Prathap for pointing me to the wf expression directory that
definitely helped and made things click, a little bit.



sd


Hi Steve

With your try and catch in place, I don't think ecn.getDescription() will
throw null pointer expression. If ecn is null, then it will throw null
pointer expression.

From few of my clients, I understood the we need to initialize the workflow
variables when the workflows are upgraded from R8 to R91. I am unsure
whether the behavior you notice is relevant to initializing wf variables.
Just a food for thought.



Thank you and have a great time.

Best Regards

Swamy Senthil

Principal Solutions Architect

973 216 0456(M); 973 324 2729(W); 866 908 6561(F)

Work Email: swamy.senthil@swasen.com

LinkedIn Profile:

Instead of a try/catch do this:

description=";
If(ecn != null) {
description = ecn.getDescription();
}

-Thomas R. Busch
Sr. Software Developer
Stryker Instruments
(269) 323-7700 x4014
tom.busch@stryker.com<">mailto:tom.busch@stryker.com>

Thanks for all the replies. The ECN is not what will be null, as it's the PBO for the workflow. It's the description of the ECN which is not required may be null.

Once I disabled the product lifecycle/workflow and the org lifecycle/wf was getting executed, everything behaved as expected.

Announcements

Top Tags