[][][]弄了2天了,紧急求救Not binding factory to JNDI, no JNDI name configur没有分了只能给20分见谅

etracer 2014-03-05 01:45:53
框架hibenat struts1 jndi
jndi总是报错
如下
2014/03/05 14:33:16 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
情報: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\MyEclipse Professional\binary\com.sun.java.jdk.win32.x86_1.6.0.u43\bin;C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin
2014/03/05 14:33:16 org.apache.coyote.http11.Http11BaseProtocol init
情報: Coyote HTTP/1.1を http-8080 で初期化します
2014/03/05 14:33:16 org.apache.catalina.startup.Catalina load
情報: Initialization processed in 797 ms
2014/03/05 14:33:16 org.apache.catalina.core.StandardService start
情報: サービス Catalina を起動します
2014/03/05 14:33:16 org.apache.catalina.core.StandardEngine start
情報: Starting Servlet Engine: Apache Tomcat/5.5.26
2014/03/05 14:33:16 org.apache.catalina.core.StandardHost start
情報: XML検証は無効です
[INFO] Environment - Hibernate 2.1.8
[INFO] Environment - loaded properties from resource hibernate.properties: {hibernate.cglib.use_reflection_optimizer=true}
[INFO] Environment - using CGLIB reflection optimizer
[INFO] Environment - using JDK 1.4 java.sql.Timestamp handling
[INFO] Configuration - configuring from resource: /hibernate.cfg.xml
[INFO] Configuration - Configuration resource: /hibernate.cfg.xml
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/deyWorkTime.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.DeyWorkTime -> deywork_time
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/employee.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.Employee -> employee
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/funds.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.Funds -> funds
[INFO] Binder - Mapping joined-subclass: com.m_netd.businessobjects.Business -> business
[INFO] Binder - Mapping joined-subclass: com.m_netd.businessobjects.Commuting -> commuting
[INFO] Binder - Mapping joined-subclass: com.m_netd.businessobjects.OtherFunds -> other_funds
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/monthPay.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.MonthPay -> month_pay
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/monthWorkTime.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.MonthWorkTime -> monthwork_time
[INFO] Configuration - Mapping resource: com/m_netd/businessobjects/news.hbm.xml
[INFO] Binder - Mapping class: com.m_netd.businessobjects.News -> news
[INFO] Configuration - Configured SessionFactory: null
[INFO] Configuration - processing one-to-many association mappings
[INFO] Binder - Mapping collection: com.m_netd.businessobjects.Employee.monthPayList -> month_pay
[INFO] Binder - Mapping collection: com.m_netd.businessobjects.Employee.fundsList -> funds
[INFO] Binder - Mapping collection: com.m_netd.businessobjects.Employee.monthWorksList -> monthwork_time
[INFO] Binder - Mapping collection: com.m_netd.businessobjects.MonthWorkTime.deyWorkList -> deywork_time
[INFO] Configuration - processing one-to-one association property references
[INFO] Configuration - processing foreign key constraints
[WARN] SettingsFactory - No dialect set - using GenericDialect: Dialect class not found: org.hibernate.dialect.MySQLDialect
[INFO] Dialect - Using dialect: net.sf.hibernate.dialect.GenericDialect
[INFO] SettingsFactory - Use outer join fetching: true
[WARN] UserSuppliedConnectionProvider - No connection properties specified - the user must supply JDBC connections
[INFO] TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
[INFO] SettingsFactory - Use scrollable result sets: false
[INFO] SettingsFactory - Use JDBC3 getGeneratedKeys(): false
[INFO] SettingsFactory - Optimize cache for minimal puts: false
[INFO] SettingsFactory - echoing all SQL to stdout
[INFO] SettingsFactory - Query language substitutions: {}
[INFO] SettingsFactory - cache provider: net.sf.hibernate.cache.EhCacheProvider
[INFO] Configuration - instantiating and configuring caches
[INFO] SessionFactoryImpl - building session factory
[INFO] SessionFactoryObjectFactory - Not binding factory to JNDI, no JNDI name configured
error:java.lang.NullPointerException

2014/03/05 14:33:23 org.apache.coyote.http11.Http11BaseProtocol start
情報: Coyote HTTP/1.1を http-8080 で起動します
2014/03/05 14:33:23 org.apache.jk.common.ChannelSocket init
情報: JK: ajp13 listening on /0.0.0.0:8009
2014/03/05 14:33:23 org.apache.jk.server.JkMain start
情報: Jk running ID=0 time=0/47 config=null
2014/03/05 14:33:23 org.apache.catalina.storeconfig.StoreLoader load
情報: Find registry server-registry.xml at classpath resource
2014/03/05 14:33:23 org.apache.catalina.startup.Catalina start
情報: Server startup in 7688 ms

hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<session-factory>
<!---->
<property name="connection.datasouce">java:comp/env/jdbc/mnet</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>

<property name="hibernate.hbm2ddl.auto">create</property>
<property name="show_sql">true</property>

<mapping resource="com/m_netd/businessobjects/deyWorkTime.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/employee.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/funds.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/monthPay.hbm.xml" />
<mapping
resource="com/m_netd/businessobjects/monthWorkTime.hbm.xml" />
<mapping resource="com/m_netd/businessobjects/news.hbm.xml" />
</session-factory>
</hibernate-configuration>

tomcat 的context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>

<!-- Uncomment this to disable session persistence across Tomcat restarts -->
<!--
<Manager pathname="" />
-->
<Resource
name="jdbc/m-net"
auth="Container"
type="javax.sql.DataSource"
password="root"
username="root"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mnettest"
maxActive="100"
maxIdle="30"
maxWait="5000"
/>

</Context>
...全文
462 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lebronps 2016-01-19
  • 打赏
  • 举报
回复
数据库还没做吧,我现在也是这个提示,应该就是没有数据库的原因,或者数据库是空的
tony4geek 2014-03-05
  • 打赏
  • 举报
回复
那么session 应该有数据不是this.session = this.hibernateUtil.currentSession(); 这句报错吧。
etracer 2014-03-05
  • 打赏
  • 举报
回复
搞出来了,数据库没有表
tony4geek 2014-03-05
  • 打赏
  • 举报
回复
sessionFactory 未创建成功 。
abc130314 2014-03-05
  • 打赏
  • 举报
回复
web.xml 应该这样配吧
    <resource-ref>
        <res-ref-name>jdbc/m-net</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
        <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
etracer 2014-03-05
  • 打赏
  • 举报
回复
我该怎么办?是不是配置文件哪里错了??
etracer 2014-03-05
  • 打赏
  • 举报
回复
我debug了一下,在代码的这个位置 null this.session = this.hibernateUtil.currentSession(); ----------


public List<NewsView> getNewsView(){
		ArrayList<NewsView> newsList = new ArrayList<NewsView>();
		List newsObject;
		NewsView newsView;
		News news;
		try{
			this.session = this.hibernateUtil.currentSession();
			newsObject = this.session.find("from News");
			ListIterator iterator = newsObject.listIterator();
			while(iterator.hasNext()){
				newsView = new NewsView();
				news = (News)iterator.next();
				newsView.setId(news.getId());
				newsView.setDate(news.getDate());
				newsView.setSubstance(news.getSubstance());
				newsList.add(newsView);
			}
		}
		catch (HibernateException e) {
			System.out.println("error:" + e);
		}
		finally{
			this.hibernateUtil.closeSession();
		}
		return newsList;
	}
etracer 2014-03-05
  • 打赏
  • 举报
回复
引用 2 楼 rui888 的回复:
web.xml 里面配置没?
配置了,可是看了没有效果,给注释掉了,另外我把名称修改一致了还不行

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
	<display-name>m-net</display-name>
	<servlet>
		<servlet-name>action</servlet-name>
		<servlet-class>com.m_netd.framework.MnetActionServlet</servlet-class>
		<init-param>
			<param-name>config</param-name>
			<param-value>/WEB-INF/struts-config.xml</param-value>
		</init-param>
		<init-param>
			<param-name>mnet-service-employee-class</param-name>
			<param-value>com.m_netd.service.mnetService.MnetEmployeeService</param-value>
		</init-param>
		<init-param>
			<param-name>mnet-service-funds-class</param-name>
			<param-value>com.m_netd.service.mnetService.MnetFundsService</param-value>
		</init-param>
		<init-param>
			<param-name>mnet-service-news-class</param-name>
			<param-value>com.m_netd.service.mnetService.MnetNewsService</param-value>
		</init-param>
		<init-param>
			<param-name>mnet-service-pay-class</param-name>
			<param-value>com.m_netd.service.mnetService.MnetPayService</param-value>
		</init-param>
		<init-param>
			<param-name>mnet-service-workTime-class</param-name>
			<param-value>com.m_netd.service.mnetService.MnetWorkTimeService</param-value>
		</init-param>
		<!--  -->
		
		
		<load-on-startup>2</load-on-startup>
	</servlet>
	
	<!-- Standard Action Servlet Mapping -->
	<servlet-mapping>
		<servlet-name>action</servlet-name>
		<url-pattern>*.mnet</url-pattern>
  	</servlet-mapping>
  	
  	<filter>
  		<filter-name>SetCharacterEncoding</filter-name>
  		<filter-class>com.m_netd.framework.util.SetCharacterEncodingFilter</filter-class>
  	</filter>
  	<filter-mapping>
  		<filter-name>SetCharacterEncoding</filter-name>
  		<url-pattern>/*</url-pattern>
  	</filter-mapping>
    
 <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>security/logon.jsp</welcome-file>
  </welcome-file-list>

  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/WEB-INF/taglib/struts-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/taglib/struts-bean.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/taglib/struts-html.tld</taglib-uri>
    <taglib-location>/WEB-INF/taglib/struts-html.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/WEB-INF/taglib/struts-logic.tld</taglib-uri>
    <taglib-location>/WEB-INF/taglib/struts-logic.tld</taglib-location>
  </taglib>
  <!-- 
<Resource name="jdbc/m-net"   
auth="Container"  
type="javax.sql.DataSource"   
driverClassName="com.mysql.jdbc.Driver"  
url="jdbc:mysql://localhost:3306/mnettest"  
username="root"   
password="root"   
maxActive="5"  
maxIdle="2"   
maxWait="10000"/> 
 -->
</web-app>

tony4geek 2014-03-05
  • 打赏
  • 举报
回复
web.xml 里面配置没?
  • 打赏
  • 举报
回复
jdbc/mnet, name="jdbc/m-net" 名称不一致

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧