練功房推薦書單

  • 猛虎出柙雙劍合璧版--最新 OCA / OCP Java SE 7 Programmer 專業認證 (電子書)
  • 流浪教師存零股存到3000萬(全新增修版)(書+DVD)
  • 開始在關西自助旅行(京都‧大阪‧神戶‧奈良)(全新增訂版)
  • 不敗教主的300張股票存股術

Tomcat 5.5.16以上版本會出現cannot be resolved to a type的錯誤 RSS feed
討論區首頁 » Web/Application Server
發表人 內容
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 718
來自: 台北
離線
不知道有沒有人也遇到在Tomcat 5.5.15之前在某個子目錄下可以正常執行的程式,換到5.5.16以上新版的Tomcat後就會出現找不到一些類別的錯誤(如ParameterParser cannot be resolved to a type),但是在根目錄下有用到同樣類別的程式卻又可以正常執行,而且WEB-INF/classes或WEB-INF/lib目錄下確實也有該類別的class檔或包含該類別的jar檔。您該不會已經開始在想像電腦界也有一些靈異現象然後自己剛好倒楣碰上吧?參考這個問題的另一個說明
smiliehttp://www.javaworld.com.tw/jute/post/view?bid=9&id=182062&sty=1&tpg=1&age=0

有則Tomcat的Mailing list:Tomcat 5.5.16 Auto-Deploy Change Breaking Some WebApps大致說明了這個問題的成因,Tomcat開發團隊不知道是怎麼回事,自5.5.16版開始把所有根目錄下的子目錄都自動當成一個webapp,不管有沒有WEB-INF/web.xml,衝擊最大的就是如果先前您的網站是啟用虛擬主機,且有把功能依目錄分割,則升級將是一個令人跳腳的事。
另外也別期待Tomcat 5.5.17以後的版本會修正這個「你認為是個錯誤的新功能」。
smilie解決的方法:
如果可以的話,就是要把第一層的所有子目錄都加上WEB-INF下的相關檔案,不想這麼做的話,唯一的解法就是再降級回Tomcat 5.5.15以前的版本。雖然可能會有一些安全性的問題,但是也只能這麼辦了。底下是在Apache網站上找到的Tomcat 5.5.15版本,供大家下載使用。
http://archive.apache.org/dist/tomcat/tomcat-5/archive/v5.5.15/bin/apache-tomcat-5.5.15.tar.gz
http://archive.apache.org/dist/tomcat/tomcat-5/archive/v5.5.15/bin/apache-tomcat-5.5.15.zip

分享經驗 累積智慧
[WWW]
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 718
來自: 台北
離線
由於換回Tomcat 5.5.15後也有其他問題(例如OLAT跑不起來, javax.servlet.http.HttpSessionAttributeListener 的 attributeRemoved() 出現Session already invalidated), 故還是得繼續用新的Tomcat版本.
參考了大陸一位網友zhangxinzhou的文章
http://zhangxinzhou.blog.ccidnet.com/blog-htm-do-showone-uid-36421-type-blog-itemid-150874.html
把server.xml裡面Host的設定修改一下
例如原本的設定如下:

<Host name="www.ezmatch.tw"
appBase="webapps/www.ezmatch.tw"
unpackWARs="true" autoDeploy="true">
<Alias>ezmatch.tw</Alias>
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs/www.ezmatch.tw"
prefix="www.ezmatch.tw_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"/>
<Context path="" docBase="" debug="0" reloadable="false" />
</Host>

修改為:

<Host name="www.ezmatch.tw"
appBase=""
unpackWARs="true" autoDeploy="true">
<Alias>ezmatch.tw</Alias>
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs/www.ezmatch.tw"
prefix="www.ezmatch.tw_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"/>
<Context path="" docBase="webapps/www.ezmatch.tw" debug="0" reloadable="false" />
</Host>

這樣子就可以了.

分享經驗 累積智慧
[WWW]
andowson

七段學員
[Avatar]

註冊時間: 2007/1/2
文章: 718
來自: 台北
離線
今天在Tomcat 6.0.18上又遇到這個問題
The type javax.servlet.http.HttpSession cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.JspException cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.tagext.Tag cannot be resolved. It is indirectly referenced from required .class files
The type javax.servlet.jsp.JspApplicationContext cannot be resolved. It is indirectly referenced from required .class files
HttpSession cannot be resolved to a type
JspWriter cannot be resolved to a type
JspWriter cannot be resolved to a type
The type javax.servlet.jsp.JspContext cannot be resolved. It is indirectly referenced from required .class files
org.apache.jasper.runtime.PageContextImpl cannot be resolved to a type

後來找到這篇http://forums.sun.com/thread.jspa?threadID=708154
解法如下
修改Tomcat conf目錄下的 web.xml, 將
<init-param>

<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>

修改為

<init-param>
<param-name>fork</param-name>
<param-value>true</param-value>
</init-param>

然後重新起動Tomcat
這樣就OK了

分享經驗 累積智慧
[WWW]
 
討論區首頁 » Web/Application Server
前往:   
行動版