0

有一个问题从 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 的限制。

请问我该怎么做?

4

1 回答 1

5

默认情况下,EJB 和 CDI 在 Tomcat 中不起作用,因为 Tomcat 只是一个 Servlet 容器。如果您想使用它们,您必须将您的应用程序部署在真正的 Java EE 应用程序服务器上,例如JBoss 7GlassFish 3TomEE(请注意,这些都是免费的,还有一些其他的,例如 IBM WebSphere 和 Oracle WebLogic,它们是 Java EE 6 应用程序服务器,但是您必须付费才能获得/使用它们)。如果你继续在 Tomcat 中部署它,你将永远不会成功。

如果您仍然想只使用 Tomcat,那么摆脱所有这些@EJB和其他 Java EE 注释(例如 CDI 注释,如@Named)。

顺便说一句,请遵循有关 JSF 或 CDI 的良好理智教程。您不能同时将 bean 装饰为@Named@ManagedBean

于 2013-05-21T22:09:56.327 回答