私は postConstruct メソッドを持っています:
@EJB
private VisitServiceLocal visitService;
@PostConstruct
void init() {
eventModel = new DefaultScheduleModel();
visits = getDoctorVisits();
}
方法:
public List<Visit> getDoctorVisits() {
doctorId = (Integer) session.getAttribute("userId");
return visitService.findMyVisits(doctorId);
}
訪問サービス:
@Override
public List<Visit> findMyVisits(Integer myId) {
return visitDao.findMyVisits(myId);
}
VisitDao:
@Override
public List<Visit> findMyVisits(Integer myId) {
currentDate = new Date();
try {
Query q = em.createQuery("SELECT v FROM Visit v WHERE v.doctorId.id = :myId and v.visitStart > :currentDate");
q.setParameter("myId", myId);
q.setParameter("currentDate", currentDate);
List<Visit> visits = q.getResultList();
return visits;
} catch (Exception e) {
System.out.println("Błąd: " + e.getMessage());
return null;
}
}
アプリケーションを実行するとエラーが発生します:
com.sun.faces.mgbean.ManagedBeanCreationException: com.sun.faces.mgbean.BeanBuilder. build(BeanBuilder.java:105) com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:409) com.sun.faces.mgbean.BeanManager.create(BeanManager.java:269) com.sun .faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:244) com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:116) com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java) :176) com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203) で com.sun.el.parser.AstIdentifier で。getValue(AstIdentifier.java:103) com.sun.el.parser.AstValue.getValue(AstValue.java:179) com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224) com.sun.faces .facelets.el.TagValueExpression.getValue(TagValueExpression.java:109) で javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194) で javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182) でjavax.faces.component.UIOutput.getValue(UIOutput.java:169) で org.primefaces.component.outputlabel.OutputLabelRenderer.encodeEnd(OutputLabelRenderer.java:36) で javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java: 875) com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312) で、com.sun.faces.renderkit.html_basic.GridRenderer で。renderRow(GridRenderer.java:185) の com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129) の javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) の org.primefaces .renderkit.CoreRenderer.renderChild(CoreRenderer.java:59) で org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:47) で org.primefaces.component.dialog.DialogRenderer.encodeContent(DialogRenderer.java:172) でjavax.faces.component.UIComponentBase.encodeEnd(UIComponentBase. java:875) で javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764) で javax.faces.render.Renderer で。javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) の encodeChildren(Renderer.java:168) javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757) の javax.faces.component.UIComponent に.encodeAll(UIComponent.java:1760) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) at com. com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) の sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) com.sun.faces.lifecycle.Phase.doPhase( Phase.java:101) の com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) の javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550) で org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343) で org.apache.catalina.core.ApplicationFilterChain .doFilter(ApplicationFilterChain.java:217) at pl.ePrzychodnia.filter.FilterLogin.doFilter(FilterLogin.java:49) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256) at org.apache. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java: 175) org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655) で org.org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter. java:331) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231) で com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317) で.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195) com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860) com.sun.grizzly.http.ProcessorTask .doProcess(ProcessorTask.java:757) at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056) at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229) com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137) com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104) com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java) :90) com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79) で com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54) で com.sun.grizzly.SelectionKeyContextTask.call( SelectionKeyContextTask.java:59) com.sun.grizzly.ContextTask.run(ContextTask.java:71) com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532) com.sun.grizzly .util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513) at java.lang.Thread.run(Thread.java:722) 原因: com.sun.faces.spi。InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: org.glassfish.faces.integration.GlassFishInjectionProvider.invokePostConstruct(GlassFishInjectionProvider. java:231) com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:223) で ... 67 以上ライフサイクル メソッド void pl.ePrzychodnia.mb.VisitSecretaryMB.init() org.glassfish.faces.integration.GlassFishInjectionProvider.invokeLifecycleMethod(GlassFishInjectionProvider.java:393) org.glassfish.faces.integration.GlassFishInjectionProvider.invokePostConstruct(GlassFishInjectionProvider.java: 306) 組織で。glassfish.faces.integration.GlassFishInjectionProvider.invokePostConstruct(GlassFishInjectionProvider.java:229) ... 68 以上 原因: java.security.PrivilegedActionException: java.lang.reflect.InvocationTargetException at java.security.AccessController.doPrivileged(Native Method) at org.glassfish.faces.integration.GlassFishInjectionProvider.invokeLifecycleMethod(GlassFishInjectionProvider.java:376) ... 70 以上 原因: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect. NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) で java.lang.reflect.Method.invoke(Method.java:601) で org.glassfish.faces.integration .GlassFishInjectionProvider$2.run(GlassFishInjectionProvider.java:382) ... 72 以上 原因: com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5215) での javax.ejb.EJBException。 container.BaseContainer.completeNewTx(BaseContainer.java:5113) com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4901) com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2045) com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1994) com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:222) com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke (EJBLocalObjectInvocationHandlerDelegate.java:89) com.sun.proxy.$Proxy170.findMyVisits(未知のソース) at pl.ePrzychodnia.mb.VisitSecretaryMB.getDoctorVisits(VisitSecretaryMB.java:322) at pl.ePrzychodnia.mb.VisitSecretaryMB.init(VisitSecretaryMB.java:61) ... 77 以上の原因: java.lang.NullPointerException at pl.ePrzychodnia.dao .serviceClass.VisitService.findMyVisits(VisitService.java:89)、sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド)、sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)、sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl) .java:43) で java.lang.reflect.Method.invoke(Method.java:601) で org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052) で org.glassfish.ejb. com.sun.ejb.containers.BaseContainer の security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)。com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619) の invokeBeanMethod(BaseContainer.java:5388) com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:800) の com.sun .ejb.EjbInvocation.proceed(EjbInvocation.java:571) com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162) com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy) .java:144) で sun.reflect.GeneratedMethodAccessor116.invoke(不明なソース) で sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) で java.lang.reflect.Method.invoke(Method.java:601) でcom.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:861) at com.sun.ejb.com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:370) では、com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer. java:5360) com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5348) で com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) ... 81 詳細container.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) ... 81 詳細container.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:214) ... 81 詳細
なぜこのエラーが発生するのですか。
しかし、JSF メソッド Service を Dao に変更すると、すべて正常に動作します。
方法:
public List<Visit> getDoctorVisits() {
doctorId = (Integer) session.getAttribute("userId");
return visitDao.findMyVisits(doctorId);
}
追加サービス層がこのエラーを生成するのはなぜですか? サービス層では、dao メソッドのみを発生させます。