`

tomcat启动时报错

    博客分类:
  • j2ee
 
阅读更多

1.如果出现这样的提示,意思是说your slf4j包的版本不兼容,

slf4j包的版本冲突,你有至少两个版本的SLF4J,有一个1.6版本的,有一个1.6一下的,删除一个即可 
SLF4J: The requested version 1.6 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8] 
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details. 
15 [main] INFO org.hibernate.cfg.Environment - Hibernate 3.3.2.GA 
31 [main] INFO org.hibernate.cfg.Environment - hibernate.properties not found 
31 [main] INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist 
2.如果报出如下异常: 
1109 [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:348) 
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341) 
    at com.asm.hibernate.test.UserTest.main(UserTest.java:16) 
------解决方法-------------------------------------------------------- 
应该是jndi没有配置好 
------解决方法-------------------------------------------------------- 
配置文件名是不是hibernate.cfg.xml? 
  代码new Configuration().configure().buildSessionFactory();是指读入默认名为hibernate.cfg.xml的配置文件。 
------解决方法-------------------------------------------------------- 
  把 
  <session-factory name="eheshnew"> 
  改成 
  <session-factory > 
  name="xxxx" 是为了把SessionFactory的唯一实例bind到jndi上的,这样可以通过new InitialContext().lookup("xxxx")来得到SessionFactory,不过实际上没什么用处。 
  非j2ee容器下直接执行或容器不支持jndi动态bind(如tomcat)都会出现这个问题。 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics