Spring fails when java splits classes -
i've created spring security configuration class 2 configuration subclasses frontend & backend.
@enablewebsecurity public class securityconfig { private static authenticationprovider authenticationprovider = new fakeauthenticationprovider(); /** * frontend security configuration */ @configuration @order(2) public static class frontendsecurityconfiguration extends websecurityconfigureradapter { @override protected void configure(httpsecurity http) throws exception { http.authenticationprovider(authenticationprovider) .authorizerequests() .antmatchers("/resources/**").permitall() .anyrequest() .hasrole("user") .and() .formlogin() .loginpage( "/login") .permitall() .defaultsuccessurl("/", true); } } /** * backend security configuration */ @configuration @order(1) public static class backendsecurityconfiguration extends websecurityconfigureradapter { @autowired private string backendurl; @override protected void configure(httpsecurity http) throws exception { http.antmatcher(backendurl + "**").authenticationprovider(authenticationprovider) .authorizerequests() .anyrequest() .hasrole("admin") .and() .formlogin() .loginpage(backendurl + "login") .permitall() .defaultsuccessurl(backendurl, true); } } }
and java compiles 3 class files it: securityconfig$frontendsecurityconfiguration.class securityconfig$backendsecurityconfiguration.class securityconfig.class
15-may-2015 13:38:21.971 warning [http-nio-8082-exec-68] org.springframework.web.context.support.annotationconfigwebapplicationcontext.refresh exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.beandefinitionstoreexception: failed parse configuration class [com.aplhost.panel.core.config.appconfig]; nested exception org.springframework.context.annotation.conflictingbeandefinitionexception: annotation-specified bean name 'securityconfig.backendsecurityconfiguration' bean class [com.aplhost.panel.core.config.securityconfig$backendsecurityconfiguration] conflicts existing, non-compatible bean definition of same name , class [com.aplhost.panel.core.securityconfig$backendsecurityconfiguration] @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:179) @ org.springframework.context.annotation.configurationclasspostprocessor.processconfigbeandefinitions(configurationclasspostprocessor.java:306) @ org.springframework.context.annotation.configurationclasspostprocessor.postprocessbeandefinitionregistry(configurationclasspostprocessor.java:239) @ org.springframework.context.support.postprocessorregistrationdelegate.invokebeandefinitionregistrypostprocessors(postprocessorregistrationdelegate.java:254) @ org.springframework.context.support.postprocessorregistrationdelegate.invokebeanfactorypostprocessors(postprocessorregistrationdelegate.java:94) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:606) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:462) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4727) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5167) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.manager.managerservlet.start(managerservlet.java:1293) @ org.apache.catalina.manager.htmlmanagerservlet.start(htmlmanagerservlet.java:673) @ org.apache.catalina.manager.htmlmanagerservlet.dopost(htmlmanagerservlet.java:221) @ javax.servlet.http.httpservlet.service(httpservlet.java:648) @ javax.servlet.http.httpservlet.service(httpservlet.java:729) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.filters.csrfpreventionfilter.dofilter(csrfpreventionfilter.java:213) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.filters.setcharacterencodingfilter.dofilter(setcharacterencodingfilter.java:108) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:614) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:142) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:617) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:518) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1091) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:668) @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1521) @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1478) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745) caused by: org.springframework.context.annotation.conflictingbeandefinitionexception: annotation-specified bean name 'securityconfig.backendsecurityconfiguration' bean class [com.aplhost.panel.core.config.securityconfig$backendsecurityconfiguration] conflicts existing, non-compatible bean definition of same name , class [com.aplhost.panel.core.securityconfig$backendsecurityconfiguration] @ org.springframework.context.annotation.classpathbeandefinitionscanner.checkcandidate(classpathbeandefinitionscanner.java:320) @ org.springframework.context.annotation.classpathbeandefinitionscanner.doscan(classpathbeandefinitionscanner.java:259) @ org.springframework.context.annotation.componentscanannotationparser.parse(componentscanannotationparser.java:140) @ org.springframework.context.annotation.configurationclassparser.doprocessconfigurationclass(configurationclassparser.java:265) @ org.springframework.context.annotation.configurationclassparser.processconfigurationclass(configurationclassparser.java:229) @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:196) @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:165) ... 44 more 15-may-2015 13:38:21.973 severe [http-nio-8082-exec-68] org.springframework.web.context.contextloader.initwebapplicationcontext context initialization failed org.springframework.beans.factory.beandefinitionstoreexception: failed parse configuration class [com.aplhost.panel.core.config.appconfig]; nested exception org.springframework.context.annotation.conflictingbeandefinitionexception: annotation-specified bean name 'securityconfig.backendsecurityconfiguration' bean class [com.aplhost.panel.core.config.securityconfig$backendsecurityconfiguration] conflicts existing, non-compatible bean definition of same name , class [com.aplhost.panel.core.securityconfig$backendsecurityconfiguration] @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:179) @ org.springframework.context.annotation.configurationclasspostprocessor.processconfigbeandefinitions(configurationclasspostprocessor.java:306) @ org.springframework.context.annotation.configurationclasspostprocessor.postprocessbeandefinitionregistry(configurationclasspostprocessor.java:239) @ org.springframework.context.support.postprocessorregistrationdelegate.invokebeandefinitionregistrypostprocessors(postprocessorregistrationdelegate.java:254) @ org.springframework.context.support.postprocessorregistrationdelegate.invokebeanfactorypostprocessors(postprocessorregistrationdelegate.java:94) @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:606) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:462) @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403) @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4727) @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5167) @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) @ org.apache.catalina.manager.managerservlet.start(managerservlet.java:1293) @ org.apache.catalina.manager.htmlmanagerservlet.start(htmlmanagerservlet.java:673) @ org.apache.catalina.manager.htmlmanagerservlet.dopost(htmlmanagerservlet.java:221) @ javax.servlet.http.httpservlet.service(httpservlet.java:648) @ javax.servlet.http.httpservlet.service(httpservlet.java:729) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:291) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.filters.csrfpreventionfilter.dofilter(csrfpreventionfilter.java:213) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.tomcat.websocket.server.wsfilter.dofilter(wsfilter.java:52) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.filters.setcharacterencodingfilter.dofilter(setcharacterencodingfilter.java:108) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:239) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:206) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:219) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:106) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:614) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:142) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:79) @ org.apache.catalina.valves.abstractaccesslogvalve.invoke(abstractaccesslogvalve.java:617) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:88) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:518) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1091) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:668) @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.dorun(nioendpoint.java:1521) @ org.apache.tomcat.util.net.nioendpoint$socketprocessor.run(nioendpoint.java:1478) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1142) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:617) @ org.apache.tomcat.util.threads.taskthread$wrappingrunnable.run(taskthread.java:61) @ java.lang.thread.run(thread.java:745) caused by: org.springframework.context.annotation.conflictingbeandefinitionexception: annotation-specified bean name 'securityconfig.backendsecurityconfiguration' bean class [com.aplhost.panel.core.config.securityconfig$backendsecurityconfiguration] conflicts existing, non-compatible bean definition of same name , class [com.aplhost.panel.core.securityconfig$backendsecurityconfiguration] @ org.springframework.context.annotation.classpathbeandefinitionscanner.checkcandidate(classpathbeandefinitionscanner.java:320) @ org.springframework.context.annotation.classpathbeandefinitionscanner.doscan(classpathbeandefinitionscanner.java:259) @ org.springframework.context.annotation.componentscanannotationparser.parse(componentscanannotationparser.java:140) @ org.springframework.context.annotation.configurationclassparser.doprocessconfigurationclass(configurationclassparser.java:265) @ org.springframework.context.annotation.configurationclassparser.processconfigurationclass(configurationclassparser.java:229) @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:196) @ org.springframework.context.annotation.configurationclassparser.parse(configurationclassparser.java:165) ... 44 more 15-may-2015 13:38:21.974 severe [http-nio-8082-exec-68] org.apache.catalina.core.standardcontext.startinternal 1 or more listeners failed start. full details found in appropriate container log file
but eclipse compiles 1 file securityconfig.class , everythng works correctly.
does know how fix it?
it seems have resolved issue. added @configuration
annotation top class securityconfig
.
Comments
Post a Comment