hibernate动态链接数据库配置文件问题

王政 发布于 2013/07/23 11:27
阅读 998
收藏 0
//protected Configuration conf=new Configuration().configure();
	protected Configuration conf=new Configuration().addFile("hibernate.cfg.xml");
这是某个action的部分代码,上面注释掉的是正确代码,在这条代码下,应用是正常的,但是对于下面的代码,控制台产生如下信息:
七月 23, 2013 11:24:07 上午 org.hibernate.cfg.Configuration addFile INFO: HHH000220: Reading mappings from file: hibernate.cfg.xml

之后即不再产生任何信息……

我自己的分析是,上面的代码说明配置文件是没有错的,应该是addFile中的路径有问题,于是路径修改成了

/hibernate.cfg.xml
但是问题仍然如故……只是控制台信息改成了
七月 23, 2013 11:24:07 上午 org.hibernate.cfg.Configuration addFile INFO: HHH000220: Reading mappings from file: /hibernate.cfg.xml

请大家解答。

另,附控制台信息:

七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:tomcatTest' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:webStruts' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:strutsTest' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:PaaSofLogistics' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:scoreMS' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:target' did not find a matching property.
七月 23, 2013 2:13:08 下午 org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
七月 23, 2013 2:13:08 下午 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1332 ms
七月 23, 2013 2:13:08 下午 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
七月 23, 2013 2:13:08 下午 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.26
七月 23, 2013 2:13:09 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/scoreMS/WEB-INF/lib/el-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
七月 23, 2013 2:13:09 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/scoreMS/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
七月 23, 2013 2:13:12 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PaaSofLogistics/WEB-INF/lib/el-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
七月 23, 2013 2:13:12 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/PaaSofLogistics/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
七月 23, 2013 2:13:13 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/target/WEB-INF/lib/el-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
七月 23, 2013 2:13:13 下午 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/ufo/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/target/WEB-INF/lib/servlet-api.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
七月 23, 2013 2:13:14 下午 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
七月 23, 2013 2:13:14 下午 org.apache.catalina.startup.Catalina start
INFO: Server startup in 5851 ms
七月 23, 2013 2:15:08 下午 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
七月 23, 2013 2:15:08 下午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.9.Final}
七月 23, 2013 2:15:08 下午 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
七月 23, 2013 2:15:08 下午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
七月 23, 2013 2:15:08 下午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: hibernate.cfg.xml
七月 23, 2013 2:15:08 下午 org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator initiateService
WARN: HHH000181: No appropriate connection provider encountered, assuming application will be supplying connections

加载中
0
Michael.Feng
Michael.Feng
用排除法,去掉hibernate.cfg.xml里面的mapping标签,如果去掉哪个mapping的文件不出错了,那么就是哪个配置文件里面配置的问题
0
王政
王政

引用来自“Michael.Feng”的答案

用排除法,去掉hibernate.cfg.xml里面的mapping标签,如果去掉哪个mapping的文件不出错了,那么就是哪个配置文件里面配置的问题

第一眼看到你的答复我就觉得不太可能,因为mapping的存在是为了包含其他配置文件……没有的话显然是不行的……

然后我进行了实验……按照你说的……真的不行,错误仍然是刚才的错误……

0
lkclkc888
lkclkc888
开debug日志。
返回顶部
顶部