File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Target Unreachable, 'null' returned null Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Target Unreachable, Watch "Target Unreachable, New topic
Author

Target Unreachable, 'null' returned null

Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Hello. I am trying to learn JSF, teaching myself of course, I have a couple of books and I've been working hard at this. Not sure how else to do it...:-)

My issue is when I attempt to create (add) a record via my web app. I get the error "Target Unreachable, 'null' returned null".

Stack trace (I can't find anything useful here)



I suspect it' some issue with my SelectOneMenu component, but just a guess.

JSF page:


Managed Bean:


EJB:


The Paprd entity has other fields that are set/calculated internally, other than the ones input by the user. That part is a little tricky too. But I'm really trying to find out why I'm getting a null target returned.

Thank yoU!
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

I suspect this line where you have used "cores" but I never find neither it's a instance variable nor function. Correct this and let's try again also check for other code lines too. Best way of finding the problem is insert lines one by one then we could find the exact line which causes the problem when you don't find useful exception/error message.


No pain, No gain.
OCJP 1.6
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5



Does this call return anything? I think your drop down list is null. It is better practice to return an empty list in such a scenario.
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Thank you both for replying.

@Kumaravadivel: As I was building the page, after the dot in <f:selectItems value="#{productupc.cores}"/>, cores [SelectItem] was in the list, so this told me that it was accessible from the getCores method in the managed bean (ProductUPCMBean). I'm still fuzzy on this part, and on SelectItem/SelectOneMenu. I do think there is some issue here, but I don't know how to find it. Suggestions?

@James: I can't get a return other than the error I posted. I tried logging some values in the managed bean code just before the .create method is called. Still get the error. How can I code around the list to check for null before returning? I can't seem to make it to the managed bean from the jsf page.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5



I have modified your method above. Which of the 3 System.out.println statements is output?
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

This one:

INFO: *** getCores() returned list of size 10000 ***

There are in fact 10000 records in the table that getCores is retrieving from.

Also, the drop-down does pull back all of the values in the list, and I can choose a value from the list. The error occurs when I click the 'Save' button, which triggers the action of create.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5



When you click the save button, the value selected in the drop-down list will be set on coreNum by calling productupc.getDetails().setCoreNum()

From your code, it looks like getDetails() is returning null as the instance member variable paprd is never initialised. Can you look at this area to check if this is indeed the problem?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

A better way of doing it:



Variant for populating selectItems list:


Actually, an EJB really shouldn't be returning null if there are no associated objects, it should be returning an empty list, so in theory, the "if (coreunum == null)" part is redundant.

Debugging EL NullPointerException errors is a real pain in the fundament. I do it by trapping the exception with my debugger at the time it is thrown and walking up the stack until I find out which expression was being evaluated, but it isn't a trivial task.


Customer surveys are for companies who didn't pay proper attention to begin with.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

Yet one more, to save creating the empty list:
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Tim & James:

Thank you for the direction. I will work on this using your advice, and post my results. Thanks again.
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Ok back from Christmas/New Year's break & vacation, and made some changes.

As I'm completing the form to Create, I see the following in the server log:

WARNING: Unable to find component with ID coreNum in view.
INFO: *** getCores() returned list of xize 10000 ***

Then I Save.

Server log:
INFO: *** getCores() returned list of xize 10000 ***
INFO: title from NewUPC.jsp My test title
INFO: core_num from NewUPC.jsp null
INFO: prodtype from NewUPC.jsp2

followed by:

WARNING: A system exception occurred during an invocation on EJB ProductUPCSessionBean method public org.productgen.entity.Paprd org.productgen.ejb.ProductUPCSessionBean.create(org.productgen.entity.Paprd)
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy232.create(Unknown Source)
at org.productgen.ejb.__EJB31_Generated__ProductUPCSessionBean__Intf____Bean__.create(Unknown Source)
at org.productgen.web.ProductUPCMBean.create(ProductUPCMBean.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.IllegalStateException: Query argument id not found in the list of parameters provided during query execution.
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.processParameters(EJBQueryImpl.java:829)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:406)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:734)
at org.productgen.ejb.ProductUPCSessionBean.getID(ProductUPCSessionBean.java:90)
at org.productgen.ejb.ProductUPCSessionBean.getNextID(ProductUPCSessionBean.java:95)
at org.productgen.ejb.ProductUPCSessionBean.create(ProductUPCSessionBean.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
... 44 more

WARNING: #{productupc.create}: javax.ejb.EJBException
javax.faces.FacesException: #{productupc.create}: javax.ejb.EJBException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.faces.el.EvaluationException: javax.ejb.EJBException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 32 more
Caused by: javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5193)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5091)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4879)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2039)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1990)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:88)
at $Proxy232.create(Unknown Source)
at org.productgen.ejb.__EJB31_Generated__ProductUPCSessionBean__Intf____Bean__.create(Unknown Source)
at org.productgen.web.ProductUPCMBean.create(ProductUPCMBean.java:88)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 33 more
Caused by: java.lang.IllegalStateException: Query argument id not found in the list of parameters provided during query execution.
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.processParameters(EJBQueryImpl.java:829)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:406)
at org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:734)
at org.productgen.ejb.ProductUPCSessionBean.getID(ProductUPCSessionBean.java:90)
at org.productgen.ejb.ProductUPCSessionBean.getNextID(ProductUPCSessionBean.java:95)
at org.productgen.ejb.ProductUPCSessionBean.create(ProductUPCSessionBean.java:140)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5366)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5338)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5326)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214)
... 44 more

I see this line Caused by: java.lang.IllegalStateException: Query argument id not found in the list of parameters provided during query execution. at org.eclipse.persistence.internal.jpa.EJBQueryImpl.processParameters(EJBQueryImpl.java:829)

and am researching it...



Also Tim, you posted this

Actually, an EJB really shouldn't be returning null if there are no associated objects


I have read several books but they don't seem to have this kind of basic information...is there a book that you recommend that can help me get a better understanding of some of these kinds of things?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16020
    
  20

I think you've got one of those annoying lazy error messages that can read ambiguously. It should properly have read:

Caused by: java.lang.IllegalStateException: Query argument "id" not found in the list of parameters provided during query execution.


That is, a query was built but the argument named "id" wasn't set before the query was made. It's POSSIBLE that they actually meant that a query argument identifier was not found, but usually, that's not what I see for messages in what one former co-worker named "Ogg the Caveman" format.

We're not using punched cards any more and we have megabytes of RAM. I wish people would get with the program and use intelligible English.

A lot of what I know about EJB3 and JPA has come through experience and reverse-engineering the intelligence of what I learned the hard way. However, I found this little morsel in the Persistence 2.0 Final spec at the very top of Page 42:


If there are no associated entities for a multi-valued relationship of an entity fetched from the database,
the persistence provider is responsible for returning an empty collection as the value of the relationship.


Read carefully, that means that a collection should return empty rather than null. There is no enforcement on constructed entity objects, but it is good practice to initialize all collection objects to empty collections when constructing. Otherwise, you'd have to add extra logic to check for both kinds of "no-data" conditions. Plus someday, JPA might get more rigorous about such things.
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Good info - makes perfect sense! I have since made some changes and narrowed it down to two things:

1) The core_num value from the dropdown is null. I am checking for null and setting it to a fixed value if it is, just for the test.
2) When persisting the paprd entity em.merge(paprd);, all of the values for the db are null. I output the values from the EJB to show that I have values, mainly the primary key "id", though the log says the id is null. I will go back and read my entity books again...
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

Update, I have figured most of it out. No error on Save now. I am missing a couple of values in the database, but I'm working on it. Thanks for the direction and suggestions. I'm teaching myself (go figure) so you can imagine the uphill struggle with Java!
Phillip Ankerson
Greenhorn

Joined: Aug 10, 2011
Posts: 27

I'm happy to report that all issues have been resolved. Very happy! And proud of myself for digging up answers to a lot of these little issues. The biggie was the dropdown for corenum - I won't say I still understand every part of it completely, but mostly :=). I'll get there. Thanks again guys for helping me and being patient! I don't think I could have resolved that part very quickly on my own.

Cheers!
Phillip
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Target Unreachable, 'null' returned null