问题
i am using PrettyFaces 3.3.0 with Spring Security 3 i have two beans UserBean which is mapped to serve to pages (users,add) and LoginBean to serve the login page
my mappings is as follows:
1- UserBean:
@Component("user")
@Scope("request")
@URLMappings(mappings = {
@URLMapping(id = "users", pattern = "/users", viewId = "/faces/users.xhtml"),
@URLMapping(id = "add", pattern = "/add", viewId = "/faces/add.xhtml") })
public class UserBean {
2- LoginBean:
@Component("login")
@Scope("request")
@URLMapping(id = "login", pattern = "/login", viewId = "/faces/login.xhtml")
public class LoginBean {
but when i try to run the application i am getting the following exception (i added some debugs before and after the exception):
DEBUG [main] (FacesConfigBeanNameResolver.java:110) - Found 0 bean names in faces configuration.
DEBUG [main] (CDIBeanNameResolver.java:127) - BeanManager or Bean class not found. CDI resolver has been disabled.
DEBUG [main] (SpringBeanNameResolver.java:95) - Spring detected. Enabling Spring bean name resolving.
DEBUG [main] (SeamBeanNameResolver.java:90) - Seam class has not been found. Seam resolver will be disabled.
DEBUG [main] (AbstractClassFinder.java:200) - Bytecode filter recommends to scan class: myapp.beans.LoginBean
DEBUG [main] (AbstractClassFinder.java:200) - Bytecode filter recommends to scan class: myapp.beans.UserBean
com.ocpsoft.pretty.PrettyException: Failed to load configuration.
at com.ocpsoft.pretty.faces.config.PrettyConfigurator.configure(PrettyConfigurator.java:90)
at com.ocpsoft.pretty.PrettyFilter.init(PrettyFilter.java:305)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:295)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:422)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:115)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4072)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4726)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.IllegalArgumentException: Duplicated mapping id: login
at com.ocpsoft.pretty.faces.config.annotation.PrettyAnnotationHandler.processPrettyMappingAnnotation(PrettyAnnotationHandler.java:209)
at com.ocpsoft.pretty.faces.config.annotation.PrettyAnnotationHandler.processClassMappingAnnotations(PrettyAnnotationHandler.java:154)
at com.ocpsoft.pretty.faces.config.annotation.PrettyAnnotationHandler.processClass(PrettyAnnotationHandler.java:109)
at com.ocpsoft.pretty.faces.config.annotation.AbstractClassFinder.processClass(AbstractClassFinder.java:219)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:154)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.processDirectory(WebClassesFinder.java:183)
at com.ocpsoft.pretty.faces.config.annotation.WebClassesFinder.findClasses(WebClassesFinder.java:68)
at com.ocpsoft.pretty.faces.config.spi.AnnotationConfigurationProvider.loadConfiguration(AnnotationConfigurationProvider.java:82)
at com.ocpsoft.pretty.faces.config.PrettyConfigurator.configure(PrettyConfigurator.java:63)
... 19 more
DEBUG [main] (AbstractClassFinder.java:200) - Bytecode filter recommends to scan class: myapp.LoginBean
this line is repeated twice for LoginBean, is it the problem ?
Bytecode filter recommends to scan class LoginBean
please advise.
回答1:
Please make sure that your IDE/build tool is not putting duplicated class files into your web application output directory. This is most likely the cause. I also believe this issue has been addressed in the PrettyFaces class scanner, but the fault is in the build.
来源:https://stackoverflow.com/questions/7758777/duplicated-mapping-id-with-prettyfaces