Monday, December 15, 2008

Starting tomcat from Eclipse gives error "Can't load server.xml"

I am using Eclipse Gannymede and I am trying to start a Tomcat 5.5 and/or Tomcat 6.0 server.

Problem: When trying to start the Tomcat server from within Eclipse you get an error stating that Eclipse cannot load the server.xml file:

WARNING: Can't load server.xml from C:\projects\workspace-gannymede\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml
Dec 15, 2008 3:52:51 PM org.apache.catalina.startup.Catalina load
WARNING: Can't load server.xml from C:\projects\workspace-gannymede\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\conf\server.xml
Dec 15, 2008 3:52:51 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 0 ms
java.lang.reflect.InvocationTargetException
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:585)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Caused by: java.lang.NullPointerException
at org.apache.catalina.startup.Catalina.await(Catalina.java:616)
at org.apache.catalina.startup.Catalina.start(Catalina.java:576)
... 6 more

If I try to look at the server.xml file that Eclipse is trying to read, it does not exist on the filesystem.

Solution: I tried a number of things such as deleting all my server configurations as well as the contents of the .metadata\.plugins\org.eclipse.wst.server.core\ directory.  Nothing worked.  The solution is to create a new Server Runtime Environment (Window -> Preferences -> Server -> Runtime Environments).  Then in your Servers view (Window -> Show View -> Servers) add a new server configuration (right-click and select New -> Server) but DO NOT ADD ANY PROJECTS TO IT.  Double click the new server configuration to bring up the Server Overview page which looks like this:

Under Server Locations select Use Tomcat installation.  Save.  You should be able to start your server now (assuming you can start it fine from the command line).  Now add your project to the server and you're ready to go.

17 comments:

Anonymous said...

Thanks dude, what a life saver.

Фёдоров said...

Aaah such a simple tip but so hardto find..
Thanks a million!

Anonymous said...

Thank you! Struggled with this for hours.

Anonymous said...

Ouais, vraiment trop cool. I don't what made this happen. At the beginning all was working. Now i get this error even after re installing...
Merci+++

natimhoff said...

thanks a million!! really a life saver :D

Anonymous said...

Thanks a lot, simple solution to a really annoying problem.

Anonymous said...

Thanks a lot

Divya said...

Thanks Karl.

Adriana said...

Yeah! You rock! Thanks, dude!

Anonymous said...

Thanx man,
problem solved

Anonymous said...

btw,
if you already have configured a server,

if you dbl click it in the server view, you can't edit the 'server location'.

But if you simply remove the deployed webapp and clean (from server view), when you'll dbl click it, it will be editable.

Anonymous said...

Man thank you very much, that problem was pissing me off

Anonymous said...

Thank you very much.

Div said...

Thanks Karl.

Deepti Charolkar said...

Thanks a lot...it worked.....

Anonymous said...

thanks! super time saver niner!

lee woo said...

Brown nosers and asskissers have been pissing off cool people since the dawn of time. At some point, they always get their comeuppance. See the link below for more info.



#pissing
www.ufgop.org