有一个问题,从6个小时开始处理,但没有解决它。
使用JSF / Tomcat 7 / Maven / Java 7开发动态Web项目
每次我在服务器上运行项目时都会得到这个:
javax.naming.NameNotFoundException: Name [....ProjectManagement/service] is not bound in this Context. Unable to find [de.hhn.team3.artzpraxismanagement.ProjectManagement].
at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
at org.apache.catalina.core.DefaultInstanceManager.lookupFieldResource(DefaultInstanceManager.java:580)
at org.apache.catalina.core.DefaultInstanceManager.processAnnotations(DefaultInstanceManager.java:470)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:157)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.myfaces.config.annotation.Tomcat7AnnotationLifecycleProvider.postConstruct(Tomcat7AnnotationLifecycleProvider.java:90)
at org.apache.myfaces.config.ManagedBeanBuilder.buildManagedBean(ManagedBeanBuilder.java:213)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.createManagedBean(ManagedBeanResolver.java:333)
at org.apache.myfaces.el.unified.resolver.ManagedBeanResolver.getValue(ManagedBeanResolver.java:296)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:169)
at org.apache.myfaces.el.VariableResolverImpl.resolveVariable(VariableResolverImpl.java:65)
at org.apache.myfaces.el.convert.VariableResolverToELResolver.getValue(VariableResolverToELResolver.java:123)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:67)
at org.apache.myfaces.el.unified.resolver.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:169)
at org.apache.el.parser.AstIdentifier.getValue(AstIdentifier.java:72)
at org.apache.el.parser.AstValue.getValue(AstValue.java:161)
at org.apache.el.parser.AstEqual.getValue(AstEqual.java:38)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:185)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:96)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:263)
at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1089)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:733)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:758)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:758)
at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1900)
at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:285)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:115)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:947)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1009)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
这是我的课程项目管理
package ...artzpraxismanagement;
@Named
@ManagedBean
@SessionScoped
public class ProjectManagement implements Serializable {
private static final long serialVersionUID = 1L;
@EJB private Services service;
和我的服务类
@ManagedBean
@SessionScoped @Local public class Services implements Serializable {...}
我尝试过不同的解决方案,例如在WebContent / lib中删除Tomcat Jars,但它没有帮助。
我想我的ProjectManagement
类不在context.xml中。
我该怎么办呢?
答案 0 :(得分:5)
默认情况下,EJB和CDI在Tomcat中不起作用,因为Tomcat只是一个Servlet容器。如果要使用它们,则必须在真实的Java EE应用程序服务器上部署应用程序,如JBoss 7,GlassFish 3或TomEE(请注意,这些是免费的,还有其他类似IBM WebSphere和Oracle WebLogic是Java EE 6应用程序服务器,但您必须付费才能获取/使用它们。如果你继续在Tomcat中部署它,你就永远不会成功。
如果您仍然只想使用Tomcat,那么请删除所有@EJB
和其他Java EE注释(例如@Named
等CDI注释。
顺便说一句,请遵循JSF或CDI上的理智教程。你不能同时将@Named
和@ManagedBean
装饰成豆。