加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

警告:JSF1074:已经注册了名为“bean”的托管bean

发布时间:2020-12-14 05:50:42 所属栏目:Java 来源:网络整理
导读:我正在使用mojarra JSF 2.2. 我们定义的bean是基于anotation的例如. @ManagedBean(name = "codeBean")@ViewScopedpublic class CodeRuleBean implements Serializable 我使用tomcat 7.0.53来部署相同的.但是,我收到了警告说 WARNING: JSF1074: Managed bean
我正在使用mojarra JSF 2.2.

我们定义的bean是基于anotation的例如.

@ManagedBean(name = "codeBean")
@ViewScoped
public class CodeRuleBean implements Serializable

我使用tomcat 7.0.53来部署相同的.但是,我收到了警告说

WARNING: JSF1074: Managed bean named ‘codeBean’ has already been registered. Replacing existing managed bean class type com.myclass.rule.ui.CodeRuleBean with com.myclass.rule.ui.CodeRuleBean.

在faces-config.xml中没有.我只使用faces-config.xml来定义导航规则.

<?xml version="1.0" encoding="UTF-8"?>

<faces-config version="2.2" xmlns="http://xmlns.jcp.org/xml/ns/javaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
              http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd">


    <application>
        <navigation-handler>com.configurator.application.navigator.MyNavigator</navigation-handler>
    </application>

    <navigation-rule>
        <navigation-case>
            <from-outcome>codeRulePage</from-outcome>
            <to-view-id>/pages/rule/shortCodeMain.xhtml
            </to-view-id>
            <redirect />
            <to-flow-document-id />
        </navigation-case>
    </navigation-rule>

    <navigation-rule>
        <from-view-id>/pages/rule/shortCodeMain.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>successPage</from-outcome>
            <to-view-id>/pages/rule/successCodeRule.xhtml
            </to-view-id>
        </navigation-case>
    </navigation-rule>
</<faces-config>

这是web.xml,它不包含任何Web侦听器.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>MyWeb</display-name>

    <context-param>
        <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>
    <filter-mapping>
        <filter-name>cachePreventionFilter</filter-name>
        <url-pattern>*.xhtml</url-pattern>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>*.jsp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>
    <servlet>
        <servlet-name>FacesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>FacesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
</web-app>

这是怎么造成的,我该如何解决?

解决方法

我认为你已经为jsf空间注册了多个监听器.看看这个.如果你的web.xml中有com.sun.faces.config.ConfigureListener,请将其删除.

因为com.sun.faces.config.FacesInitializer在onStartup方法上注册了com.sun.faces.config.ConfigureListener.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读