Announcement Announcement Module
Collapse
No announcement yet.
Invalid content was found starting with element 'beans:bean' Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Invalid content was found starting with element 'beans:bean'

    hey guys i'm unsure why i'm getting this error or how to go about fixing it

    here is the code from the applicationContext-security.xml

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <beans:beans xmlns="http://www.springframework.org/schema/security"
    	xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd">
    
    
    	<!-- HTTP security configurations -->
    	<http auto-config="true" use-expressions="true">
    		<form-login login-processing-url="/resources/j_spring_security_check"
    			login-page="/login" authentication-failure-url="/login?login_error=t" />
    		<logout logout-url="/resources/j_spring_security_logout" />
    
    		<!-- Configure these elements to secure URIs in your application -->
    		<intercept-url pattern="/choices/**" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/locations/**" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/businesses/**" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/subscribers" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/users" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/dealpurchases" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/vouchers/**" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/roleses/**" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/deals/form" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/users/form" access="hasRole('ADMIN')" />
    		<intercept-url pattern="/member/**" access="isAuthenticated()" />
    		<intercept-url pattern="/resources/**" access="permitAll" />
    		<intercept-url pattern="/**" access="permitAll" />
    	</http>
    
    	<!-- Configure Authentication mechanism -->
    	<authentication-manager alias="authenticationManager">
    		<!-- DAO Based Security -->
    		<!--<authentication-provider>
    		<password-encoder hash="sha-256" />
    		<jdbc-user-service data-source-ref="dataSource"
    		users-by-username-query="SELECT user_name AS username, user_password AS password, enabled FROM user where user_name=?"
    		authorities-by-username-query="SELECT user_name as username, R.name as authority FROM user U, roles R WHERE U.roles = R.Id AND user_name=?"/>
    	      </authentication-provider>-->
    	    
    	      <authentication-provider user-service-ref="customUserDetailsService">
    	      <password-encoder hash="sha-256" />
    	      <bean id="customUserDetailsService" class="com.au.dealclick.implementations.CustomJdbcDaoImpl">
    	      <property name="dataSource" ref="dataSource"/>
    	      <property name="usersByUsernameQuery" value="SELECT username,password,enabled,email FROM users WHERE username = ?"/>
    	      </bean>
    	      </authentication-provider>
    	      </authentication-manager>
    
    	<!-- Security event logging -->
    	<beans:bean id="loggerListener"
    		class="org.springframework.security.authentication.event.LoggerListener" />
    </beans:beans>
    next post i'll put the stack trace

  • #2
    Code:
    2011-11-17 14:41:27,196 [main] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 43 in XML document from file [/home/user/webprojects/dealclick/target/classes/META-INF/spring/applicationContext-security.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans:bean'. One of '{"http://www.springframework.org/schema/security":any-user-service, "http://www.springframework.org/schema/security":password-encoder}' is expected.
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
            at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124)
            at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93)
            at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
            at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)
            at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)
            at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
            at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
            at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
            at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
            at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
            at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445)
            at org.apache.catalina.startup.Embedded.start(Embedded.java:825)
            at org.codehaus.mojo.tomcat.AbstractRunMojo.startContainer(AbstractRunMojo.java:558)
            at org.codehaus.mojo.tomcat.AbstractRunMojo.execute(AbstractRunMojo.java:255)
            at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
            at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
            at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
            at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
            at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
            at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
            at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
            at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
            at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
            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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
            at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
            at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
            at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
    Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'beans:bean'. One of '{"http://www.springframework.org/schema/security":any-user-service, "http://www.springframework.org/schema/security":password-encoder}' is expected.
            at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
            at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
            at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
            at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:417)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3182)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1806)
            at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705)
            at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
            at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
            at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
            at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
            at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
            at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235)
            at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284)
            at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
            at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
            ... 43 more

    Comment


    • #3
      You haven't prefixed the "bean" element with the "beans" namespace, e.g.:

      Code:
      <beans:bean id="customUserDetailsService" class="com.au.dealclick.implementations.CustomJdbcDaoImpl">
                 <beans:property name="dataSource" ref="dataSource"/>
                 <beans:property name="usersByUsernameQuery" value="SELECT username,password,enabled,email FROM users WHERE username = ?"/>
      </beans:bean>
      However, I don't believe you can configure a custom UserDetailsService with an inline bean like this (in Spring Sec 3.0, anyway) - you need to use the user-service ref="myBean" attribute to refer to a custom bean that you declare elsewhere in the file. This is covered in the namespace introduction chapter of the manual.

      Comment


      • #4
        sweet that works, thankyou,,, now i just need to implement the roles :

        Comment

        Working...
        X