[jboss-user] [EJB 3.0] - Packaging Hibernate Mapping Files and persistence.xml

jonesn do-not-reply at jboss.com
Wed Nov 7 06:13:55 EST 2007


Hi.

We're moving our code base to EJB3 on JBOSS AS 4.2.1GA. We want to stick with Hibernate but use the @PersistenceContext annotations to inject the sessions. 

The problem we're having is on deployment, it seems like the Entities are being deployed twice which is causing a DuplicateMappingException 

Two of us have sat down and made sure we aren't duplicating mappings in our codebase and that the deployed jars aren't packaging files in an incorrect fashion.  

Here is our persistence.xml

  | <?xml version="1.0" encoding="UTF-8"?>
  | <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  |              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |              xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
  |              version="1.0">
  |     <persistence-unit name="rb">
  |         <provider>org.hibernate.ejb.HibernatePersistence</provider>
  |         <jta-data-source>java:/RBDBPool</jta-data-source>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/userprofile/hbm/userprofile.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/accesscontrol/hbm/accesscontrol.hbm.xml</mapping-file>        
  |         <mapping-file>com/pioneer/riskbudgeting/dao/benchmark/hbm/rb/benchmark.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/immunisation/hbm/immunisation.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/performance/hbm/performance.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/portfolio/hbm/portfolio.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/portfoliometadata/hbm/portfoliometadata.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/pricing/hbm/rb/pricing.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/report/hbm/report.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/riskfactor/hbm/riskfactor.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/riskfactorschema/hbm/riskfactorschema.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/statistics/hbm/statistics.xml</mapping-file>
  |         <mapping-file>com/pioneer/riskbudgeting/dao/strategyattribute/hbm/strategyattribute.xml</mapping-file>
  |     </persistence-unit>
  | </persistence>

Here is the relevant part of the log:


  | 2007-11-07 11:07:42,937 INFO  [PersistenceUnitDeployment] Starting persistence unit persistence.units:ear=80.rb.ear,jar=20.rb-ejb.jar,unitName=rb
  | 
  | 2007-11-07 11:07:42,968 INFO  [Version] Hibernate EntityManager 3.2.1.GA
  | 2007-11-07 11:07:42,968 INFO  [Version] Hibernate Annotations 3.2.1.GA
  | 2007-11-07 11:07:43,031 INFO  [Ejb3Configuration] Processing PersistenceUnitInfo [
  |         name: rb
  |         ...]
  | 2007-11-07 11:07:44,388 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/userprofile/hbm/userprofile.xml
  | 2007-11-07 11:07:44,403 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/accesscontrol/hbm/accesscontrol.hbm.
  | xml
  | 2007-11-07 11:07:44,419 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/benchmark/hbm/rb/benchmark.xml
  | 2007-11-07 11:07:44,434 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/immunisation/hbm/immunisation.xml
  | 2007-11-07 11:07:44,434 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/performance/hbm/performance.xml
  | 2007-11-07 11:07:44,450 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/portfolio/hbm/portfolio.xml
  | 2007-11-07 11:07:44,481 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/portfoliometadata/hbm/portfoliometad
  | ata.xml
  | 2007-11-07 11:07:44,497 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/pricing/hbm/rb/pricing.xml
  | 2007-11-07 11:07:44,512 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/report/hbm/report.xml
  | 2007-11-07 11:07:44,809 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/riskfactor/hbm/riskfactor.xml
  | 2007-11-07 11:07:44,809 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/riskfactorschema/hbm/riskfactorschem
  | a.xml
  | 2007-11-07 11:07:44,840 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/statistics/hbm/statistics.xml
  | 2007-11-07 11:07:44,856 INFO  [Configuration] Reading mappings from resource : com/pioneer/riskbudgeting/dao/strategyattribute/hbm/strategyattrib
  | ute.xml
  | 2007-11-07 11:07:44,871 INFO  [Configuration] Reading mappings from resource : META-INF/orm.xml
  | 2007-11-07 11:07:44,887 INFO  [Ejb3Configuration] [PersistenceUnit: rb] no META-INF/orm.xml found
  | 2007-11-07 11:07:44,949 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO -> ProtectedObjec
  | tTypes
  | 2007-11-07 11:07:44,949 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ObjectAccessPolicyHTO -> ObjectAccessRig
  | hts
  | 2007-11-07 11:07:44,949 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.benchmark.hbm.rb.CachedBenchmarkHTO -> Benchmarks
  | 2007-11-07 11:07:44,949 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.benchmark.hbm.rb.BenchmarkOverrideHTO -> BenchmarkOverride
  | s
  | 2007-11-07 11:07:44,949 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.immunisation.hbm.TemplateHTO -> ImmunisationTemplates
  | 2007-11-07 11:07:44,965 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.immunisation.hbm.TemplateSecurityHTO -> ImmunisationTempla
  | teHoldings
  | 2007-11-07 11:07:44,965 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.performance.hbm.StrategyOverallPerfHTO -> StrategyOverallP
  | erfHTO
  | 2007-11-07 11:07:44,980 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.performance.hbm.StrategyPerfTimeSeriesHTO -> StrategyPerfT
  | imeSeriesHTO
  | 2007-11-07 11:07:44,980 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.RBPortfolioHTO -> RBPortfolioIds
  | 2007-11-07 11:07:44,980 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.portfolio.hbm.RBPortfolioHTO.attributeValues -> Portf
  | olioAttributeValues
  | 2007-11-07 11:07:44,980 INFO  [HbmBinder] Mapping joined-subclass: com.pioneer.riskbudgeting.dao.portfolio.hbm.RealPortfolioHTO -> Portfolios
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping joined-subclass: com.pioneer.riskbudgeting.dao.portfolio.hbm.VirtualPortfolioHTO -> VirtualPort
  | folios
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.HoldingRevisionHTO -> HoldingRevisions
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.portfolio.hbm.HoldingRevisionHTO.holdings -> Portfoli
  | oHoldings
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.PortfolioRevisionHTO -> PortfolioRevisions
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.StrategyHTO -> PortfolioStrategies
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.StrategyRevisionHTO -> StrategyRevisions
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.portfolio.hbm.StrategyRevisionHTO.holdings -> Portfol
  | ioStrategyHoldings
  | 2007-11-07 11:07:44,996 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.AlertHTO -> PortfolioAlerts
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.AlertAssignmentHTO -> StrategyRevisionsAlert
  | s
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.TradeHTO -> PortfolioTrades
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfolio.hbm.TradeAssignmentHTO -> StrategyRevisionsTrade
  | s
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfoliometadata.hbm.PortfolioAttributeHTO -> PortfolioAt
  | tributes
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.portfoliometadata.hbm.PortfolioAttributeHTO.mappings
  | -> PortfolioAttributeMappings
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.portfoliometadata.hbm.PortfolioAttributeMappingHTO -> Port
  | folioAttributeMappings
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.pricing.hbm.rb.SecurityPriceHTO -> SecurityPrices
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.pricing.hbm.rb.SecurityPriceHTO.accruedInterests -> S
  | ecurityAccruedInterests
  | 2007-11-07 11:07:45,011 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.pricing.hbm.rb.BenchmarkPriceHTO -> BenchmarkPrices
  | 2007-11-07 11:07:45,027 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.pricing.hbm.rb.PortfolioBackOfficePriceHTO -> PortfolioBac
  | kOfficePrices
  | 2007-11-07 11:07:45,027 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.pricing.hbm.rb.PortfolioBackOfficePriceHTO.accruedInt
  | erests -> PortfolioBackOfficeAccruedInterests
  | 2007-11-07 11:07:45,027 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.ReportHTO -> Reports
  | 2007-11-07 11:07:45,027 INFO  [HbmBinder] Mapping joined-subclass: com.pioneer.riskbudgeting.dao.report.hbm.PerformanceReportHTO -> PerformanceRe
  | ports
  | 2007-11-07 11:07:45,027 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.StrategyWeightHTO -> ReportStrategyWeights
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.StrategyCorrelationHTO -> StrategyCorrelations
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.RiskFactorCorrelationHTO -> RiskFactorCorrelati
  | ons
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.TEAttributionHTO -> TEAttribution
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.TERiskFactorSensitivityHTO -> TERiskFactorSensi
  | tivities
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.TEIRSensitivityHTO -> TEIRSensitivities
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.BenchmarkHoldingPerfDataHTO -> BenchmarkHolding
  | PerfData
  | 2007-11-07 11:07:45,043 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.PortfolioHoldingPerfDataHTO -> PortfolioHolding
  | PerfData
  | 2007-11-07 11:07:45,058 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.report.hbm.PerformanceReportExportHTO -> PerformanceReport
  | Export
  | 2007-11-07 11:07:45,121 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.riskfactor.hbm.RiskFactorMappingHTO -> RiskFactors
  | 2007-11-07 11:07:45,121 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.riskfactorschema.hbm.RiskFactorSchemaHTO -> RiskFactorSche
  | mas
  | 2007-11-07 11:07:45,121 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.riskfactorschema.hbm.RiskFactorSchemaHTO.riskFactors
  | -> RiskFactorOrdering
  | 2007-11-07 11:07:45,121 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.statistics.hbm.JobStatisticsHTO -> JobStatistics
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.statistics.hbm.JobItemWeightHTO -> JobItemWeights
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.statistics.hbm.JobEnginePropertiesHTO -> JobEngineProperti
  | es
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.strategyattribute.hbm.StrategyAttributeHTO -> StrategyAttr
  | ibutes
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.strategyattribute.hbm.StrategyTypeHTO -> StrategyTypes
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping collection: com.pioneer.riskbudgeting.dao.strategyattribute.hbm.StrategyTypeHTO.attributeValues
  |  -> StrategyAttributeValues
  | 2007-11-07 11:07:45,136 INFO  [Mappings] duplicate import: com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO->com.pioneer.ri
  | skbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO
  | 2007-11-07 11:07:45,136 INFO  [Mappings] duplicate import: com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO->ProtectedObjec
  | tTypeHTO
  | 2007-11-07 11:07:45,136 INFO  [HbmBinder] Mapping class: com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO -> ProtectedObjec
  | tTypes
  | 2007-11-07 11:07:45,152 WARN  [ServiceController] Problem starting service persistence.units:ear=80.rb.ear,jar=20.rb-ejb.jar,unitName=rb
  | org.hibernate.DuplicateMappingException: Duplicate class/entity mapping com.pioneer.riskbudgeting.dao.accesscontrol.hbm.ProtectedObjectTypeHTO
  |         at org.hibernate.cfg.Mappings.addClass(Mappings.java:118)
  |         at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:145)
  |         at org.hibernate.cfg.Configuration.add(Configuration.java:669)
  |         at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:437)
  |         at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
  |         at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
  |         at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
  |         at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)
  |         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
  |         at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
  |         at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
  |         at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)
  | 

Does anyone have any advice on why the mappings might be occuring twice (Apart from the obvious mapping and packaging errors that we have checked)?

Thanks for your time
Nick.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4102475#4102475

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4102475



More information about the jboss-user mailing list