說實話,這個問題弄了我2個多小時...??
環境:ObjectWeb Lomboz for JavaEE Development ?Version: 3.1.2??? JDK1.6 BETA
問題:100%沒問題的JSP編譯始終報錯 甚至我感覺他更本就沒有編譯
信息:Syntax error on token(s), misplaced construct(s)?
???????????? Syntax error on tokens, delete these tokens
ObjectWeb Lomboz for JavaEE Development ?Version: 3.1.2?加了tomcat插件進來后的確遇到過很多奇怪的問題。比如 Run on server?的時候提示“no launchable artifact??could be found”。到google去搜索。見了有一個朋友Email給官方,尋找問題的原因。有一段回復見下:
I suspect that you are having this problem because you have not placed the login.jsp page someplace inside the WebContent folder.
Unfortunately this message is being thrown from the class org.eclipse.wst.server.ui.internal.actions.RunOnServerActionDelegate and I am unable to provide a more meaningful message.?? You may want to file a bug against the wst.server component on this.
看到這里,差點就放棄了這個玩意。不得行,弄不好 始終睡不著。
在IDE里面找了一個多小時原因,(夠傻的吧)。干脆跑下頁面看有沒有更詳細的信息
果然收獲了一堆信息:Syntax error on token(s), misplaced construct(s)? Syntax error on tokens, delete these tokens
再到Google查詢。搜索結果很少,幸運,至少還有遇到過這個問題的
他提供了SUN官方網站的說明:
Without?this?step,?the?JSP?servlet?uses?the?JDT?compiler,?and?will?seemingly?ignore?most?of?the?options?in?the?web.xml?configuration?file.
Once?you?change?these?jar?files,?you?should?be?using?the?javac?compiler,?but?the?JSP?servlet?will?still?be?invoking?it?in?1.3?mode.
Now,?update?your?<catalina_home>/conf/web.xml?file?so?that?the?JSP?servlet?invokes?the?javac?compiler?to?expect?Java?1.5?constructs,?and?to?generate?Java?1.5?output.?Do?this?by?adding?the?init-params?compilerSourceVM?and?compilerTargetVM,?both?with?values?of?1.5.
The?JSP?servlet?section?of?web.xml?should?look?like?this:
原來是tomcat編譯器的問題。NND的估計他默認是1.4版本的
解決辦法:
1)http://ant.apache.org/bindownload.cgi下?ant.zip?的包?然后把里邊的?ant.jar?復制到 /common/lib
2)刪除 /common/lib/jasper-compiler-jdt.jar
3)找到Tomcat 5.5\conf 這個目錄下的web.xml? 里面有一段:
?????? <servlet>
??????? <servlet-name>jsp</servlet-name>
??????? <servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
??????? <init-param>
??????????? <param-name>fork</param-name>
??????????? <param-value>false</param-value>
??????? </init-param>
??????? <init-param>
??????????? <param-name>xpoweredBy</param-name>
??????????? <param-value>false</param-value>
??????? </init-param>
??????? <load-on-startup>3</load-on-startup>
??? ?</servlet>
4)?? 把這段注釋掉 改成下面這段。 注意我寫的是1.6。如果你是1.5的話可以嘗試改成1.5
??????<servlet>
??????<servlet-name>jsp</servlet-name>
??????<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
??????<init-param>
??????<param-name>fork</param-name>
??????<param-value>false</param-value>
??????</init-param>
??????<init-param>
??????<param-name>xpoweredBy</param-name>
??????<param-value>false</param-value>
??????</init-param>
??????<init-param>
??????<param-name>compilerSourceVM</param-name>
??????<param-value>1.6</param-value>
??????</init-param>
??????<init-param>
??????<param-name>compilerTargetVM</param-name>
??????<param-value>1.6</param-value>
??????</init-param>
??????<load-on-startup>3</load-on-startup>
??????</servlet>
??? ?剛修改完, 這回的確能編譯了。又出來一個問題。頁面是亂碼了。亂碼到是小問題?原理簡單
???? 控制臺提示[錯誤:讀取 D:\java\jdk1.6\jre\lib\ext\localedata.pack 時出錯;error in opening zip file] 我也不清楚這個文件里面到底寫的什么。SUN的官方有相關的BUG報告 ID: 6353586? 把他改成.rar后居然正常了。看來他的作用也不大。不過鑒于它和JDK的關系,還是沒忍心干掉他
?????NND這幾天遇到的怪問題多得很。都沒時間一一寫下來
???? 經過兩次改造,感覺已經挖干了這只貓的“五臟六腑” 不過他還挺能折騰的
???? 2006-03-19? Goingmm?