Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solv] Intellij and tomcat. Can't really talk to each other
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
*_-=Banana=-_*
Apprentice
Apprentice


Joined: 21 May 2004
Posts: 157
Location: Germany

PostPosted: Wed May 09, 2018 12:06 pm    Post subject: [solv] Intellij and tomcat. Can't really talk to each other Reply with quote

Hello, everyone. I have a problem with Intellij and Tomcat and I could not find a solution to get it really fixed.

I can't find the "right" settings for a working run/debug config. Right now I'm able to run the project and deploy it. But only with a workaround and it looks not "right".
Manually starting the tomcat with the provided init.d script works fine. Port settings and even the jmx works. But (as a beginner) running and using the process (Run->run / Run->debug and stopping) from intellij would really make my live easier. At least for the get used to part....

So here is my setup. Version infos below.

Intellij Run/debug config
    Tomcat Server (local)
    Aplication Server Tomcat 9.0.7-gentoo -> home: /usr/share/tomcat-9; base: /var/lib/tomcat-9
    HTTP port: 8090
    JMX port: 1099
    AJP port: 8009
    Startup script: /var/lib/tomcat-9/custom-start.sh
    Shutdown script: /var/lib/tomcat-9/custom-stop.sh


Why the custom startup scripts?
Gentoo uses the /etc/init.d/tomcat-9 script and not the catalina.sh script. Since the init.d script requires root I've set up the execution with sudo. At frist I had "/usr/bin/sudo /etc/init.d/tomcat-9 start" as the startup script. But the result was that the run process from intellij executed it but did not recognize the server needs some time to start. It ends the process with the message the it could not connect to the jmx port. Which is running and working (netstat shows it) but not as fast as intellij "thinks".
This lead to the creation to the following script:

/var/lib/tomcat-9/custom-start.sh
Code:
#!/bin/bash

/usr/bin/sudo /etc/init.d/tomcat-9 start &> /dev/null;
sleep 10

exit 0;


This delay makes it possible that intellij recognizes the open jmx port and continues to deploy the files. Which will work but soon after that intellij prints a "disconnected from server" and it shows that the run process is terminated. Which is not and I would have to stop/restart the tomcat process. So the run process from Intellij is useless.

I know I could do this without intellij but as a beginner I will be happy learn the project first and then starting to not using IDEs...

Any help will be appreciated. I hope I can reply fast enough but the next two days could be slow on my end. The right solution I would have as a result would be the "simple" setup I can use in my macbook. Same intellij and code and it "just" works.... I can use the run/debug stuff from intellij and control the tomcat server....


Tomcat
Code:
[ebuild   R   ~] www-servers/tomcat-9.0.7:9::gentoo  USE="-doc -extra-webapps -source {-test}"


Intellij
Code:
IntelliJ IDEA 2017.1.4
Build #IU-171.4694.23, built on June 6, 2017
JRE: 1.8.0_172-b11 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation
Linux 4.9.72-gentoo

_________________
My personal space


Last edited by *_-=Banana=-_* on Tue May 15, 2018 8:52 am; edited 1 time in total
Back to top
View user's profile Send private message
arnvidr
Guru
Guru


Joined: 19 Aug 2004
Posts: 573
Location: Oslo, Norway

PostPosted: Wed May 09, 2018 7:50 pm    Post subject: Reply with quote

I'm not sure if I ever launch tomcat directly through IntelliJ. Will have to check at work how I normally launch some of these lower level projects, but I won't be at the office again until Friday. I know that at least for our GWT projects, which run in tomcat on the various deployed instances, we just run a 'GWT Configuration' in IntelliJ to directly launch a GWT app in a browser.

Will get back to you.
_________________
Noone wrote:
anything
Back to top
View user's profile Send private message
arnvidr
Guru
Guru


Joined: 19 Aug 2004
Posts: 573
Location: Oslo, Norway

PostPosted: Fri May 11, 2018 11:10 am    Post subject: Reply with quote

An update to that, we use jetty to run/debug locally in IntelliJ.

Not sure how applicable that is to your projects, but we have them as all maven modules, and just use a maven run configuration with the command line 'jetty:run' to start any of the modules.
_________________
Noone wrote:
anything
Back to top
View user's profile Send private message
*_-=Banana=-_*
Apprentice
Apprentice


Joined: 21 May 2004
Posts: 157
Location: Germany

PostPosted: Sat May 12, 2018 10:08 pm    Post subject: Reply with quote

arnvidr, thank you for looking into it. Since we use tomcat in production I will stick to that. I kinda got it to work through running the server manually and configure the tomcat server as a remote server in intellij. Still wondering why the usual approach does not work....
_________________
My personal space
Back to top
View user's profile Send private message
arnvidr
Guru
Guru


Joined: 19 Aug 2004
Posts: 573
Location: Oslo, Norway

PostPosted: Sun May 13, 2018 9:30 am    Post subject: Reply with quote

We also run all of these modules in tomcat containers in production, but anything you want to try to debug locally is probably never directly related to tomcat, but the module running inside it, hence we use something more lightweight like jetty for easier local testing.

Glad you got it running though :)
_________________
Noone wrote:
anything
Back to top
View user's profile Send private message
logrusx
n00b
n00b


Joined: 22 Feb 2018
Posts: 13

PostPosted: Sun May 13, 2018 1:29 pm    Post subject: Reply with quote

The way to go is download and extract a copy of Tomcat in your home folder and use it from there, or use lightweight tools like jetty, as proposed. Either way I don't think IntelliJ would wait enough to establish a connection. Use Tomcat as a remote server - start it manually and connect on the debug ports.
p.s. don't allow yourself to get distracted of what's "right" too much. Init scripts are ment for servers and services, not for development, neither to be run from an IDE of a regular user.
Back to top
View user's profile Send private message
*_-=Banana=-_*
Apprentice
Apprentice


Joined: 21 May 2004
Posts: 157
Location: Germany

PostPosted: Mon May 14, 2018 1:37 pm    Post subject: Reply with quote

since tomcat is in portage I choose it. Jetty isnt, rigth?

I have it running as a remote server, so it is partly solved.

Thx for the help!
_________________
My personal space
Back to top
View user's profile Send private message
arnvidr
Guru
Guru


Joined: 19 Aug 2004
Posts: 573
Location: Oslo, Norway

PostPosted: Mon May 14, 2018 9:36 pm    Post subject: Reply with quote

Since jetty is only used for running stuff inside IntelliJ it's only installed through maven, I think as a build plugin. Might be worth a try if you use maven :)
_________________
Noone wrote:
anything
Back to top
View user's profile Send private message
*_-=Banana=-_*
Apprentice
Apprentice


Joined: 21 May 2004
Posts: 157
Location: Germany

PostPosted: Tue May 15, 2018 8:41 am    Post subject: Reply with quote

hm. I tried it. But there are some path and context errros. I will have a talk with the other devs if it is possible to run it with jetty. I don't know if there are some connections or dependencies to tomcat....

EDIT / UPDATE:
I could not get it to run with jetty or the tomcat installed from portage. After this I tried the suggestion from logrusx. This way I do not have any problems anymore. Problem solved.

But I still wonder why it does not work with the tomcat installed via portage
_________________
My personal space
Back to top
View user's profile Send private message
logrusx
n00b
n00b


Joined: 22 Feb 2018
Posts: 13

PostPosted: Mon May 21, 2018 2:13 pm    Post subject: Reply with quote

*_-=Banana=-_* wrote:

But I still wonder why it does not work with the tomcat installed via portage

It's not intended to be used that way. It's intended to be set up and maintained by sysadmins.
Java is also not regular Linux stuff. Things in Java world have always been like that.
Back to top
View user's profile Send private message
archenroot
Apprentice
Apprentice


Joined: 13 Dec 2011
Posts: 164
Location: Lake Macha, Czech republic

PostPosted: Sat Jun 09, 2018 10:08 am    Post subject: Reply with quote

As per my understanding there are 2 things:
1. Gentoo install files into nonstandard structure different then when you download tomcat in zip distribution. This is fine, why not, but
2. Idea plugin for Tomcat is not capable of any kind of library scanning, so this little change make it non-working at some cases (per version, etc.)
_________________
Emperor wants to control outer space Yoda wants to explore inner space that's the fundamental difference between good and bad sides of the Force
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum