2

I am testing Codenvy (https://codenvy.io) and made a very simple Spring Boot web controller:

@Controller
@EnableAutoConfiguration
public class SampleController { 

@RequestMapping("/")
@ResponseBody
String home() {
    return "Hello World!";
}

public static void main(String[] args) throws Exception {
    SpringApplication.run(SampleController.class, args);
}

}

Pom.xml:

 <parent>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-parent</artifactId>
  <version>1.4.2.RELEASE</version>
 </parent>
 <dependencies>
 <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
  </dependency>

Launch is ok:

          2016-11-17 22:34:23.060  INFO 344 --- [           main] sample.SampleController                  : Starting SampleController on 780c1f85387b with PID 344 (/projects/Spring-boot started by user in /projects/Spring-boot)
      2016-11-17 22:34:23.084  INFO 344 --- [           main] sample.SampleController                  : No active profile set, falling back to default profiles: default
      2016-11-17 22:34:23.334  INFO 344 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70e8f8e: startup date [Thu Nov 17 22:34:23 UTC 2016]; root of context hierarchy
      2016-11-17 22:34:34.172  INFO 344 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
      2016-11-17 22:34:34.343  INFO 344 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
      2016-11-17 22:34:34.358  INFO 344 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
      2016-11-17 22:34:34.746  INFO 344 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
      2016-11-17 22:34:34.748  INFO 344 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 11431 ms
      2016-11-17 22:34:35.782  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
      2016-11-17 22:34:35.808  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
      2016-11-17 22:34:35.810  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
      2016-11-17 22:34:35.812  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
      2016-11-17 22:34:35.814  INFO 344 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
      2016-11-17 22:34:37.532  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@70e8f8e: startup date [Thu Nov 17 22:34:23 UTC 2016]; root of context hierarchy
      2016-11-17 22:34:38.123  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto java.lang.String sample.SampleController.home()
      2016-11-17 22:34:38.170  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
      2016-11-17 22:34:38.170  INFO 344 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
      2016-11-17 22:34:38.490  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:38.490  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:38.646  INFO 344 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
      2016-11-17 22:34:39.377  INFO 344 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
      2016-11-17 22:34:39.669  INFO 344 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
      2016-11-17 22:34:39.708  INFO 344 --- [           main] sample.SampleController                  : Started SampleController in 20.214 seconds (JVM running for 21.802)

In my browser the url for the project is: https://codenvy.io/dashboard/#/ide/tyvain/BOTS

Simple (dumb) question: How can I call this URL to test it ??

Tyvain
  • 2,640
  • 6
  • 36
  • 70

2 Answers2

2

It's not really a dumb question :)

When you are in a cloud IDE, the application is running inside of another runtime. In the case of codenvy, we use Docker containers as the runtime. Docker lets you start your application, but then uses the ephemeral port range to take your server's internal port number and to make it available to the outside world. It maps the port to another number starting in the 32765+ range. It does this because if there are two servers in two workspaces running on the same port, they both would collide with one another, so docker places the ports into this range to avoid port collission.

You need to set up a command with a previewURL that will show you the URL to your server when you run it. We have a lot of documentation on how preview URLs are generated at www.eclipse.org. But also, you can see how the commands are structured in the samples (try the maven spring sample).

Tyler Jewell
  • 151
  • 5
  • Almost goo, the problem was that I launched with java command instead of mvn. Now i get a preview URL: http://node6.codenvy.io:35072/ , but I still can't see my 'Hello World' response ( (110) Connection timed out) – Tyvain Nov 18 '16 at 00:05
  • You may want to post a ticket at github.com/eclipse/che/issues with a full set of steps that you are using to create your workspace to see if others can reproduce the issue and help you out. – Tyler Jewell Nov 18 '16 at 16:19
  • It could be a network policy preventing your machine from accessing external server on any other port than '80'. But to check this I did `'wget ` in codenvy terminal but still i am getting 404 – old-monk Apr 13 '18 at 23:22
-1

https://codenvy.com/docs/user-guide/previews/index.html

Is this what you are asking, looking for?

Looks like a variable is part of the command pallette for the run command

whackamadoodle3000
  • 6,684
  • 4
  • 27
  • 44
Philip Ruff
  • 11
  • 1
  • 3