Tomcat is not working in Eclipse
You can try the following that changes the way Eclipse handles Tomcat.
- In Eclipse, go to 'Servers' tab and double-click on the Tomcat instance you have. This opens up a tab
- In the ab, click on the Server Locations section to expand the view (if collapsed)
- Select the second radio button that says "Use Tomcat installation (takes control of Tomcat installation)"
- Also change the deploy path to the path of the webapps directory in your tomcat installation by clicking the Browse button. In my case, it is set to "D:\Apps\apache-tomcat-7.0.47\webapps"
- Click the "Save" button on the toolbar and restart your Tomcat instance from the Servers tab
You can try seeing the tomcat page.
Let me know how it goes.
ChrisZ
Updated on July 09, 2022Comments
-
ChrisZ almost 2 years
I couldn't believe I spent several days in solving this issue, maybe partially because I was not that familiar with Mac. OK, just post out my solution diary. Hope it will be helpful to other folks.
encountered problems: 1.The first problem is Tomcat cannot be started from Eclipse, but can be started by startup.sh (locahost:8080 page cannot be loaded) 2.And then, after some attempts, even startup.sh will not work. 3. After fixing the first two problem, the locahost:8080 page can be loaded, but the application can not be loaded. 404 error - resouce not found is shown even though the war folder is correctly placed inside the webapps folder. When Tomcat has reference to the Struts 2 application, some ClassNotFoundException or MethodNotDefinedException will occur.
Causes and Solution to each of the problem.
Tomcat cannot be started from Eclipse. The cause is that the setup for Tomcat in Eclipse is not completed. Tomcat in Eclipse is not yet pointed to the configuration folder. Solution: double click on the Tomcat server in Server tab, and a configuration window will come up. In the window, select the Tomcat configuration folder and deployment destination folder.
startup.sh does not work. The cause MAY BE duplicated jar issue. I forgot I had copied the entire Struts 2 jars in /Library/Java/Extensions, which had been originally empty. Solutions: Clear that folder, and startup.sh will work.
Web application cannot be loaded even when Tomcat is working (the previous 2 issues have been fixed) The cause MAY BE that redundant Struts jars are included in the project. I googled to find out the necessary jars for Struts 2, and include them only.
Original post: I have been trying to run a Hello World web application in Eclipse but cannot publish.
Here is what I have done:
-using Macintosh on OS X 10.8.
-downloading Tomcat 7 from Apache, and upzipping the file under some directory.
-also creating a certain environment variables like $CATALINA_BASE and $CATALINA_HOME by using the "export" command.
-In Eclipse, creating a new server as Tomcat 7, pointing it to the unzipped Tomcat directory above, and add the web application(compile error-free) project into Tomcat
-publishing my Web app.
`
Here is what I countered.
As the server in Eclipse is running, I got 404 error that resource is not found. I checked server.xml, the context reference was added. But in Tomcat's webapps folder, there is no war file added. Even if I typed locahost:8080, I still get 404 error instead of the tomcat "default page".
-
-
However, it worked if I started the server with startup.sh, and manually dragged the war file under the webapps folder. Immediately, the war gets unzipped and I can load my static and dynamic pages.
p.s. Once my problem above is solved, I have more problems now. My startup.sh can no longer start the server now. And Everytime I run it, it seems to erase the value of the environment variables it concerns.
----------------RESPONSE TO MY HELPER COMMENTERS------------------------------------ to Keerthi Ramanathan: catalina.out content
Nov 27, 2013 10:26:50 PM org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: .:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java Nov 27, 2013 10:26:50 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["http-bio-8080"] Nov 27, 2013 10:26:50 PM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-bio-8009"] Nov 27, 2013 10:26:50 PM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 800 ms Nov 27, 2013 10:26:50 PM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina Nov 27, 2013 10:26:50 PM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/7.0.47 Nov 27, 2013 10:26:50 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/docs Nov 27, 2013 10:26:50 PM org.apache.tomcat.websocket.server.WsSci onStartup INFO: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocketJARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. Nov 27, 2013 10:26:50 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/examples Nov 27, 2013 10:26:51 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/host-manager Nov 27, 2013 10:26:51 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/manager Nov 27, 2013 10:26:51 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory /usr/local/apache-tomcat-7.0.47/webapps/ROOT Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["ajp-bio-8009"] Nov 27, 2013 10:26:51 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 1075 ms java.lang.NoSuchMethodError: org.apache.juli.ClassLoaderLogManager.setUseShutdownHook(Z)V at org.apache.catalina.startup.Catalina.start(Catalina.java:719) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:456) Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["http-bio-8080"] Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol pause INFO: Pausing ProtocolHandler ["ajp-bio-8009"] Nov 27, 2013 10:26:51 PM org.apache.catalina.core.StandardService stopInternal INFO: Stopping service Catalina Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol stop INFO: Stopping ProtocolHandler ["http-bio-8080"] Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol stop INFO: Stopping ProtocolHandler ["ajp-bio-8009"] Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["http-bio-8080"] Nov 27, 2013 10:26:51 PM org.apache.coyote.AbstractProtocol destroy INFO: Destroying ProtocolHandler ["ajp-bio-8009"] Exception in thread "Thread-2" java.lang.NoSuchMethodError: org.apache.juli.ClassLoaderLogManager.shutdown()V at org.apache.catalina.startup.Catalina$CatalinaShutdownHook.run(Catalina.java:920)
-
to Krish
By select the radio button "Use Tomcat installation...." I can see a good page when loading localhost:8080
By set the deployment path to the webapps folder, I can see the unzipped war folder copied under the webapps folder.
However, loading an application still failed. loading the localhost:8080/HellowWorldStruts2/index.jsp or localhost:8080/HellowWorldStruts2/index.jsp (ignore the typo of additional w, it is a typo along in the project) still gave a 404 error and description The requested resource is not available. However, the index.jsp is right under the war folder.
And I got these feedbacks during deployment
SEVERE: Exception starting filter struts2 java.lang.NoClassDefFoundError: javax/servlet/Filter at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) at java.net.URLClassLoader.defineClass(URLClassLoader.java:283) at java.net.URLClassLoader.access$000(URLClassLoader.java:58) at java.net.URLClassLoader$1.run(URLClassLoader.java:197) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:295) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1617) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1547) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:142) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4775) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5452) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1120) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1678) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) ... 35 more Nov 28, 2013 12:09:20 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Error filterStart Nov 28, 2013 12:09:20 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Context [/HellowWorldStruts2] startup failed due to previous errors
--------------------END RESPONSE TO MY HELPER COMMENTERS---------------------------