How to change port 8080

Hello, just installed Cuba studio. I already have Tomcat running on port 8080.

Cuba says "please ensure the port 8080 is free when you work with the CUBA Studio.

Can I change this port number in Cuba?

Hello,
actually you can change the Tomcat port, but now it will look like a hack:

  • run Studio server once, start it, then stop and exit
  • edit ~/.haulmont/studio/config.xml and add the following parameter:

  <configuration>
    <app> 
       <port>8081</port>
   </app>...
  • start Studio server again, it will read the config
  • create a project and execute Run > Deploy. You will see the Tomcat instance in build/tomcat subdirectory
  • edit build/tomcat/conf/server.xml and change two ports:

<Server port="8006" shutdown="SHUTDOWN">
  ...
  <Connector port="8081" ...
  • now you can build your project and start the app server - you will be able to open the app on [url=http://localhost:8081/app]http://localhost:8081/app[/url]
    Unfortunately, the default shutdown port (8005) is hardcoded to Studio - so you will not be able to stop or restart your appserver from Studio (don’t even try, you will stop your other Tomcat instance). So to restart, you will have to stop Tomcat manually, then start it from Studio.
    Thanks for the idea, we will try to implement the ports change in the nearest update.

Ok, thanks!

Hi,
the problem is fixed in the Studio version 2.0.6.

I do some of my cuba development on a windows 7 machine that I don’t have admin rights to. Whenever I go to studio, it believes something is running on port 8080. I suspect there’s some background security monitoring going on that checks 8080 that leads cuba studio to erroneously conclude that “Address localhost:8080 is in use”. I can for example run a different project with tomcat that will work fine with port 8080.

I am using studio 6.3.0. I tried the above hack but it doesn’t seem to work. It still gives the “Address localhost:8080 is in use” instead of using 8081. How can I change the port for a project without using studio?

As a future enhancement, can you improve the port checking or enable the user to force specify that the application server is not running even though it thinks it is?

One clarification, the “hack” described above does work in the sense that tomcat runs the application on port 8081. However, the link in studio at the bottom left still links to 8080 and when you go to project properties -> advanced -> http port, it doesn’t let you change the port because “Tomcat was not stopped. Stop it manually” which is something I cannot do because it looks at port 8080 and always thinks tomcat was not stopped.

Jonathan,

I would recommend just set up the desired ports using modern Studio on a separate machine, then copy the project to your workstation. Alternatively, you can do it manually in build.gradle and tomcat\conf\server.xml, but again, first look at what Studio does when it changes ports.

The hack described on this topic makes sense only for a very old Studio.

btw, your last suggestion worked well, changing the port on a machine i have admin access to, committing the changes, then pulling the changes on the machine without admin access. Thx.

I am facing the same problem!

Does anyone can help me?

Edit:

Jonathan,
Are you using Oracle? I found the process that was using the 8080 port. Its from oracle and its called tnslsnr.

I used the TCPView to find it. (How to kill Tomcat when running it from Eclipse? - Stack Overflow)

If the issue is similar to the one I had relating to admin rights, write your project somewhere, open it on a different machine with Cuba Studio installed where you do have admin rights, change the port (I ended up changing it to 8083) and when you re-open the project on the first machine, it should be on the new port.

I wrote my project to Github, pulled it on another machine where I had admin rights, made the change, and the re-wrote the changes to Github. Then I pulled the changes to the original machine where I did not have admin rights and it worked well.

And there is a simpler solution: after creating a new project, close it and add the following to your build.gradle:


cuba {
...
    tomcat {
        dir = "$project.rootDir/build/tomcat"
        port = "8081"
        debugPort = "8788"
        shutdownPort = "8006"
        ajpPort = "8010"
    }
}

If you tried to deploy or start the app server, go to build and completely delete tomcat folder.

Then open the project and work as usual. When you start app server, Studio will modify Tomcat’s server.xml to use the specified ports.

1 Like

Is it possible that there’s a bug in the current version? Whatever I do, dropTomcat, setupTomcat, clean, cleanConf, … the tomcat server won’t respect my port change (8081) and deploy/tomcat/conf/server.xml still only contains the lines with port 8080:

    <Connector port="8080" protocol="HTTP/1.1"

I have noticed this as well before. do a gradle clean and/or delete the deploy folder and build again.

Hi,
It’s a known bug in the CUBA gradle plugin: https://github.com/cuba-platform/cuba-gradle-plugin/issues/152

Ok, thanks for the information. Is there a known workaround besides editing the server.xml manually?

Just don’t change the ajp port. :wink:

Not sure. Maybe you can change AJP port back to default value (it’s not used in recent Tomcat version in the default configuration anyway).
Or change port value in the server.xml manually.

1 Like

@AlexBudarov You replied exactly when I edited my post. :slight_smile: Yes, that works. Just leave the value at the default.