2013-08-14 2 views
0

Я хочу написать veriy простой пример с HibernateOGM для заполнения коллекции в MongoDB, но если я бегу мое Programm, я получаю это исключение:Ошибка: Не удалось получить конструктор для org.hibernate.ogm.persister.OgmEntityPersister

Исключение в потоке "основного" org.hibernate.MappingException: не удалось получить конструктор для org.hibernate.ogm.persister.OgmEntityPersister

это мой трассировки стека:

*at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185) 
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135) 
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:383) 
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750) 
at hogm.hibernateogm_mongodb.App.main(App.java:30)* 

Hier это мой POJ O:

public class Contact { 
    @Id 
    private Long id; 
    private String email; 
    private String firstname; 
    private String lastname; 

    public String getEmail() { 
     return email; 
    } 

    /** 
    * @param email the email to set 
    */ 
    public void setEmail(String email) { 
     this.email = email; 
    } 

и здесь вы можете найти мой hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 
    <session-factory> 
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> 
    <property name="hibernate.current_session_context_class">thread</property> 
    <property name="hibernate.ogm.datastore.provider">mongodb</property> 
    <property name="hibernate.ogm.mongodb.database">rcfdb</property> 
    <property name="hibernate.ogm.mongodb.host">127.0.0.1</property> 
    <property name="hibernate.ogm.mongodb.port">27017</property> 
    <mapping resource="hibernate-contact.hbm.xml"/> 
    </session-factory> 
</hibernate-configuration> 

и hbm.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE hibernate-mapping PUBLIC 
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN" 
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> 
<hibernate-mapping> 
    <class name="Untersuchungsraum.Contact" table="District"> 
    <id column="id" type="integer" > 
     <generator class="native"> 
     </generator> 
    </id> 
    <property name="firstname" type="java.lang.String"> 
     <column name="Firstname"></column> 
    </property> 

    <property name="lastname" type="java.lang.String"> 
     <column name="lastname"></column> 
    </property> 

    <property name="email" type="java.lang.String"> 
     <column name="email"></column> 
    </property> 
    </class> 
    </hibernate-mapping> 

Есть ли у вас может быть идея, чтобы решить эту проблему? благодаря

* UPDATE *

мой полный трассировки стека:

Scanning for projects... 

------------------------------------------------------------------------ 
Building HibernateOGM_MongoDB 1.0-SNAPSHOT 
------------------------------------------------------------------------ 

[resources:resources] 
[debug] execute contextualize 
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! 
Copying 2 resources 

[compiler:compile] 
File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent! 
Compiling 1 source file to C:\Users\Babak\Documents\NetBeansProjects\HibernateOGM_MongoDB\target\classes 

[exec:exec] 
Aug 14, 2013 4:16:57 PM org.hibernate.annotations.common.Version <clinit> 
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} 
Aug 14, 2013 4:16:57 PM org.hibernate.Version logVersion 
INFO: HHH000412: Hibernate Core {4.1.9.Final} 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Environment <clinit> 
INFO: HHH000206: hibernate.properties not found 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Environment buildBytecodeProvider 
INFO: HHH000021: Bytecode provider name : javassist 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Configuration configure 
INFO: HHH000043: Configuring from resource: hibernate.cfg.xml 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Configuration getConfigurationInputStream 
INFO: HHH000040: Configuration resource: hibernate.cfg.xml 
Aug 14, 2013 4:16:57 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity 
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Configuration addResource 
INFO: HHH000221: Reading mappings from resource: hibernate-contact.hbm.xml 
Aug 14, 2013 4:16:57 PM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity 
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide! 
Aug 14, 2013 4:16:57 PM org.hibernate.cfg.Configuration doConfigure 
INFO: HHH000041: Configured SessionFactory: null 
Aug 14, 2013 4:16:57 PM org.hibernate.dialect.Dialect <init> 
INFO: HHH000400: Using dialect: org.hibernate.ogm.dialect.NoopDialect 
Aug 14, 2013 4:16:57 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation 
INFO: HHH000422: Disabling contextual LOB creation as connection was null 
Aug 14, 2013 4:16:57 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService 
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory 
Aug 14, 2013 4:16:57 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init> 
INFO: HHH000397: Using ASTQueryTranslatorFactory 
Aug 14, 2013 4:16:57 PM org.hibernate.ogm.cfg.impl.Version <clinit> 
INFO: OGM000001: Hibernate OGM 4.0.0.Beta1 
Exception in thread "main" org.hibernate.MappingException: Could not get constructor for org.hibernate.ogm.persister.OgmEntityPersister 
    at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:185) 
    at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135) 
    at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:383) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1750) 
    at hogm.hibernateogm_mongodb.App.main(App.java:30) 
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.ogm.datastore.spi.DatastoreProvider] 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:186) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:150) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) 
    at org.hibernate.ogm.datastore.impl.DatastoreServicesImpl.configure(DatastoreServicesImpl.java:53) 
    at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) 
    at org.hibernate.ogm.persister.OgmEntityPersister.<init>(OgmEntityPersister.java:125) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525) 
    at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163) 
    ... 4 more 
Caused by: org.hibernate.HibernateException: OGM000008: DatastoreManager class [mongodb] cannot be found in classpath try with: [MAP, INFINISPAN, EHCACHE, MONGODB] 
    at org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator.buildServiceInstance(DatastoreProviderInitiator.java:64) 
    at org.hibernate.ogm.datastore.impl.DatastoreProviderInitiator.buildServiceInstance(DatastoreProviderInitiator.java:40) 
    at org.hibernate.ogm.service.impl.OptionalServiceInitiator.initiateService(OptionalServiceInitiator.java:37) 
    at org.hibernate.service.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:69) 
    at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:176) 
    ... 16 more 
------------------------------------------------------------------------ 
BUILD FAILURE 
------------------------------------------------------------------------ 
Total time: 3.141s 
Finished at: Wed Aug 14 16:16:58 PDT 2013 
Final Memory: 10M/25M 
------------------------------------------------------------------------ 
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project HibernateOGM_MongoDB: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1] 

To see the full stack trace of the errors, re-run Maven with the -e switch. 
Re-run Maven using the -X switch to enable full debug logging. 

For more information about the errors and possible solutions, please read the following articles: 
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException 
+0

Опубликовать полную трассировку стека (включая основную причину) – harrybvp

+0

Я обновил сообщение, что я должен опубликовать в качестве основной причины? извините, что я новичок: / – TangoStar

ответ

0

У вас есть что-то подобное в вашем ПОМ?

<dependency> 
    <groupId>org.hibernate.ogm</groupId> 
    <artifactId>hibernate-ogm-mongodb</artifactId> 
    <version>4.0.0.Beta3</version> 
</dependency> 

Похоже, вы не добавляете банку для MongoDB.

Смежные вопросы