2017-02-25 147 views
0

我正在使用Murach的Java Servlets和JSP中的指示信息:3rd Ed。教科書在我的Mac上設置Netbeans,Tomcat和MySQL。除了運行Tomcat之外,一切都可以運行我嘗試了所有我能找到的相關解決方案(更改端口號,檢查localhost:8080,重新啓動等),但我仍然收到類似這樣的錯誤消息(我正在粘貼由Netbeans創建的所有三個日誌):Netbeans:啓動Tomcat失敗

Starting Tomcat process... 
Waiting for Tomcat... 
Starting of Tomcat failed. 
/Users/username/Programming/murach/servlet_and_jsp/netbeans/book_apps/ch02email/nbproject/build-impl.xml:1045: Deployment error: Starting of Tomcat failed. 
See the server log for details. 
BUILD FAILED (total time: 5 seconds) 

第二個日誌下面更新編輯。


25-Feb-2017 10:52:01.036 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 10:52:01.039 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 10:56:20.738 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 10:56:20.739 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 10:56:21.153 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 10:56:21.154 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 10:56:57.631 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 10:56:57.633 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 10:56:58.028 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 10:56:58.029 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:03:33.511 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:03:33.512 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:03:33.954 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:03:33.954 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:04:55.741 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:04:55.742 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:04:56.266 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:04:56.267 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:07:47.921 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:07:47.921 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:07:48.269 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:07:48.270 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:10:47.597 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:10:47.597 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:10:47.938 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:10:47.938 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:26:32.913 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:26:32.914 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:26:33.299 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:26:33.300 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:33:02.424 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:33:02.425 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 11:33:02.830 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 11:33:02.830 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 11:37:40.206 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 11:37:40.206 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 12:00:38.512 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 12:00:38.512 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 12:00:38.911 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 12:00:38.912 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 12:02:02.486 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 12:02:02.486 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 12:02:02.900 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 12:02:02.901 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 12:15:11.097 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 12:15:11.097 INFO [localhost-startStop-2] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 12:55:27.480 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 12:55:27.480 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 12:55:27.850 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 12:55:27.850 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 12:55:43.461 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 12:55:43.461 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 12:55:43.768 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 12:55:43.768 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 12:59:14.284 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 12:59:14.284 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:06:51.106 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 13:06:51.106 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:06:51.393 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 13:06:51.395 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 13:06:54.234 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 13:06:54.234 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:06:54.480 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 13:06:54.481 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 13:07:27.585 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 13:07:27.586 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:07:27.852 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 13:07:27.853 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 13:07:56.290 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 13:07:56.290 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:07:56.581 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 13:07:56.581 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 
25-Feb-2017 13:08:06.413 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 
25-Feb-2017 13:08:06.413 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 
25-Feb-2017 13:08:06.701 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log SessionListener: contextDestroyed() 
25-Feb-2017 13:08:06.701 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextDestroyed() 

任何幫助將是非常讚賞!

更新:我卸載了Tomcat,重新啓動了我的電腦,重新安裝了Tomcat,並試圖運行相同的程序。我知道問題在於我的設置,因爲該程序是從教科書出版商下載的示例。

去我的瀏覽器中的本地主機:8080每當我嘗試運行該程序時都工作,所以我相信Tomcat實際上是開始的,因爲某種原因只是沒有與Netbeans一起工作。

第一個錯誤是目前相同,但第二個,現在看起來是這樣的:

25-Feb-2017 13:48:08.178 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:  Apache Tomcat/8.5.11 
25-Feb-2017 13:48:08.181 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:   Jan 10 2017 21:02:52 UTC 
25-Feb-2017 13:48:08.181 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:   8.5.11.0 
25-Feb-2017 13:48:08.181 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:    Mac OS X 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:   10.12.3 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:   x86_64 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:    /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:   1.8.0_121-b13 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:   Oracle Corporation 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:   /Users/username/Applications/tomcat-8.0 
25-Feb-2017 13:48:08.182 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:   /Users/username/Applications/tomcat-8.0 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/Users/username/Applications/tomcat-8.0/conf/logging.properties 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dhttp.nonProxyHosts=localhost|127.0.0.1|Users-Mac-mini.local 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/Users/username/Applications/tomcat-8.0 
25-Feb-2017 13:48:08.183 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/Users/username/Applications/tomcat-8.0 
25-Feb-2017 13:48:08.184 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/Users/username/Applications/tomcat-8.0/temp 
25-Feb-2017 13:48:08.184 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /Users/username/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:. 
25-Feb-2017 13:48:08.883 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"] 
25-Feb-2017 13:48:08.953 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 
25-Feb-2017 13:48:08.959 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"] 
25-Feb-2017 13:48:08.968 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read 
25-Feb-2017 13:48:08.969 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 1818 ms 
25-Feb-2017 13:48:09.059 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina 
25-Feb-2017 13:48:09.059 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.11 
25-Feb-2017 13:48:09.074 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/username/Applications/tomcat-8.0/webapps/docs 
25-Feb-2017 13:48:09.602 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/username/Applications/tomcat-8.0/webapps/docs has finished in 527 ms 
25-Feb-2017 13:48:09.603 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/username/Applications/tomcat-8.0/webapps/examples 
25-Feb-2017 13:48:10.305 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/username/Applications/tomcat-8.0/webapps/examples has finished in 703 ms 
25-Feb-2017 13:48:10.306 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/username/Applications/tomcat-8.0/webapps/host-manager 
25-Feb-2017 13:48:10.358 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/username/Applications/tomcat-8.0/webapps/host-manager has finished in 52 ms 
25-Feb-2017 13:48:10.359 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/username/Applications/tomcat-8.0/webapps/manager 
25-Feb-2017 13:48:10.419 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/username/Applications/tomcat-8.0/webapps/manager has finished in 59 ms 
25-Feb-2017 13:48:10.419 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /Users/username/Applications/tomcat-8.0/webapps/ROOT 
25-Feb-2017 13:48:10.469 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /Users/username/Applications/tomcat-8.0/webapps/ROOT has finished in 50 ms 
25-Feb-2017 13:48:10.473 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [http-nio-8080] 
25-Feb-2017 13:48:10.479 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [ajp-nio-8009] 
25-Feb-2017 13:48:10.480 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 1510 ms 
+0

轉到'''''''''選項'在'一般'選項卡中選擇'無代理'並點擊'好'。 – Shashanth

+0

@Shashanth在什麼程序? NetBeans中的工具或常規選項卡下沒有選項。 – hmowilliams

+0

從Netbeans的菜單欄中選擇工具。看到這個[截圖](https://i.stack.imgur.com/RHG6f.png) – Shashanth

回答

0

這個問題已經摺騰我好幾個星期,但今天我終於得到它的工作。據我所知,教科書說明不再適用於MacOS Sierra。如果其他人是否有類似的麻煩,這裏是我使用的步驟:

  1. 對Java EE 安裝了NetBeans(安裝說:「安裝剩餘時間:不到一分鐘。」望穿秋水我剛剛離開單幹並且它最終完成安裝。)
  2. 下載並解壓的Apache Tomcat 9(我最終把這個在同一個文件夾中,我的其他服務器的文件夾存儲和書指示沒有改名)
  3. 大多沿用書的說明配置Tomcat服務器,但因爲另一臺服務器正在使用8080,所以使用服務器端口8081.再次使用默認名稱。
  4. 按照書中的指示下載了Murach示例文件,但經過三次註冊後,該網站仍然無法識別我曾經註冊過的。
  5. 按照本書指示打開第2章中的示例文件。

這是修復我的問題的主要部分:系統代理設置在塞拉利昂。感謝https://discussions.apple.com/message/30715103#30715103我終於搞定了。下面是我使用的步驟:

  1. 在Mac:系統偏好設置 - >網絡 - >選擇您的WiFi連接 - >高級 - >代理 選擇自動代理髮現(鏈接說選擇多個選項,但這是唯一一個留在我的系統上選擇,所以我不認爲其他人是必要的)
  2. 在Netbeans:首選項 - >常規 - >選擇「使用系統代理設置」 - >點擊重新加載 - >點擊測試連接

當我在測試連接旁邊的綠色複選標記後,我能夠運行示例程序從第2章沒有我這是第一次。

導入其他項目文件後還有一些剩餘的問題。到目前爲止,有一個需要手動鏈接的.jar文件,可能是因爲我使用了Tomcat 9而不是Tomcat 8?無論如何,輕鬆完成。此外,我得到了一些例子,說一個警告:該項目

warning: [options] bootstrap class path not set in conjunction with -source 1.6 
1 warning 

單擊鼠標右鍵,然後選擇屬性,切換到JDK 8源代碼/二進制從JDK 6格式解決了這個警告。

希望能幫助別人!

-1

C:\apache-tomcat-8.0.36-windows-x64\apache-tomcat-8.0.36\bin然後打開catalina.bat在記事本++和搜索集"JAVA_OPTS=%JAVA_OPTS% %LOGGING_CONFIG%",並設置「JAVA_OPTS=%JAVA_OPTS% %LOGGING_MANAGER%」並刪除雙引號。

然後搜索集「JAVA_OPTS=%JAVA_OPTS% %JSSE_OPTS%」,並從這裏刪除雙引號。

希望它會工作

+0

謝謝,迪帕克!我使用的是Mac,但catalina.bat文件中的這些選項只有「JAVA_OPTS =%JAVA_OPTS%%JSSE_OPTS%」。我從該部分刪除了雙引號,但它並沒有解決問題。 :( – hmowilliams