嗨,
我正在尝试运行一个导入的开源但运行后我遇到了这个错误:它让我发疯了这是一个巨大的项目,我不知道应该从哪开始。
Running test.hibernate.softdelete.jointablewhere.SoftDeleteAssociationTest
main INFO [org.hibernate.cfg.Configuration] - configuring from resource: softdelete/softdelete-hibernate.cfg.xml
main INFO [org.hibernate.cfg.Configuration] - Configuration resource: softdelete/softdelete-hibernate.cfg.xml
main INFO [org.hibernate.cfg.Configuration] - Configured SessionFactory: java:hibernate/SessionFactory
main INFO [org.hibernate.cfg.AnnotationBinder] - Binding entity from annotated class: test.hibernate.softdelete.jointablewhere.Parent
main INFO [org.hibernate.cfg.annotations.EntityBinder] - Bind entity test.hibernate.softdelete.jointablewhere.Parent on table Parent
main INFO [org.hibernate.cfg.AnnotationBinder] - Binding entity from annotated class: test.hibernate.softdelete.jointablewhere.Child
main INFO [org.hibernate.cfg.annotations.EntityBinder] - Bind entity test.hibernate.softdelete.jointablewhere.Child on table Child
main INFO [org.hibernate.cfg.search.HibernateSearchEventListenerRegister] - Unable to find org.hibernate.search.event.FullTextIndexEventListener on the classpath. Hibernate Search is not enabled.
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - Using Hibernate built-in connection pool (not for production use!)
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - Hibernate connection pool size: 20
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - autocommit mode: false
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - using driver: org.h2.Driver at URL: jdbc:h2:mem:softdelete
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - connection properties: {user=sa, password=****}
main INFO [org.hibernate.dialect.Dialect] - Using dialect: org.hibernate.dialect.H2Dialect
main INFO [org.hibernate.engine.jdbc.JdbcSupportLoader] - Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
main INFO [org.hibernate.cfg.SettingsFactory] - Database ->
name : H2
version : 1.2.144 (2010-10-15)
major : 1
minor : 2
main INFO [org.hibernate.cfg.SettingsFactory] - Driver ->
name : H2 JDBC Driver
version : 1.2.144 (2010-10-15)
major : 1
minor : 2
main INFO [org.hibernate.transaction.TransactionFactoryFactory] - Using default transaction strategy (direct JDBC transactions)
main INFO [org.hibernate.transaction.TransactionManagerLookupFactory] - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
main INFO [org.hibernate.cfg.SettingsFactory] - Automatic flush during beforeCompletion(): disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Automatic session close at end of transaction: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch size: 15
main INFO [org.hibernate.cfg.SettingsFactory] - JDBC batch updates for versioned data: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Scrollable result sets: enabled
main INFO [org.hibernate.cfg.SettingsFactory] - JDBC3 getGeneratedKeys(): enabled
main INFO [org.hibernate.cfg.SettingsFactory] - Connection release mode: auto
main INFO [org.hibernate.cfg.SettingsFactory] - Default batch fetch size: 1
main INFO [org.hibernate.cfg.SettingsFactory] - Generate SQL with comments: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Order SQL updates by primary key: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Order SQL inserts for batching: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
main INFO [org.hibernate.hql.ast.ASTQueryTranslatorFactory] - Using ASTQueryTranslatorFactory
main INFO [org.hibernate.cfg.SettingsFactory] - Query language substitutions: {}
main INFO [org.hibernate.cfg.SettingsFactory] - JPA-QL strict compliance: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Second-level cache: enabled
main INFO [org.hibernate.cfg.SettingsFactory] - Query cache: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
main INFO [org.hibernate.cfg.SettingsFactory] - Optimize cache for minimal puts: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Structured second-level cache entries: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Statistics: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Deleted entity synthetic identifier rollback: disabled
main INFO [org.hibernate.cfg.SettingsFactory] - Default entity-mode: pojo
main INFO [org.hibernate.cfg.SettingsFactory] - Named query checking : enabled
main INFO [org.hibernate.cfg.SettingsFactory] - Check Nullability in Core (should be disabled when Bean Validation is on): disabled
main INFO [org.hibernate.impl.SessionFactoryImpl] - building session factory
main INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Factory name: java:hibernate/SessionFactory
main INFO [org.hibernate.util.NamingHelper] - JNDI InitialContext properties:{}
main WARN [org.hibernate.impl.SessionFactoryObjectFactory] - Could not bind factory to JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getNameParser(Unknown Source)
at org.hibernate.util.NamingHelper.bind(NamingHelper.java:75)
at org.hibernate.impl.SessionFactoryObjectFactory.addInstance(SessionFactoryObjectFactory.java:113)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:367)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1872)
at org.hibernate.cfg.Configuration$buildSessionFactory.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at test.hibernate.softdelete.jointablewhere.SoftDeleteAssociationTest.setup(SoftDeleteAssociationTest.groovy:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:235)
at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:217)
at org.spockframework.runtime.BaseSpecRunner.invokeSetup(BaseSpecRunner.java:198)
at org.spockframework.runtime.BaseSpecRunner.runSimpleFeature(BaseSpecRunner.java:181)
at org.spockframework.runtime.BaseSpecRunner.doRunFeature(BaseSpecRunner.java:174)
at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:235)
at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:217)
at org.spockframework.runtime.BaseSpecRunner.runFeature(BaseSpecRunner.java:152)
at org.spockframework.runtime.BaseSpecRunner.runFeatures(BaseSpecRunner.java:129)
at org.spockframework.runtime.BaseSpecRunner.doRun(BaseSpecRunner.java:96)
at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.spockframework.runtime.BaseSpecRunner.invokeRaw(BaseSpecRunner.java:235)
at org.spockframework.runtime.BaseSpecRunner.invoke(BaseSpecRunner.java:217)
at org.spockframework.runtime.BaseSpecRunner.run(BaseSpecRunner.java:73)
at org.spockframework.runtime.Sputnik.run(Sputnik.java:57)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:24)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at org.junit.runner.JUnitCore.run(JUnitCore.java:136)
at org.junit.runner.JUnitCore.run(JUnitCore.java:127)
at org.apache.maven.surefire.junitcore.JUnitCoreWrapper.execute(JUnitCoreWrapper.java:51)
at org.apache.maven.surefire.junitcore.JUnitCoreProvider.invoke(JUnitCoreProvider.java:103)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(ProviderFactory.java:103)
at $Proxy0.invoke(Unknown Source)
at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(SurefireStarter.java:145)
at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(SurefireStarter.java:87)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)
main INFO [org.hibernate.impl.SessionFactoryImpl] - closing
main INFO [org.hibernate.connection.DriverManagerConnectionProvider] - cleaning up connection pool: jdbc:h2:mem:softdelete
main INFO [org.hibernate.impl.SessionFactoryObjectFactory] - Unbinding factory from JNDI name: java:hibernate/SessionFactory
main INFO [org.hibernate.util.NamingHelper] - JNDI InitialContext properties:{}
main WARN [org.hibernate.impl.SessionFactoryObjectFactory] - Could not unbind factory from JNDI
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
这是softdelete-hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory name="java:hibernate/SessionFactory">
<!-- properties -->
<property name="connection.url">jdbc:h2:mem:softdelete</property>
<property name="connection.driver">org.h2.Driver</property>
<property name="connection.username">sa</property>
<property name="connection.password">sa</property>
<property name="dialect">org.hibernate.dialect.H2Dialect</property>
<property name="hbm2ddl.auto">create</property>
<property name="hbm2ddl.import_files">softdelete/import.sql</property>
<property name="validator.apply_to_ddl">false</property>
<property name="javax.persistence.validation.mode">none</property>
</session-factory>
</hibernate-configuration>
请问好吗? 提前谢谢你
答案 0 :(得分:16)
在softdelete-hibernate.cfg.xml中,删除会话工厂名称。 请尝试仅使用
<session-factory>
<!-- ... -->
</session-factory>
答案 1 :(得分:11)
只需从name
名称=&#34; SessionFactory&#34; <session-factory
>