Ubuntu 12.04에서 Tomcat7과 eclipse 설정하기
2012.08.22 22:39
Set up Eclipse and Tomcat 7 on Ubuntu 12.04 to create Java RESTful Web Services with Jersey
- Download Eclipse;
- use the Eclipse Update Manager to install all packages from the category Web, XML, Java EE Development and OSGi Enterprise Development, except “PHP Development” and the “RAP” Tooling;
- while you wait for the installation of the packages you can install tomcat7 by running from terminal:
sudo apt-get install tomcat7 tomcat7-docs tomcat7-examples tomcat7-admin -y
- configure WTP to use Tomcat:
- select Windows -> Preferences -> Server -> Runtime Environments;
- press Add…;
- select “Apache Tomcat v7.0″;
- enter “/usr/share/tomcat7″ into the “Tomcat installation directory” field;
- press Ok;
- create a new “Dynamic Web Project”
- as Target Runtime select “Apache Tomcat v7.0″;
- press twice Next;
- select the “Generate the web.xml deployment descriptor” option at the final dialog;
- press Finish;
- close Eclipse;
- to fix the error “Cannot create a server using the selected type” run the following:
cd ~/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/ rm org.eclipse.jst.server.tomcat.core.prefs rm org.eclipse.wst.server.core.prefs
- to fix the error “Could not load the Tomcat server configuration at /usr/share/tomcat7/conf. The configuration may be corrupt or incomplete. /usr/share/tomcat7/conf/catalina.policy (No such file or directory)” run the following commands:
cd /usr/share/tomcat7 sudo ln -s /var/lib/tomcat7/conf conf sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy sudo ln -s /var/log/tomcat7 log sudo chmod -R 777 /usr/share/tomcat7/conf
- log out and log back in;
- open Eclipse;
- open the server view:
- go to Window->Show View->Other…;
- choose the Servers under the Server category;
- click on “new server wizard”;
- choose Apache / Tomcat v7.0 Server and press Next;
- enter “/usr/share/tomcat7″ into the “Tomcat installation directory” field;
- press Next;
- select your project on the left pane under “Available” and press Add> to move it to the right pane under “Configured”;
- press Finish”;
- to be able to start the Tomcat server from Eclipse you need first to stop the one running in background:
sudo service tomcat7 stop
and to disable Tomcat to automatically start at boot run:
sudo update-rc.d tomcat7 disable
- download the zip of Jersey;
- put the the jersey jars into the folder “WEB-INF/lib” and add them to the project build path;
- create your first RESTful Webservice by following this tutorial by Lars Vogel.
Your web services will be automatically deployed in the following folder:
~/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/
Your web service will be accessible through the following URI:
http://localhost:8080/EclipseProjectName/x/y/z
Where:
- x = the root of your service set inside the tag url-pattern in web.xml;
- y = the path set for your class
- z = the path set for your method
본 웹사이트는 광고를 포함하고 있습니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.
광고 클릭에서 발생하는 수익금은 모두 웹사이트 서버의 유지 및 관리, 그리고 기술 콘텐츠 향상을 위해 쓰여집니다.