2014年1月7日星期二

hibernate configuration mistakes most , how to do first aid ah ......


2011-6-20 14:51:11 org.hibernate.annotations.common.Version <clinit>
信息: Hibernate Commons Annotations 3.2.0.Final
2011-6-20 14:51:11 org.hibernate.cfg.Environment <clinit>
信息: Hibernate 3.6.4.Final
2011-6-20 14:51:11 org.hibernate.cfg.Environment <clinit>
信息: hibernate.properties not found
2011-6-20 14:51:11 org.hibernate.cfg.Environment buildBytecodeProvider
信息: Bytecode provider name : javassist
2011-6-20 14:51:11 org.hibernate.cfg.Environment <clinit>
信息: using JDK 1.4 java.sql.Timestamp handling
2011-6-20 14:51:11 org.hibernate.cfg.Configuration configure
信息: configuring from resource: /hibernate.cfg.xml
2011-6-20 14:51:11 org.hibernate.cfg.Configuration getConfigurationInputStream
信息: Configuration resource: /hibernate.cfg.xml
2011-6-20 14:51:11 org.hibernate.cfg.Configuration doConfigure
信息: Configured SessionFactory: null
2011-6-20 14:51:11 org.hibernate.cfg.AnnotationBinder bindClass
信息: Binding entity from annotated class: hb.learn.model.User
2011-6-20 14:51:11 org.hibernate.cfg.annotations.EntityBinder bindTable
信息: Bind entity hb.learn.model.User on table user
2011-6-20 14:51:11 org.hibernate.cfg.Configuration applyHibernateValidatorLegacyConstraintsOnDDL
信息: Hibernate Validator not found: ignoring
2011-6-20 14:51:11 org.hibernate.validator.util.Version <clinit>
信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
Exception in thread "main" org.hibernate.HibernateException: Unable to get the default Bean Validation factory
at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127)
at org.hibernate.cfg.Configuration.applyBeanValidationConstraintsOnDDL(Configuration.java:1704)
at org.hibernate.cfg.Configuration.applyConstraintsToDDL(Configuration.java:1654)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1445)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at hb.learn.util.HibernateUtil.main(HibernateUtil.java:15)
Caused by: java.lang.reflect.InvocationTargetException
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.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:118)
... 5 more
Caused by: org.hibernate.HibernateException: Unable to build the default ValidatorFactory
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:383)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.applyDDL(TypeSafeActivator.java:109)
... 10 more
Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:272)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafeActivator.java:380)
... 11 more
Caused by: java.lang.NullPointerException
at java.util.ResourceBundle.getBundle(ResourceBundle.java:960)
at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.loadBundle(ResourceBundleMessageInterpolator.java:202)
at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.getFileBasedResourceBundle(ResourceBundleMessageInterpolator.java:182)
at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:81)
at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:73)
at org.hibernate.validator.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:57)
at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43)
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
... 13 more


------ Solution ------------------------------------- -------
+1 +1 +1 +1 +1 +1
------ Solution ------------------ --------------------------
is not necessary jar package did not lead the whole ah
------ Solution --------------------------------------------
can not be instantiated Disposition . Look at the configuration posted under way . .
------ For reference only -------------------------------------- -
hibernate.cfg.xml
This is my configuration file:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/spring
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>

<!-- JDBC connection pool (use the built-in) --><!--
<property name="connection.pool_size">1</property>

--><!-- SQL dialect -->
<property name="dialect">
org.hibernate.dialect.MySQL5Dialect
</property>

<!--<Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache  -->
<property name="cache.provider_class">
org.hibernate.cache.NoCacheProvider
</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<property name="format_sql">true</property>

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>

<mapping class="hb.learn.model.User" />
</session-factory>
</hibernate-configuration>

------ For reference only ----------------------------------- ----
I configure the java web project where , after deleting all javaee 6libraries as long as there's a package, you can not go wrong , and this is how Nigeria ! ?
------ For reference only -------------------------------------- -
Dinga , which experts help me ah ......
------ For reference only ---------------------- -----------------
org.hibernate.HibernateException: Unable to get the default Bean Validation factor
This anomaly needs to be configured in the hibernate.cfg.xml configuration file:
none
------ For reference only ----------- ----------------------------
Thank upstairs selfless dedication , the use of this approach can really solve
hibernate tests reported problems such errors , thank you again !
------ For reference only -------------------------------------- -
7 floor right way . Spring3 + Hibernate3.6 + Junit4 can write unit tests.
------ For reference only -------------------------------------- - 7th floor

powerful
Why can explain it ?
------ For reference only -------------------------------------- -

hibernate by default will use the bean validation features, adding if the configuration file
none
This configuration is tell me NA hibernate bean validation function , of course, will not hibernate factory class initialization tests , and also not being given up !
------ For reference only -------------------------------------- -
much worse ! Thank Kazakhstan, taught the ~
------ For reference only ------------------------------- --------
powerful. . . . I am also the same mistake. . Now finally resolved
------ For reference only ----------------------------------- ----
badly, I'm looking for a long time do not know what wrong ? Thanks. .
------ For reference only -------------------------------------- -
So now , previously solved , looked up and guess

没有评论:

发表评论