Remote debugging Tomcat with Eclipse

May 11th, 2012 No comments

http://en.newinstance.it/2005/10/04/remote-debugging-tomcat-with-eclipse/

Remote debugging Tomcat with Eclipse
16 Comments Published October 4th, 2005 in Eclipse, Java, Web
Tags: .
Today I tried to use remote debugging with Eclipse and Tomcat.
I usually use a Tomcat Sysdeo Plugin to run Tomcat inside Eclipse, but today I faced remote debugging.
To run tomcat in remote debugging you can start it with command
catalina jpda start

But this will start remote debugging using shared memory, and Eclipse, as far as I know, does not support shared memory as transport for deubugging.
The alternative is to use a socket as transport for JPDA.
You simply set some enviroment variable that will be checked by catalina startup script, as in following example:

set JPDA_TRANSPORT=dt_socket
set JPDA_ADDRESS=5050
… then you can run …
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run
…or…
D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda start
This tells catalina script to use socket transport for debugging and to listen on port 5050. If you don’t specify the port, it will be assigned randomly.
When you start tomcat, you’ll see some messages on console saying that debugging socket is listening:

D:\Java\jakarta-tomcat-5.5.7\bin>catalina jpda run
Using CATALINA_BASE: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_HOME: D:\Java\jakarta-tomcat-5.5.7
Using CATALINA_TMPDIR: D:\Java\jakarta-tomcat-5.5.7\temp
Using JAVA_HOME: d:\Java\jdk1.5.0_04
Listening for transport dt_socket at address: 5050
4-ott-2005 18.26.11 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
4-ott-2005 18.26.11 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1162 ms
4-ott-2005 18.26.11 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
4-ott-2005 18.26.11 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.7
4-ott-2005 18.26.11 org.apache.catalina.core.StandardHost start
Now it’s time to connect to that socket using Eclipse: see following picture.

On “Connection Properties” you can configure a remote VM that you want to debug. Then place your breakpoints and run the shown launch configuration.
Shared memory is easier to be used: with tomcat you don’t have to set up environment variables, and for IDE supporting it (I used this with IntelliJ), you only need to specify the name of the shared space. This won’t work if the VM to debug is on a remote computer but can be helpful anyway. I tried to find shared memory support in Eclipse but I didn’ find it, and I believe it doesn’t have.
Remote debugging is more useful when you have to attach to a running instance on a remote server on which the bug is alive. Shared memory support lack is not that problem.

One thing that you cannot do running programs inside Eclipse under Windows is to get a Thread dump. On Windows you can get a Thread Dump pressing CTRL+Break in the DOS console, but this doesn’t work on Eclipse console. On Linux you can use “kill -3″, and I think this work even running processes in Eclipse. Maybe it’s possible also in Windows, using some esotic tool, but I don’ know… also I don’t know if Windows supports several kill signals.

Categories: Java, 互联网, 互联网后端 Tags:

svn error :Delta Source Ended Unexpectedly

May 2nd, 2012 No comments

Easy fix for “SVN: Delta Source Ended Unexpectedly” Error

I tried to update one of my subversion working copies today and got the following message:
“Delta source ended unexpectedly”

Here’s how I solved the problem:
Step 1: I identified the file that was causing the problem.
Step 2: I made sure that all changed files in the problem file’s directory were committed to the repository.
Step 3: I deleted the problem file’s directory from my working copy (not the repository!)
Step 4: I updated my entire working copy

Easy! I spent around half an hour searching for an answer and reading through several message board threads on the topic. The fix took me about three minutes to complete. Hope this is helpful for someone.” Error

Categories: Java, 互联网 Tags:

Introducing JSON

April 9th, 2012 No comments

1.what is json?
json is javascript object notation.
2.what is json define?
please click link to view detail:http://www.json.org/index.html
3.example

{
“glossary”: {
“title”: “example glossary”,
“GlossDiv”: {
“title”: “S”,
“GlossList”: {
“GlossEntry”: {
“ID”: “SGML”,
“SortAs”: “SGML”,
“GlossTerm”: “Standard Generalized Markup Language”,
“Acronym”: “SGML”,
“Abbrev”: “ISO 8879:1986″,
“GlossDef”: {
“para”: “A meta-markup language, used to create markup languages such as DocBook.”,
“GlossSeeAlso”: ["GML", "XML"]
},
“GlossSee”: “markup”
}
}
}
}
}
The same text expressed as XML:






Standard Generalized Markup Language
SGML
ISO 8879:1986

A meta-markup language, used to create markup
languages such as DocBook.








{“menu”: {
“id”: “file”,
“value”: “File”,
“popup”: {
“menuitem”: [
{"value": "New", "onclick": "CreateNewDoc()"},
{"value": "Open", "onclick": "OpenDoc()"},
{"value": "Close", "onclick": "CloseDoc()"}
]
}
}}
The same text expressed as XML:

{“widget”: {
“debug”: “on”,
“window”: {
“title”: “Sample Konfabulator Widget”,
“name”: “main_window”,
“width”: 500,
“height”: 500
},
“image”: {
“src”: “Images/Sun.png”,
“name”: “sun1″,
“hOffset”: 250,
“vOffset”: 250,
“alignment”: “center”
},
“text”: {
“data”: “Click Here”,
“size”: 36,
“style”: “bold”,
“name”: “text1″,
“hOffset”: 250,
“vOffset”: 100,
“alignment”: “center”,
“onMouseUp”: “sun1.opacity = (sun1.opacity / 100) * 90;”
}
}}
The same text expressed as XML:


on

main_window
500
500


250
250
center


text1
250
100
center

sun1.opacity = (sun1.opacity / 100) * 90;



{“web-app”: {
“servlet”: [
{
"servlet-name": "cofaxCDS",
"servlet-class": "org.cofax.cds.CDSServlet",
"init-param": {
"configGlossary:installationAt": "Philadelphia, PA",
"configGlossary:adminEmail": "ksm@pobox.com",
"configGlossary:poweredBy": "Cofax",
"configGlossary:poweredByIcon": "/images/cofax.gif",
"configGlossary:staticPath": "/content/static",
"templateProcessorClass": "org.cofax.WysiwygTemplate",
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
"templatePath": "templates",
"templateOverridePath": "",
"defaultListTemplate": "listTemplate.htm",
"defaultFileTemplate": "articleTemplate.htm",
"useJSP": false,
"jspListTemplate": "listTemplate.jsp",
"jspFileTemplate": "articleTemplate.jsp",
"cachePackageTagsTrack": 200,
"cachePackageTagsStore": 200,
"cachePackageTagsRefresh": 60,
"cacheTemplatesTrack": 100,
"cacheTemplatesStore": 50,
"cacheTemplatesRefresh": 15,
"cachePagesTrack": 200,
"cachePagesStore": 100,
"cachePagesRefresh": 10,
"cachePagesDirtyRead": 10,
"searchEngineListTemplate": "forSearchEnginesList.htm",
"searchEngineFileTemplate": "forSearchEngines.htm",
"searchEngineRobotsDb": "WEB-INF/robots.db",
"useDataStore": true,
"dataStoreClass": "org.cofax.SqlDataStore",
"redirectionClass": "org.cofax.SqlRedirection",
"dataStoreName": "cofax",
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
"dataStoreUser": "sa",
"dataStorePassword": "dataStoreTestQuery",
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
"dataStoreInitConns": 10,
"dataStoreMaxConns": 100,
"dataStoreConnUsageLimit": 100,
"dataStoreLogLevel": "debug",
"maxUrlLength": 500}},
{
"servlet-name": "cofaxEmail",
"servlet-class": "org.cofax.cds.EmailServlet",
"init-param": {
"mailHost": "mail1",
"mailHostOverride": "mail2"}},
{
"servlet-name": "cofaxAdmin",
"servlet-class": "org.cofax.cds.AdminServlet"},

{
"servlet-name": "fileServlet",
"servlet-class": "org.cofax.cds.FileServlet"},
{
"servlet-name": "cofaxTools",
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
"init-param": {
"templatePath": "toolstemplates/",
"log": 1,
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
"logMaxSize": "",
"dataLog": 1,
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
"dataLogMaxSize": "",
"removePageCache": "/content/admin/remove?cache=pages&id=",
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
"lookInContext": 1,
"adminGroupID": 4,
"betaServer": true}}],
“servlet-mapping”: {
“cofaxCDS”: “/”,
“cofaxEmail”: “/cofaxutil/aemail/*”,
“cofaxAdmin”: “/admin/*”,
“fileServlet”: “/static/*”,
“cofaxTools”: “/tools/*”},

“taglib”: {
“taglib-uri”: “cofax.tld”,
“taglib-location”: “/WEB-INF/tlds/cofax.tld”}}}
The same file expressed as XML:

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">



cofaxCDS


org.cofax.cds.CDSServlet

configGlossary:installationAt Philadelphia, PA

configGlossary:adminEmail ksm@pobox.com

configGlossary:poweredBy Cofax

configGlossary:poweredByIcon /images/cofax.gif

configGlossary:staticPath /content/static

templateProcessorClass org.cofax.WysiwygTemplate

templateLoaderClass org.cofax.FilesTemplateLoader

templatePath templates

templateOverridePath

defaultListTemplate listTemplate.htm

defaultFileTemplate articleTemplate.htm

useJSP false

jspListTemplate listTemplate.jsp

jspFileTemplate articleTemplate.jsp

cachePackageTagsTrack 200

cachePackageTagsStore 200

cachePackageTagsRefresh 60

cacheTemplatesTrack 100

cacheTemplatesStore 50

cacheTemplatesRefresh 15

cachePagesTrack 200

cachePagesStore 100

cachePagesRefresh 10

cachePagesDirtyRead 10

searchEngineListTemplate forSearchEnginesList.htm

searchEngineFileTemplate forSearchEngines.htm

searchEngineRobotsDb WEB-INF/robots.db

useDataStore true

dataStoreClass org.cofax.SqlDataStore

redirectionClass org.cofax.SqlRedirection

dataStoreName cofax

dataStoreDriver com.microsoft.jdbc.sqlserver.SQLServerDriver

dataStoreUrl jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon

dataStoreUser sa

dataStorePassword

dataStoreTestQuery SET NOCOUNT ON;select test=’test’;

dataStoreLogFile /usr/local/tomcat/logs/datastore.log

dataStoreInitConns 10

dataStoreMaxConns 100

dataStoreConnUsageLimit 100

dataStoreLogLevel debug

maxUrlLength 500



cofaxEmail


org.cofax.cds.EmailServlet

mailHost mail1

mailHostOverride mail2



cofaxAdmin


org.cofax.cds.AdminServlet



fileServlet


org.cofax.cds.FileServlet



cofaxTools


org.cofax.cms.CofaxToolsServlet

templatePath toolstemplates/

log 1

logLocation /usr/local/tomcat/logs/CofaxTools.log

logMaxSize

dataLog 1

dataLogLocation /usr/local/tomcat/logs/dataLog.log

dataLogMaxSize

removePageCache /content/admin/remove?cache=pages&id=

removeTemplateCache /content/admin/remove?cache=templates&id=

fileTransferFolder /usr/local/tomcat/webapps/content/fileTransferFolder

lookInContext 1

adminGroupID 4

betaServer true



cofaxCDS


/



cofaxEmail


/cofaxutil/aemail/*



cofaxAdmin


/admin/*



fileServlet


/static/*



cofaxTools


/tools/*


cofax.tld
/WEB-INF/tlds/cofax.tld


The action and label values only need to be provided if they are not the same as the id.

{“menu”: {
“header”: “SVG Viewer”,
“items”: [
{"id": "Open"},
{"id": "OpenNew", "label": "Open New"},
null,
{"id": "ZoomIn", "label": "Zoom In"},
{"id": "ZoomOut", "label": "Zoom Out"},
{"id": "OriginalView", "label": "Original View"},
null,
{"id": "Quality"},
{"id": "Pause"},
{"id": "Mute"},
null,
{"id": "Find", "label": "Find..."},
{"id": "FindAgain", "label": "Find Again"},
{"id": "Copy"},
{"id": "CopyAgain", "label": "Copy Again"},
{"id": "CopySVG", "label": "Copy SVG"},
{"id": "ViewSVG", "label": "View SVG"},
{"id": "ViewSource", "label": "View Source"},
{"id": "SaveAs", "label": "Save As"},
null,
{"id": "Help"},
{"id": "About", "label": "About Adobe CVG Viewer..."}
]
}}
The same message expressed as XML:

Adobe SVG Viewer

Open
Open New

Zoom In
Zoom Out
Original View

Quality
Pause
Mute

Find…
Find Again
Copy
Copy Again
Copy SVG
View SVG
View Source
Save As

Help
About Adobe CVG Viewer…

Categories: 互联网, 前端技术 Tags:

最近的最近

March 6th, 2012 No comments

想写点东西,来纪念这段日子。

这段日子主旋律是换一份工作。

我的目标:找一份具有挑战和成长的工作,找一家大型的公司,具体岗位是搜索引擎开发工程师。

我2月15日 请假去面试了4家公司,第一家上午9点,zhengbaoyuanchengjiaoyujituan,java开发,做完面试题,发现时间已经10点,面试官才到不多久,前面有2个人在等着面试,我果断跟前台说,我改天再来参加面试,直奔第二家公司,zhonghulian,他们是想做一个电商系统,基于一个国外开源php系统做的,但是大部分已经做好,基本只要维护即可,显然我们并不合适。下午到一家叫**的公司,他跟我谈了半天,告诉我,我的搜索经验来自小公司的自学,这实力与我的期望待遇之间形成很大的差距,他说不可能,给不起我的待遇,这样不欢而散。接着到sina leju,这是一家上市公司,里面给人感觉很正式,也让我来北京这么久后,终于感受到了白领是什么样子,可惜他们招聘php,而我对php了解不够多,主动放弃了这个机会。

接下来的几天,我把简历放在中华英才网上,电话邮件来自四面八方的,我偶尔接接电话,回回邮件。期间和我们boss聊了打算辞职的事,中间他跟我讲了很多东西,只是我想我再也不能在这里****,所以boss几经挽留,我都婉辞拒绝了。毕竟在公司这么久,经理给了很宽的条件,你可以去外面看发展机会,有的话,你选择走,没有的话,留在公司发展。我当时说不出什么感觉。

接下来的一周,我前四天请假了,每天安排2场面试。也算挺忙的。周一上午suishichuanmei的java爬虫类的工作,笔试、技术面试、人力面试、老板面试后,回家等通知(那个周五,给我offer了,但没去成)。下午来到ruiankeji,这公司的笔试题出奇的简单,先通过技术笔试,技术面试,智力笔试,然后是人事面试,人事没说几句,谈了下薪资期望,回家等通知。

周二到上午58tongcheng参加面试,和面试官聊得还可以,但是他让写一个数组合并的程序,一时没想出来,后面用了一个很笨的方法,最后也是等通知。(一直没音讯)
下午到yingruili公司,很多人面试,能够感觉出来公司近期有大型项目要开发,从面试题来看,偏向java swing.未进入面试,直接回家等通知。(今天接到复试电话,我说没兴趣了)

周三上午 cc shipin 笔试,面试,面试官是一个搜索引擎的博士,能够感觉出他的博学和睿智,可惜公司要招的人是要做云计算,而我是一心想要做搜索开发,也只好作罢。
下午到messagesolution面试搜索开发,笔试题做完,面试人跟我简单的聊了会,说今天我们做搜索的同事没来,让我明天再去一趟,我说好。

周四上午tengruiwanli,笔试后,技术面试,原本公司是找java开发,不招搜索开发的人员,但是公司也安排了搜索开发工程师来面试了我,跟那位工程师聊的其实并不顺畅,他一心就把lucene和数据库做对比,而我恰好没有研究二者的区别,但是幸好他们还有一个经理在场,经理也看着我们的聊天,在这之间我可能表露出来比较好的学习力和思考方式,他比较看好我,但是可笑的是,公司搜索确实不需要人手了,后面估计是一个boss级的人物来和我讲了公司的业务和人员安排,搜索这块实在不行了,但是公司还有底层开发和日志统计分析2块业务,可以随我选一个。我觉得我是一个比较理想的人,认为时间还充足,我要找一份搜索引擎的工作。最后留了对方的联系方式,说2周后,要是没有合适的工作,我们再谈谈。(今天再次接到电话去复试,暂定明天去看看)
下午到messagesolution 第一轮复试,是一个java搜索领域里做了3年以上的年轻工程师,我们聊天聊得很痛快,我也把我的心里话跟他说了,最后的结论是 担心我的稳定性。他把情况给上报老板后,让老板决定。(最后因为行业不一样,老板告知不合适)

周五回到公司,把辞职相关的事宜办妥,boss说 周六还过去一下,因而周六也去公司呆到下午,最后走时,我和boss两眼相对,我情不自禁流泪了,为了不让他看见,我迅速走进电梯,关门走了,但是回家的路上,回想这一年多的一幕幕,眼泪最终还是流了。

既然离职了,那么就安心在家里找工作呗。

去wensi面试了一下,原本没打算去外包、外派工作的,但是wensi说这不是外包,是公司内部职位,去面试了一下,结果还感觉不错,面试官很友善,据说还要参加美国那边的E文复试,我想想也只要硬着头皮上了。(无心插柳柳成荫)

后面到sohu面试了一下,sohu面试真让我伤心,我觉得根本就没有正常表达出我的水平。当然面试官问得问题也趋向对细节提问,所以。。。。。还是等通知。。。

今天上午去wensi参加E文复试,我准备了好几天的英文资料基本派不上用场,美国人问的线程问题,问的我压根就不知道是什么?同步方法和同步块的信号灯有啥区别?我实在是不知道,信号灯是啥,我都不是很清楚。美国人有一个习惯,就是他们研究一个问题研究的比较深,他问得多线程,问到最后我可以说完全答不上来。后面又问了几个简单的技术问题,还好搞定了,面试完技术题后,面试智力题,第一个等比数列求和公式的推导,第二个,8个球有一个轻点的,用一个天平,称最少多少次可以找出请求,找出后,请给出数学模型或数学推导公式,三、三个灯,三个开关,两个房间,一次进房间看灯的机会,找出灯的对应关系。当然最后还是等通知哦。。。

总结一下最近面试的一个经验:
1、基础真的很重要,一般人眼高手低,一个很基础的问题搞不定,会影响自己的自信,到时候兵败如山倒,大势去矣;
2、笔试题一定要做好,这也是看基础和态度的,只有当笔试题做得比较好时,技术面试官,才更有兴趣和你聊;
3、技术面试,讲自己做了什么,怎样做的,碰到面试官的提问,回答时重点讲思路,体现你的思想、领悟力、学习力,学习力公司很看重的,讲完思路要讲一些实际开发例子,以佐证你说的不是空谈或纸上谈兵;
4、人事面试,基本谈薪水,说出自己合适的期望薪资就好了,还有辞职原因,实话实说吧;
5、老板如果要面试你,此时要海阔天空的谈,谈理想,谈人生,谈给公司带来价值,给职业规划,谈愿意和公司一起成长,谈自己的优势。

最最重要的还是,平时积累,不要放弃平常开发过程中碰到任何问题,日积月累,那么别人很easy知道你是一个富有经验和智慧的员工。

真的有点怕找工作了,太难等了。。。。

Categories: About Me, 互联网, 工作, 生活 Tags:

什么最重要

February 16th, 2012 No comments

解决问题的能力最重要!

Categories: About Me Tags:

有人跟我说 自学 很难达到一流水平

February 16th, 2012 No comments

业务 都是需求驱动的,没有需求驱动,去研究某项技术,那么会显得很苍白无力,凭着一些简单的兴趣支持,但很难达到一流水平,因为人的成长,与人交流很重要。

Categories: 生活 Tags:

矛盾的我

February 14th, 2012 No comments

一个矛盾的人,既爱中国传统文化,又走时代前沿。

从事互联网行业,热爱Unix/linux所倡导的自由、简单风格。

Categories: About Me Tags:

专精

February 11th, 2012 No comments

专精

Categories: 工作 Tags:

linux crontab date %

December 22nd, 2011 1 comment

% 是crontab 命令中换行标记

在date命令中 %是格式化时间的语法 如运行, date +%Y-%m-%d 输出:2011-12-22

那么在crontab中要设置定时任务时,如需用到 date命令的% ,那么需要转义。

示例:

*/2 * * * * cd /opt/lampp/htdocs/order && /opt/lampp/bin/php cron.php >>info.$(date +\%Y-\%m-\%d).log 2>&1

如果不转义,那么linux用户邮箱将收到报错邮件。

Categories: shell, Unix/Linux, 互联网 Tags:

load an apache log file into mysql

December 1st, 2011 No comments

There are programs that let you authenticate your users from a MySQL database and also let you write your log files into a MySQL table.

You can change the Apache logging format to be easily readable by MySQL by putting the following into the Apache configuration file:

LogFormat \
“\”%h\”,%{%Y%m%d%H%M%S}t,%>s,\”%b\”,\”%{Content-Type}o\”, \
\”%U\”,\”%{Referer}i\”,\”%{User-Agent}i\”"
To load a log file in that format into MySQL, you can use a statement something like this:

LOAD DATA INFILE ‘/local/access_log’ INTO TABLE tbl_name
FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”‘ ESCAPED BY ‘\\’
The named table should be created to have columns that correspond to those that the LogFormat line writes to the log file.

Categories: mysql, 互联网, 数据库 Tags: