简体   繁体   中英

How to run existing apache tomcat instance from eclipse (runtime environment configuration)?

I have a general question which challenges my understanding of web applications as I only recently began to work with web apps.

To simplify - I have a maven project which can be successfully installed using mvn clean install and then it can be started executing catalina start from the 'apache-tomcat/bin' folder using command line. At this point I will also add that localhost is accessible and working nicely.

The goal is to do the same using eclipse. I can successfully install maven project from eclipse but I cannot start the server - or rather - I can start the server but it's not working properly.

The way I try to start server from eclipse is I add a runtime environment (Windows->Preferences->Runtime Environmentss: tomcat 7), which points to the tomcat root folder /target/apache-tomcat (please note 'target' folder was created as result of installing/building maven project). At the end I change configuration path (set to apache-tomcat/conf ) in 'Overview' tab in eclipse as well as I tick 'use custom location' radio button, pointing to 'apache-tomcat' folder.

As the result server started but when trying to access localhost, instead of 'home-page' there is exception thrown:

java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:295) org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:33) org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:178) org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticateNow(CasAuthenticationProvider.java:131) org.springframework.security.cas.authentication.CasAuthenticationProvider.authenticate(CasAuthenticationProvider.java:117) org.springframework.security.authentication.ProviderManager.doAuthentication(ProviderManager.java:130) org.springframework.security.authenticatio n.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:48) org.springframework.security.cas.web.CasAuthenticationFilter.attemptAuthentication(CasAuthenticationFilter.java:111) org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) org.jasig.cas.client.session.SingleSignOutFilter.doFilter(SingleSignOutFilter.java:110) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105) org.springframework.security.web.FilterChainProxy$V irtualFilterChain.doFilter(FilterChainProxy.java:381) org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79) org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:381) org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:168) org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237) org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)

Obviously eclipse overridden somehow tomcat launch configuration but I don't know why. I'd appreciate any input!

@update : Although I tried everything @skomisa suggested so far, it doesn't seem to work. Interesting enough, that I can run the server via command prompt (eg 'catalina run' from tomcat bin directory, once it's built), but I cannot run it inside eclipse as following exception is thrown. I do not access local host via HTTPS, but HTTP. Is that because in 'Add and Remove' window there are no web applications to deploy? At this point I will add, that my eclipse project is simply of Maven nature (it's not converted to dynamic web project, and I'm not sure if it has to be in order to successfully run tomcat).

Add your Tomcat server to Eclipse as follows:

  • Window -> Show View -> Servers
  • In the Servers panel right-click in any empty area and select New -> Server
  • In the New Server wizard that opens expand the Apache node in the list of servers and select the appropriate version of Tomcat. It's Tomcat v7.0 Server in your case. Click Next .
  • On the next screen click the Browse button and navigate to your installation of Tomcat 7. Click Next .
  • On the Add and Remove screen add any web applications you want deployed on that Tomcat 7 server, and click Finish .
  • You should see your Tomcat 7 server on the list of servers in the Servers panel. Select it, right click and select Run from the popup menu. Tomcat will log to the console ( Window -> Show View -> Console ).
  • Enter the URL for your application in the browser. That's it!

This tutorial may also be helpful: https://crunchify.com/how-to-create-dynamic-web-project-using-maven-in-eclipse/

As an unrelated issue, the stack trace you posted suggests that you are entered an https URL when you should have entered an http URL. Is that the case?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM