原来的图形工具sqlyogV3.5连不上它了,估计是驱动版本低了。另外,在java程序中原来用的mysqldriver.jar用不成了,去mysql网站下了一个mysql-connector-java-3.0.17-ga-bin.jar解决问题。
我是为测试在http://www.learndiary.com/disDiaryContentAction.do?goalID=1468中的java.sql.SQLException问题装它的。但是这个问题不是数据库的问题。是连接池属性文件的配置不适合mysql语法的原因。
java.lang.StackOverflowError错误
今天,在运行wiring your web application with open source java时,当提交一份订单后,老是出现java.lang.StackOverflowError错误,经过调试,发现问题出在SaveOrderAction.java中,
里面有一段代码如下:
order.setOrderLineItems(lineItems);
__log.debug("the order before save is: "+ order.getUserName()+"this order is:"+order);
// delegate the save to the service layer and further upstream
Order returnedOrder = getOrderService().saveNewOrder(order);
__log.debug("the user's name who placed returnedOrder is: "+ returnedOrder.getUserName()+"this order is:"+returnedOrder);
oForm.setOrder(order);
request.setAttribute("form",oForm);
//ActionErrors errors = new ActionErrors();
//errors.add(Globals.ERROR_KEY, new ActionError("message.order.saved.successfully"));
//saveErrors(request, errors);
__log.debug("the order after set into form is: "+ order.getUserName()+"this order is:"+order);
return mapping.findForward("success");
如果不注释掉上面3行,就会出现这个错误,真不知道是什么原因。报错信息如下:
“type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.StackOverflowError
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.
”
另外,如果把log4j配置成显示debug信息,控制台就会一直报告如下信息,不知是怎么一回事:
2006-01-06 22:40:21,564 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/01/00) - Connection #41 created to achieve minimum of 2 = AVAILABLE
2006-01-06 22:40:21,594 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/02/00) - Connection #42 created to achieve minimum of 2 = AVAILABLE
2006-01-06 22:40:51,618 DEBUG logicalcobwebs.proxool.spring:431 -> 000003 (00/01/00) - #0041 removed because it has problems: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values(current TimeStamp)' at line 1".
2006-01-06 22:40:51,628 DEBUG logicalcobwebs.proxool.spring:431 -> 000003 (00/00/00) - #0042 removed because it has problems: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values(current TimeStamp)' at line 1".
2006-01-06 22:40:51,638 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/01/00) - Connection #43 created to achieve minimum of 2 = AVAILABLE
2006-01-06 22:40:51,658 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/02/00) - Connection #44 created to achieve minimum of 2 = AVAILABLE
2006-01-06 22:41:00,661 INFO proxool.stats.spring:66 -> 22:40:00 - 22:41:00, s:0:0.00/s, r:0:0.00/s, a:0.00ms/0.00
2006-01-06 22:41:21,671 DEBUG logicalcobwebs.proxool.spring:431 -> 000003 (00/01/00) - #0043 removed because it has problems: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values(current TimeStamp)' at line 1".
2006-01-06 22:41:21,681 DEBUG logicalcobwebs.proxool.spring:431 -> 000003 (00/00/00) - #0044 removed because it has problems: java.sql.SQLException: Syntax error or access violation, message from server: "You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'values(current TimeStamp)' at line 1".
2006-01-06 22:41:21,711 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/01/00) - Connection #45 created to achieve minimum of 2 = AVAILABLE
2006-01-06 22:41:21,731 DEBUG logicalcobwebs.proxool.spring:181 -> 000003 (00/02/00) - Connection #46 created to achieve minimum of 2 = AVAILABLE
(java.sql.SQLException产生的原因是proxool.xml的配置问题:http://www.learndiary.com/disDiaryContentAction.do?goalID=1468)
我用的是tomcat5.0+mysql4.0.14
运行wiring your web application with...的问题
我用:struts1.1+spring1.2.6+hibernate2.1.8运行wiring your web application with open source java中碰到了如下问题:
1)、必须遵照作者在源码readme.txt的安装使用说明,尤其是组件版本号,否则就会出问题。
如:文中要求用 Hibernate 2.1.2,如果用hibernate2.1.8则会出现错误:HibernateException:Unable to locate config file:e:\\pro.xml。(见:HibernateException:Unable to locate config file:e:\\pro.xml (0篇) http://www.learndiary.com/disDiaryContentAction.do?searchDiaryID=1466&goalID=1466&naviStr=a10a2961)因为hibernate2.1.2支持绝对地址文件定位,而2.1.8是把这个文件放在classpath中寻找的,所以把源码中的:“applicationContext-hibernate.xml -
- <prop key="hibernate.proxool.xml">C:/MyWSADProjects/OnJavaCom/WebContent/WEB-INF/proxool.xml</prop>”
改为:“applicationContext-hibernate.xml -
- <prop key="hibernate.proxool.xml">proxool.xml</prop>”
再把“proxool.xml”放入WEB-INF/classes下面就行了;
在build.xml文件中要求用:ant1.5.3,我用eclipse2.1下的ant1.5.2出错。
还有就是源码中没有要求的用:xdolet如果是1.1的版本也不行,用最新的1.2.3解决问题;
2)、把log4j.jar和common-logging.jar(这个文件是否必须这样没有验证)加入系统的classpath,否则会在编译build.xml时说找不到log4j的类。这好像也可以在build.xml文件中指定。
3)、需要把build.xml中的下列内容改成你机器上的:
“ <property name="xdoclet.lib.home" value="c:/java_api/xdoclet-1.2/lib"/>
<property name="properties.dir" value="." />
<property name="hibernate.lib.home" value="C:/java_api/hibernate-2.1/lib"/>
<property name="war.webinf.home" value="C:/MyWSADProjects/OnJavaCom/WebContent/WEB-INF"/>
<property name="mysql.lib.home" value="C:/java_api/mysql-connector-java-2.0.14"/>
<property name="db2.lib.home" value="C:/java_api/db2java"/>
”
另外,如果你不用db2数据库,就把build.xml中关于db2的东西去掉。否则会出错。
4)、数据库(mysql)需要先在数据库中把库建起再用build.xml脚本创建表。
5)、怀疑是作者的笔误,在web.xml文件中的“<param-value>WEB-INF/struts-config.xml</param-value>”应该是“<param-value>WEB-INF/struts-config.xml</param-value>”,否则在我的tomcat5.0下就会报错,但是不知在其它容器中如何?
6)、还有就是要把每个开源项目的包完整的拷到你的应用程序的lib中,比如:spring就要把它所有的在lib下的第三方支持包全部拷入你的应用程序的lib中。做这些事不要怕有冗余的文件,java的运行机制是要用的时候再去创建类的实例。多些文件只是占点硬盘空间而已。
我觉得有必要好好的找一找这些错误出现的真正原因。
HibernateException:Unable to locate config file:e:\\pro.xml
在运行:wiring your web application with open source java时,如果不按照说明中的用hibernate2.1.2,比如:用2.1.8,就会出现文中的问题。
转帖:转自:http://spring.jactiongroup.net/viewtopic.php?t=940&highlight=.HibernateException%3A+Unable+to+locate+config+file
--------------------------------------------------------------------------------
软件环境:
struts+hibernate+spring
配置文件:
/WEB-INF/web.xml
引用:
..................
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-hibernate.xml
</param-value>
</context-param>
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
.............
/WEB-INF/applicationContext-hibernate.xml
引用:
<beans>
<!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= -->
<!-- Choose the dialect that matches your "dataSource" definition -->
<bean id="mySessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>com/hibernate/po/TbQueue.hbm.xml</value>
<value>com/hibernate/po/TMsgHistory.hbm.xml</value>
<value>com/hibernate/po/TbHistory.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">net.sf.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="connection.useUnicode">true</prop>
<prop key="connection.characterEncoding">GBK</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.proxool.xml">e:\\pro.xml</prop>
<prop key="hibernate.proxool.pool_alias">spring</prop>
</props>
</property>
</bean>
<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="myTransactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>
<!-- Add more services here -->
<!-- CommonService-->
<bean id="commonService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="myTransactionManager"/></property>
<property name="target"><ref local="commonServiceTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly,-DataAccessException</prop>
<prop key="save*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="del*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="update*">PROPAGATION_REQUIRED,-DataAccessException</prop>
<prop key="list*">PROPAGATION_REQUIRED,-DataAccessException</prop>
</props>
</property>
</bean>
<bean id="commonServiceTarget" class="org.common.spring.CommonServiceImpl">
<property name="hibernateDAO"><ref local="hibernateDAO"/></property>
</bean>
<!-- DAO定义区 -->
<bean id="hibernateDAO" class="org.common.hibernate.HibernateDAOImpl">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>
</beans>
e:\pro.xml
引用:
<proxool>
<alias>spring</alias>
<driver-url>jdbc:jtds:sqlserver://127.0.0.1/test;TDS=8.0</driver-url>
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="sa" />
<property name="password" value="" />
</driver-properties>
<minimum-connection-count>2</minimum-connection-count>
<maximum-connection-count>20</maximum-connection-count>
<maximum-connection-lifetime>18000000</maximum-connection-lifetime> <!-- 5 hours -->
<house-keeping-test-sql>values(current TimeStamp)</house-keeping-test-sql>
<statistics>1m,15m,1d</statistics>
<statistics-log-level>INFO</statistics-log-level>
<fatal-sql-exception>Connection is closed,SQLSTATE=08003,Error opening socket. SQLSTATE=08S01,SQLSTATE=08S01</fatal-sql-exception>
<fatal-sql-exception-wrapper-class>org.logicalcobwebs.proxool.FatalRuntimeException</fatal-sql-exception-wrapper-class>
<verbose>false</verbose>
</proxool>
BaseAction.java
引用:
public abstract class BaseAction extends org.apache.struts.action.Action {
private CommonService commonService;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
WebApplicationContext wac = WebApplicationContextUtils
.getRequiredWebApplicationContext(servletContext);
this.commonService=(CommonService)wac.getBean("commonService");
}
public CommonService getCommonService() {
return commonService;
}
}
在服务器启动时报错,信息如下:
引用:
信息: Installing web application at context path /phoneMsg from URL file:F:\tomcat\webapps\phoneMsg
2004-10-26 18:29:19,750 FATAL net.sf.hibernate.util.ConfigHelper - Unable to locate config file: e:\\pro.xml
2004-10-26 18:29:19,781 ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mySessionFactory' defined in resource [/WEB-INF/applicationContext-hibernate.xml] of ServletContext: Initialization of bean failed; nested exception is net.sf.hibernate.HibernateException: Unable to locate config file: e:\\pro.xml
net.sf.hibernate.HibernateException: Unable to locate config file: e:\\pro.xml
at net.sf.hibernate.util.ConfigHelper.getConfigStream(ConfigHelper.java:83)
at net.sf.hibernate.util.ConfigHelper.getConfigStreamReader(ConfigHelper.java:104)
at net.sf.hibernate.connection.ProxoolConnectionProvider.configure(ProxoolConnectionProvider.java:122)
at net.sf.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:83)
at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:65)
at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1155)
pro.xml的确在E盘啊???
返回页首
chinalyc
spring 爱好者
注册时间: 2004-02-16
帖子: 6
来自: 北京
发表于: Fri Nov 05, 2004 9:45 am 发表主题:
--------------------------------------------------------------------------------
在net.sf.hibernate.util.ConfigHelper类中它是这样取先取一个文件的url。
代码:
final URL url = ConfigHelper.locateConfig(path);
public static final URL locateConfig(final String path) {
try {
return new URL(path);
}
catch(MalformedURLException e) {
return findAsResource(path);
}
}
public static final URL findAsResource(final String path) {
URL url = null;
// First, try to locate this resource through the current
// context classloader.
url = Thread.currentThread().getContextClassLoader().getResource(path);
if (url != null)
return url;
// Next, try to locate this resource through this class's classloader
url = ConfigHelper.class.getClassLoader().getResource(path);
if (url != null)
return url;
// Next, try to locate this resource through the system classloader
url = ClassLoader.getSystemClassLoader().getResource(path);
// Anywhere else we should look?
return url;
}
你还是把这个文件放在classes目录吧
幼儿是没有时间观念的
孩子他妈妈刚刚说明天去给她买牛奶,她马上就要牛奶了。对她来说,买牛奶就是现在就要有牛奶了。她分不清现在买和明天买的区别。这好象也是哪本书上说的。
所以,避免向小孩子许诺什么:下周、明年、你过生日怎么怎么。。。,她连明天都等不得,何况那么远的许诺。
生活的快乐更多的是去发现
生活的快乐不应该一味的追求。应该发现生活中本来就有的快乐。
今天,在花店经过,闻见腊梅很香,心有所动,破天荒的买了一束回家。用一个花瓶插上,摆在家里。
追求快乐是无止境的,而发现快乐也是无止境的。我们是以发现快乐为主还是以追求快乐为主,这也许就是人生能否快乐的分水岭?
不能要求孩子太严格了
吃零食,像大人有时都难免。更何况孩子。孩子需要快乐,而吃零食是她的快乐很大的一部分。所以,如果全信书,不能给孩子吃零食,那也未必对孩子太残忍了。
所以,适当的零食应是孩子的权利。当然,食物还是应该以一日三餐为主的。
幼儿无错论
孩子的一切都是出自自心,看到吃的东西就想吃,看到自认为有趣的东西就想玩。至于吃不吃得,玩不玩得,只有大人替她考虑了。
再译:wiring your web application...中的难点、疑点
1、Building non-trivial web applications with Java is no trivial task.
2、where the business logic will reside
3、how to enforce a consistent design across all application layers
4、Each application layer should be isolated from other layers but allow an interface for communication between them.
5、Assembling a model that can be presented in a view.
6、 type coupling
7、“allow”的使用: In particular, the Hibernate framework allows object-to-relational persistence and query service for Java.
8、This is not the correct place because it leads to tightly coupled applications and code that can be hard to maintain over time.
9、“allow”的使用:This layer allows developers to stop building and maintaining unnecessary data transfer objects, or DTOs, to match their domain objects.
10,,This model allows Java developers to work with objects naturally in an OO fashion without additional coding.
11. allows for easier maintenance when troubleshooting
12.Inversion of control is a simple concept that allows objects to accept other objects that are created at a higher level.
13.Since Hibernate works with POJOs we will use our domain objects for persistence.
14.Here is the interface for the business service object that is stubbed for a DAO object dependency
没有目标的标题有点伤感
只是用于一篇日记暂时没有合适的目标。但是应该改一个名字。