-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Attribute "generated" must be declared for element
PostPosted: Thu Feb 09, 2006 7:54 pm 
Beginner
Beginner

Joined: Thu Dec 11, 2003 12:02 pm
Posts: 23
WSAD, Hibernate 3.0

Really strange exception. When the hmb file is changed from:
<hibernate-mapping>
<class name="reservatio.CustomerScheduleSeat" table="customer_schedule_seat" catalog="reservatio">
<composite-id name="id" class="reservatio.CustomerScheduleSeatId">
<key-property name="idSchedule" type="integer">
<column name="idSchedule" />
</key-property>
<key-property name="idSeat" type="integer">
<column name="idSeat" />
</key-property>
</composite-id>
<timestamp name="audLsupTs" column="AUD_LSUP_TS" unsaved-value="null"/>

<many-to-one name="customer" class="reservatio.Customer" fetch="select">
<column name="idCustomer" />
</many-to-one>
.....

to


<hibernate-mapping>
<class name="reservatio.CustomerScheduleSeat" table="customer_schedule_seat" catalog="reservatio">
<composite-id name="id" class="reservatio.CustomerScheduleSeatId">
<key-property name="idSchedule" type="integer">
<column name="idSchedule" />
</key-property>
<key-property name="idSeat" type="integer">
<column name="idSeat" />
</key-property>
</composite-id>
<timestamp name="audLsupTs" column="AUD_LSUP_TS" unsaved-value="null" generated="always"/>

<many-to-one name="customer" class="reservatio.Customer" fetch="select">
<column name="idCustomer" />
</many-to-one>
....

I get the xml parser choking. It gives:

[@APPNAME@] DEBUG [Thread-2] DefaultListableBeanFactory.applyBeanPostProcessorsBeforeInitialization(231) | Invoking BeanPostProcessors before initialization of bean 'sessionFactory'
[@APPNAME@] DEBUG [Thread-2] DefaultListableBeanFactory.invokeInitMethods(960) | Invoking afterPropertiesSet() on bean with name 'sessionFactory'
[@APPNAME@] ERROR [Thread-2] XMLHelper.error(59) | Error parsing XML: XML InputStream(15) Attribute "generated" must be declared for element type "timestamp".
[@APPNAME@] INFO [Thread-2] DefaultListableBeanFactory.destroySingletons(525) | Destroying singletons in factory {org.springframework.beans.factory.support.DefaultListableBeanFactory defining beans [sessionFactory,transactionManager,dao,customerScheduleSeatDao,customerDao,codeListManagerDao,showsDao,scheduleDao,venueDao,seatOnTemporaryHold,validatorFactory,beanValidator,propertyConfigurer,dataSource,filterChainProxy,filterInvocationInterceptor,authenticationManager,loggerListener,daoAuthenticationProvider,jdbcAuthenticationDao,userCache,anonymousAuthenticationProvider,roleVoter,accessDecisionManager,httpSessionContextIntegrationFilter,authenticationProcessingFilter,anonymousProcessingFilter,securityEnforcementFilter,remoteUserFilter,authenticationProcessingFilterEntryPoint,userManager,userManagerSecurity,txProxyTemplate,purchaseManager,recommendationSearchManager,searchManager,codeListManager]; root of BeanFactory hierarchy}
[@APPNAME@] ERROR [Thread-2] ContextLoader.initWebApplicationContext(177) | Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext-hibernate.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: invalid mapping
org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:608)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:962)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:354)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:147)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:271)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:312)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:134)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:230)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:156)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:48)
at org.appfuse.webapp.listener.StartupListener.contextInitialized(StartupListener.java:38)
at com.ibm.ws.webcontainer.srt.WebGroup.notifyServletContextCreated(WebGroup.java:1698)


Any ideas why this additional attribute is not being recognized? If I remove the generated= property no problems. The dtd I am using is 3.0 at build time anyways. At runtime I assume it connects to the server to fetch the dtd.

Any help would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 9:00 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The "generated" attribute is new. It's in 3.1.1 but not in 3.0.5. Not sure exactly when it went in, though.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 12:33 pm 
Beginner
Beginner

Joined: Thu Dec 11, 2003 12:02 pm
Posts: 23
It must be referencing an older dtd in one of the jar files -- no idea which one. Also when I am in wsad, the auto fill correctly chooses the right dtd and the attribute can be auto populated. Only at RT does the parser complain on the attribute. As a temporary fix I modified the .hbm.xml file from this:

Code:
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


to this:

Code:
<!DOCTYPE hibernate-mapping SYSTEM "C:/hibernate-3.1/src/org/hibernate/hibernate-mapping-3.0.dtd">


This ensures the file is being validated against the known dtd.


Top
 Profile  
 
 Post subject: Re: Attribute "generated" must be declared for element
PostPosted: Tue Oct 26, 2010 4:49 am 
Beginner
Beginner

Joined: Thu Nov 12, 2009 1:57 am
Posts: 22
I had similar kind of problem. Your suggestion helped me to resolve the issue.

Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.