I finally decided enough was enough today and I'd put my mind to getting Tomcat debugging to work in IntelliJ, something I've always meant to do, just never got round to.
Firstly I needed need to get Tomcat Server to show up in Run/Debug Configurations and Application servers to show up in Settings > IDE Settings . It wasn't there so I went to Settings > Pluggins and and enabled Tomcat integration. After the IDE restarted I added my Tomcat to the Applications Servers section by opening Settings > Application Servers > Add, it asked me for my Tomcat home and base directories ("tomcat home" where the bin is and "tomcat base" is where the "webapps" directory is, on my deployment the conf director was in base location and IntelliJ was expecting it to be in home, so I had to symlink it in).
Then selected the Run/Debug Configurations menu, clicked Add, selected Tomcat server (local in my case), give it a name and leave the defaults as they are.
I needed to create an artifact in Project Structure to link to my tomcat webapp. This was a simple task of choosing Add >Web Application Exploded an adding the source folders.
I needed to tweak some stuff to get tomcat to play nicely, IntelliJ wanted to start tomcat by running ./catalina.sh run, starting tomcat this way was giving me Tomcat – Java.Lang.OutOfMemoryError: PermGen Space error, in the end I added this to the catalina.sh file
JAVA_OPTS="-Xms536m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=256m $JAVA_OPTS"probably not the best way of doing things, but it did sort out my start up issues!
All this required a lot of starting tomcat, a quick way to find tomcat process id in order to kill it (presuming your running on 8080)
$ sudo netstat -lpn |grep :8080 tcp6 0 0 :::8080 :::* LISTEN 6447/java $ kill 6447or $ kill -9 [proc id] if your hard core!
Anyway, debugging is now working, I haven't explored all the options but did check the "persist sessions" checkbox which means you can pick up where you left off between restarts which is magic! And, hot swapping seems to work (on occasion).
Why didn't I get this sorted ages ago?!
No comments:
Post a Comment