Results 1 to 4 of 4
  1. #1
    gmjord is offline Member
    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0

    Default Need help with EJBException

    Hi,

    I have a JSF project that worked on one laptop but that laptop crashed and now I am migrating it to my new laptop and I finally got it working to where the application brings up the browser for a user to log in. However, when the user logs in they get javax.ejb.EJBException.

    I have a controller program called WaketechAppController which controls page navigation and also has an injected reference to an EJB called WaketechApp_EJB. The EJB gets the data from the data base.

    All of this worked fine on my other machine. Could I have some sort of configuration problem??

    Here is the stack trace... I highlighted my packages in red

    javax.faces.el.EvaluationException: javax.ejb.EJBException
    at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:101)
    at com.sun.faces.application.ActionListenerImpl.proce ssAction(ActionListenerImpl.java:102)
    at javax.faces.component.UICommand.broadcast(UIComman d.java:315)
    at javax.faces.component.UIViewRoot.broadcastEvents(U IViewRoot.java:790)
    at javax.faces.component.UIViewRoot.processApplicatio n(UIViewRoot.java:1282)
    at com.sun.faces.lifecycle.InvokeApplicationPhase.exe cute(InvokeApplicationPhase.java:81)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:1 01)
    at com.sun.faces.lifecycle.LifecycleImpl.execute(Life cycleImpl.java:198)
    at javax.faces.webapp.FacesServlet.service(FacesServl et.java:646)
    at org.apache.catalina.core.StandardWrapper.service(S tandardWrapper.java:1682)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:318)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke (StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipel ine.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doServ ice(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMappe r.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runS ervice(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHa ndle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter .handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver $9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterCha in.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterCha in.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterCha in.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterCha in.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(Pr ocessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTranspor t.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrateg y.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStr ategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStr ategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStr ategy$WorkerThreadRunnable.run(WorkerThreadIOStrat egy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPoo l$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPoo l$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:724)
    Caused by: javax.ejb.EJBException
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.processSystemException(EJBContainerTransaction Manager.java:748)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.completeNewTx(EJBContainerTransactionManager.j ava:698)
    at com.sun.ejb.containers.EJBContainerTransactionMana ger.postInvokeTx(EJBContainerTransactionManager.ja va:503)
    at com.sun.ejb.containers.BaseContainer.postInvokeTx( BaseContainer.java:4475)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:2009)
    at com.sun.ejb.containers.BaseContainer.postInvoke(Ba seContainer.java:1979)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 20)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dlerDelegate.invoke(EJBLocalObjectInvocationHandle rDelegate.java:88)
    at com.sun.proxy.$Proxy326.getStudent(Unknown Source)
    at edu.waketech.gmjordan.__EJB31_Generated__WaketechA pp_EJB__Intf____Bean__.getStudent(Unknown Source)
    at edu.waketech.gmjordan.WaketechAppController.verify Student(WaketechAppController.java:198)
    at edu.waketech.gmjordan.WaketechAppController$Proxy$ _$$_WeldClientProxy.verifyStudent(Unknown Source)

    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at javax.el.ELUtil.invokeMethod(ELUtil.java:326)
    at javax.el.BeanELResolver.invoke(BeanELResolver.java :536)
    at javax.el.CompositeELResolver.invoke(CompositeELRes olver.java:256)
    at com.sun.el.parser.AstValue.invoke(AstValue.java:26 9)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpre ssionImpl.java:304)
    at org.jboss.weld.util.el.ForwardingMethodExpression. invoke(ForwardingMethodExpression.java:40)
    at org.jboss.weld.el.WeldMethodExpression.invoke(Weld MethodExpression.java:50)
    at com.sun.faces.facelets.el.TagMethodExpression.invo ke(TagMethodExpression.java:105)
    at javax.faces.component.MethodBindingMethodExpressio nAdapter.invoke(MethodBindingMethodExpressionAdapt er.java:87)
    ... 35 more
    Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.
    at org.eclipse.persistence.internal.jpa.QueryImpl.thr owNoResultException(QueryImpl.java:971)
    at org.eclipse.persistence.internal.jpa.QueryImpl.get SingleResult(QueryImpl.java:521)
    at org.eclipse.persistence.internal.jpa.EJBQueryImpl. getSingleResult(EJBQueryImpl.java:400)
    at edu.waketech.gmjordan.WaketechApp_EJB.getStudent(W aketechApp_EJB.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.glassfish.ejb.security.application.EJBSecurity Manager.runMethod(EJBSecurityManager.java:1081)
    at org.glassfish.ejb.security.application.EJBSecurity Manager.invoke(EJBSecurityManager.java:1153)
    at com.sun.ejb.containers.BaseContainer.invokeBeanMet hod(BaseContainer.java:4695)
    at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvo cation.java:630)
    at com.sun.ejb.containers.interceptors.AroundInvokeCh ainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.ja va:582)
    at org.jboss.weld.ejb.AbstractEJBRequestScopeActivati onInterceptor.aroundInvoke(AbstractEJBRequestScope ActivationInterceptor.java:46)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeIn terceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeCh ainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.ja va:582)
    at com.sun.ejb.containers.interceptors.SystemIntercep torProxy.doCall(SystemInterceptorProxy.java:163)
    at com.sun.ejb.containers.interceptors.SystemIntercep torProxy.aroundInvoke(SystemInterceptorProxy.java: 140)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.sun.ejb.containers.interceptors.AroundInvokeIn terceptor.intercept(InterceptorManager.java:883)
    at com.sun.ejb.containers.interceptors.AroundInvokeCh ainImpl.invokeNext(InterceptorManager.java:822)
    at com.sun.ejb.containers.interceptors.InterceptorMan ager.intercept(InterceptorManager.java:369)
    at com.sun.ejb.containers.BaseContainer.__intercept(B aseContainer.java:4667)
    at com.sun.ejb.containers.BaseContainer.intercept(Bas eContainer.java:4655)
    at com.sun.ejb.containers.EJBLocalObjectInvocationHan dler.invoke(EJBLocalObjectInvocationHandler.java:2 12)
    ... 53 more

    *************************************************
    Here is the part of WaketechAppController that calls the EJB... the verifyStudent() method is from the stacktrace

    ...
    @EJB
    private WaketechApp_EJB wtApp_EJB;
    ...

    public String verifyStudent() {
    System.out.println("id: " + personID);

    student = wtApp_EJB.getStudent(personID);
    System.out.println("Student: " + student);
    System.out.println("Student name: " + student.getName());
    System.out.println("Student personid: " + student.getPersonID());
    System.out.println("Student id: " + student.getId());
    //return student;
    if (student != null) {
    page = "welcome";
    return page;
    } else {
    page = "invalidLogin";
    return page;
    }
    }
    ...
    ****************************************

    and here is WaketechApp_EJB... the method from the stacktrace is in red


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package edu.waketech.gmjordan;

    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.ejb.LocalBean;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;

    /**
    *
    * @author Jordan
    */
    @Stateless
    //@LocalBean
    public class WaketechApp_EJB {

    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
    @PersistenceContext(unitName = "WaketechAppFrontPU")
    private EntityManager em;


    public Student getStudent(Long idIn) {

    //createEntityManager();
    System.out.println("In getStudent and id:" + idIn);
    String jpqlQuery = "SELECT s from Student s WHERE s.personID = :id";
    Query query = (Query) em.createQuery(jpqlQuery);
    query.setParameter("id", idIn);
    Object student = query.getSingleResult();
    return (Student) student;
    }

    // We assume we start the whole process by getting a student object. We pass that student
    // object to getSections here to get the sections associated with that student.
    public List<Section> getSections(Student student) {
    List<Section> section = null;
    section = student.getAllSections();
    return section;
    }

    // Get the course for a given section
    public Course getCourse(Section section) {
    Course course = null;
    course = section.getCourse();
    return course;

    }

    // Get the textbook for a certain course
    public Textbook getTextbook(Course c) {
    Textbook book = c.getTextbook();
    return book;
    }

    // Get the instructor for a certain section
    public Instructor getInstructor(Section s) {
    Instructor inst = new Instructor();
    inst = s.getInstructor();
    return inst;
    }

    // Get the time and location for a certain instructor
    public List<TimeLocation> getInstructorTimeLocation(Instructor inst) {
    List<TimeLocation> timeLoc = new ArrayList<TimeLocation>();
    timeLoc = inst.getTimeLocation();
    return timeLoc;
    }

    // Get the time and location for each section
    public List<TimeLocation> getSectionTimeLocation(Section s) {
    List<TimeLocation> timeLoc = new ArrayList<TimeLocation>();
    timeLoc = s.getTimeLocation();
    return timeLoc;
    }

    }

    Thanks in advance for any help!!

  2. #2
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,275
    Rep Power
    6

    Default Re: Need help with EJBException

    Java exception handling 101: when you get a stack trace, look at the root cause first. Which is in this case:

    Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.

    So the JPA getSingleResult() method is telling you that it got no results while there MUST be one, since you're using getSingleResult(). Its likely a data problem, not a programming problem. Unless it is allowed that there is no result, in which case you should in fact catch the NoResultException and handle it.

    Easy huh? All you had to do was actually look at the stacktrace. Its long and looks intimidating, but its actually your best friend because it is telling you where the problem happened and what is wrong.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  3. #3
    gmjord is offline Member
    Join Date
    Aug 2013
    Posts
    4
    Rep Power
    0

    Default Re: Need help with EJBException

    Quote Originally Posted by gimbal2 View Post
    Java exception handling 101: when you get a stack trace, look at the root cause first. Which is in this case:

    Caused by: javax.persistence.NoResultException: getSingleResult() did not retrieve any entities.

    So the JPA getSingleResult() method is telling you that it got no results while there MUST be one, since you're using getSingleResult(). Its likely a data problem, not a programming problem. Unless it is allowed that there is no result, in which case you should in fact catch the NoResultException and handle it.

    Easy huh? All you had to do was actually look at the stacktrace. Its long and looks intimidating, but its actually your best friend because it is telling you where the problem happened and what is wrong.
    Thank you for your help. There is data in the database. everything was working on my old laptop where this project originally was. That laptop crashed so now i am migrating my project to my new laptop. I have one project that builds and populates the database using JPA. That project runs fine. I am really confused as to why this EJBException is occuring. I thought maybe that when I created the connection pool somehow something got screwed up but it looks like it is pointing to the same database that the JPA project populated.

  4. #4
    gimbal2 is online now Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,275
    Rep Power
    6

    Default Re: Need help with EJBException

    "There is data in the database". According to your exception, not the right data. Or your code turned into something it shouldn't be on its own.

    Either way the exception is not weird, its not happening mysteriously, its not the result of caching, pooling or programs going haywire - its something easily explainable. All you have to do is believe it is something easy and go have another look. Why are there no results when there should be one? Go answer it by doing some debugging.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 1
    Last Post: 03-27-2013, 02:27 PM
  2. Replies: 4
    Last Post: 04-01-2011, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •