Announcement Announcement Module
Collapse
No announcement yet.
<property> format error? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • <property> format error?

    Hello,

    I'm stumped on this error msg:
    org.dom4j.DocumentException: Error on line 13 of document : Element type "property" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "property" must be followed by either attribute specifications, ">" or "/>".
    My applicationConfig.xml follows with the problematic line in bold:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
    "http://www.springframework.org/dtd/spring-beans-2.0.dtd">

    <beans>

    <import resource="datasource-config.xml"/>

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSes sionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="mappingResources">
    <list>
    <value>publish.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQ LDialect</prop>
    <prop key="hibernate.hbm2ddl.auto">update</prop>
    </props>
    </property>
    </bean>

    <bean id="publishDAO" class="com.sas.dwin.PublishDAOImpl">
    <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

    </beans>

    (proper indenting seems to be lost during the paste)
    When I remove that line, xml is parsed correctly, but of course hibernate doesn't get its mapping. per DTD it seems to be correct XML -- and I copied it from the Spring 2.0 reference manual so I assume it should work.

    Suggestions appreciated!

    -- David

  • #2
    If you put the code in [ code] [ /code] tags it won't loose the formatting. As for the XML, I had a look at it in SpringIDE and it validated fine. Is that the exact XML that was failing? Just out of interest could we see the full stracktrace?

    Comment


    • #3
      properties

      Yes, its the exact xml. Deleting that one line passes validation. I even tried deleting all the blanks between the tags in case there was a non-displayed char, but I'm totall stumped!

      Comment


      • #4
        A total guess... perhaps copying from PDF ended up adding some strange (invisible?) characters. For me copying from Word often does something funny; usually due to smart quotes.

        Try removing the offending line and a little bit around it. Then retype manually.

        -Ramnivas

        Comment


        • #5
          Those pesky invisible characters . I have also had the same thing before, it's a real pain. If you are still having problems, you'll have to attach the file instead so we can have a look.

          Comment


          • #6
            &lt;property&gt; format error?

            Even retyping did not solve unfortunately. Configuration file is attached. Your help is appreaciated big-time!

            Here's the error msg again:

            Code:
            Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [ApplicationConfiguration.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
            Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
            	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:508)
            	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:651)
            	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)
            	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)
            	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
            	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
            	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
            ....etc...
            Caused by: org.dom4j.DocumentException: Error on line 13 of document  : Element type "property" must be followed by either attribute specifications, ">" or "/>". Nested exception: Element type "property" must be followed by either attribute specifications, ">" or "/>".
            	at org.dom4j.io.SAXReader.read(SAXReader.java:355)
            	at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:499)
            	... 15 more

            Comment


            • #7
              I don't think this is anything to do with the Spring configuration, I think it's the actual Hibernate hbm. Is it possible to post the hbm file?

              Comment


              • #8
                &lt;property&gt; format error?

                absolutely. It is attached. I never supposed that it would be processed at that point!
                It may very well have an error as I have not yet figured out for sure how to model this simple record which does not have a synthetic key (id).

                Comment


                • #9
                  Ok, problem solved...... I hope. The last property has an extra quote at the end.

                  This
                  Code:
                  <property name="model" column="MODEL" type="java.lang.String" not-null="true""/>
                  Should be this
                  Code:
                  <property name="model" column="MODEL" type="java.lang.String" not-null="true"/>

                  Comment


                  • #10
                    Thank you very much Karl. I never figured the "property parsing" error was actually processing the mapping file! I can figure out the rest....

                    Comment


                    • #11
                      Not a problem, glad it's sorted! I should have actually read it properly in the first place, I just saw property and thought Spring. I didn't think about the Hibernate hbm. Oohhh well, chalk that one up to tiredness .

                      Comment

                      Working...
                      X