How to choose quarkus profile when running app under Idea? - java

When running my app from within Idea, I see command line ends with
... -Ddebug=38605 quarkus:dev
and dev profile is active. It doesn't depend on whether I press debug button or run button.
How to switch to prod profile? If I go to run configuration and enter
the command line changes to
... -Ddebug=38605 quarkus:dev -P prod
and the profile remains dev

This is not a Maven profile but a Quarkus profile.
You need to use -Dquarkus.profile=prod or the QUARKUS_PROFILE environment variable.
See https://quarkus.io/guides/config#configuration-profiles for more details.

You should use Runner - VM Options = -Dquarkus.profile=prod to specify quarkus profile in IntelliJ IDEA Run Configuration.
There is an issue in IntelliJ IDEA tracker, probably it should be simpler: https://youtrack.jetbrains.com/issue/IDEA-259900

Related

Debug remote java application using Intellij

I am trying to debug remote java application in Intellij but unable to get sucess, The steps which I am doing is
Run>Edit Configuration> Defaults> Remote
What is/are I am missing?
First, create a new Remote debugging configuration:
ALT + U + R
Take note of the port which IntelliJ plans to listen in Tomcat. On my setup the port is 8000, which is the default and this should be fine for your setup as well. To change the Tomcat JPDA port, edit catalina.bat (or whatever your startup script is) and find a line which looks like the following:
set JPDA_ADDRESS=8000
Second, make sure that you are building your project with javac -g .... The -g option means that debugging information will be turned on in your Spring WAR.
Finally, when you start Tomcat, use catalina jpda start, which will tell Tomcat to connect the debugger to port 8000. When you want to connect to IntelliJ then use ALT + SHIFT + F9 and select your remote configuration from the menu. Of course, you should add some breakpoints, without which it doesn't make much sense to be in debug mode.
You don't need to edit the defaults. You need to use the [+] button to create a new Remote run configuration and specify its settings.

Groovy Grails Tool Suite too small heap size, but only on Debug

When running Groovy Grails Tool Suite (GGTS) version 3.6.4 (latest as of June 2015), on Windows 7 Home 64bit, I get a "Error occurred during initialization of VM Too small initial heap for new size specified". I have a JAVA_OPTS System Environment variable of "-Xms512m -Xmx512m" I also have that same value inside the GGTS Menu: Run => Debug Configurations... Arguments Tab, VM arguments. This error does not happen when I do a run-app inside GGTS, and the app successfully starts. But, when I do try to run using Debug, with the run-app Debug Configuration, I do get this error. Where else could I possibly set the heap values to make this work in Debug? Any ideas of what else to test, fix, or set to fix this issue?
Could not get GGTS to launch my app, no matter what changes I made to -Xms and -Xmx everywhere I could find to make the change. Kept getting the same error. Finally, I stumbled upon this method of setting up the debug. Step 1, start the app from the console (not within GGTS):
grails -debug run-app
Step 2, in GGTS follow these directions to hook-up to the "grails -debug run-app" you just started (use port 5005 - as displayed in the console window), and when done, click the Debug button at the bottom: Create a Remote Java Application launch
Now, debug launches and I can set and view breakpoints inside GGTS.

Intellij IDEA remotely debug java console program

I have a remote server with Java running to which i have SSH access.
I am writing an app on the local machine, building it with maven.
Is it possible to set the IDE Itellij IDEA to run my project remotely? The idea is : to build the jar, copy it to the server, and debug the process ( or something like that).
It would be nice of you to share the settings i need to setup.
This is what I usually do to debug my remote app.
Run the server on debug mode
This can be adding this particular line when you run your application server
-Xdebug -Xrunjdwp:transport=dt_socket,server=n,suspend=n,address=9999
for JDK above 1.4, you can use this
-agentlib:jdwp=transport=dt_socket,server=n,suspend=n,address=9999
After that, run your application server
SSH Tunneling
I'm not 100% sure that you can access to your application's port directly if you're using ssh connection (well, maybe there is a way ;) ). So, first we need to expose the port for debugging that we set on first step by running this command.
ssh -f user#personal-server.com -L 9999:personal-server.com:9999 -N
Setting up the IDE
You can follow the step that #SSJVegito has said, which basically, is to point the debugger to the port 9999. Open the debug configuration in your Idea, then Change the circled value to 9999. Then, happy debugging :D
I think it's possible, I was able to do such a thing with a local server I was using to deploy my application. And since you have access to the server, it should work for you as well.
What you need to do in IntelliJ is create a Remote configuration. To do that, open IntelliJ and next to the run button (on the left), you should have your configurations, designated by a down arrow. Click that arrow and click Edit Configurations. A new window should open. Click the + sign in the upper left corner and the select Remote. A new window should appear. We now need to set the host and the port which the server uses for debugging (if you are using tomcat, it is usually 8000; in tomcat, you can locate it by opening the catalina.bat file with a text editor and looking for the JPDA_ADDRESS property, which allows you to change the port). Give your configuration a name and press Apply.
Afterwards, you need to run your configuration in Debug mode. You need to select it from the configuration list and press the Debug button located to the right of the Run button.
More details here:
http://blog.trifork.com/2014/07/14/how-to-remotely-debug-application-running-on-tomcat-from-within-intellij-idea/comment-page-1/
http://eclipse.org/jetty/documentation/current/debugging-with-intellij.html
http://www.javaranch.com/journal/200408/DebuggingServer-sideCode.html
I hope this helps.

IntelliJ - why does the terminal has different environment variables values

I have recently replaced Java 7 to Java 8.
All regular apps in IntelliJ runs smoothly.
All but the tomcat apps - which run from the cmd command line but not from IntelliJ.
It fails to load due to an error in the JRE_HOME definition.
I have oviously defined JRE_HOME in the env variables and in the jdk settings.
I have executed
echo %jre_home%
both in the IntelliJ terminal and in the cmd and received different values
(IntelliJ terminal showed unupdated value.).
Where are the variables in the terminal declared?
How do I change them?
I don't know about old IntelliJ versions, but in 2019.2.3 one can configure environment variables in project settings. Be aware, you need to restart existing terminal or create new terminal tab to see the effect.
Almost 5 years later, I have the same issue on Windows 10 and had to restart my computer to solve it.
Edit:
The best solution is to not define a JRE_HOME environment variable. I don’t know why but IntelliJ stucks using that env variable.
If you are launching IntelliJ via the JetBrains ToolBox it will cache the $PATH variable so recent changes will not appear.
Just close and re-open JetBrains Toolbox.
For me it was because IntelliJ IDEA did not launch the shell as a "login" shell. All of my environment variables are set as I expect in a login shell, but in a non-login shell, many of them are missing.
By way of example, I expect /usr/local/bin to be in my PATH, but that is only true within login shells (as I get when I run iTerm2). This is an excerpt from a terminal session within IntelliJ IDEA:
amacleod#valjean ~> echo $PATH | grep -c /usr/local/bin
0
(1) amacleod#valjean ~> $SHELL --login
Welcome to fish, the friendly interactive shell
amacleod#valjean ~> echo $PATH | grep -c /usr/local/bin
1
One possible workaround would be to add my expected PATH and other variables to the shell configuration for non-login shells, but I would really rather just always be in a login shell.
I would have hoped that IntelliJ IDEA would have a checkbox for sending --login in the Terminal settings. However, it is possible to override the Shell path setting to include the login flag.
Invalidating the systems cache should do the trick. see JetBrains: Invalidate Cache.
Any other measures (like closing projects and IDE seemed to work only on a per project basis and only after a while (when IDE detected that the cache is invalid by itself ...)
Edit:
Correction - Unfortunately, after having the corrected the environment in all terminals for a while, IntelliJ "reverted" to the old, incorrect environment in any of my projects. Now I hope that after a reboot - as posted by akuman8 - the issue is solved. (If not, I will stick to a commandshell of my choice outside the IDE, where everything works fine ...)
For me, invalidating the system cache or restarting IntelliJ didn't reload the updated environment variables.
After restarting the computer, it enabled IntelliJ to pick up the updated environment variables.
AFAIKT, the intellij terminal on linux is just the same as running a standalone terminal session. It's just conveniently located in the IDE.
In response to the question, "How do I change [the terminal environment variables]?"
I'm using virtualenvwrapper to manage my terminal's environment variables for different environments, such as dev, test and production. It's working just as well for java development as it was for python development.
https://virtualenvwrapper.readthedocs.org
Close all IntellJ windows and any process that may currently be using the wrong SDK.
Navigate to the folder where your JDK is installed (e.g. C:\Program Files\Java).
Rename the wrong SDK so something else (e.g. jdk-11.0.5.OLD). If it won't do this, you may still have a process running using that SDK; go back to 1.
Start IntelliJ again.
It seems you can define project specific environment variables:
In IntelliJ project specific environment variables you can set under
Run/Debug configurations --> Defaults --> Application --> Environment
variables
from:
http://emmanuelbernard.com/blog/2012/05/09/setting-global-variables-intellij/#comment-617922540

Websphere admin console not working

I have trouble opening the admin console for the websphere server. The server is up and running though, the application deployed and all. The only problem is with the console which gives a 404 error. Does anyone know how to fix this? Maybe reinstall/restore the console somehow?
Thanks.
You can try to reinstall the admin console :
Goto C:\[PATH TO PROFILE]\bin
Then run the Jython commands, first to cleanup, then to reinstall :
wsadmin -lang jython -f deployConsole.py remove
Wait till the admin-console is uninstalled.
Now reinstall of administrative console (isclite) will complete without errors (hopefully)
wsadmin -lang jython -f deployConsole.py install
Admin console should work now.
I had a similar problem. I was able to solve it by:
Deleting the existing profile
Creating a new profile
Running the WAS in RAD with that newly created profile
Profile management :-
Method :- RAD -> windows > prefereneces > server > websphere application server > selecting the websphere server 7.0 > click the run profile management tool button in the bottom section.
Check and make sure the DMGR is up and running on the primary node. Start --> Run --> Services.msc. Look for something that looks like "IBM WebSphere Application Server V6.1 - CellManager01" and ensure it is running. If not, browse to the installation location of Websphere "AppServer\profiles\Dmgr01\logs\dmgr" and look in the Systemout.log and the SystemErr.log for details. Also look in the "AppServer\profiles\Dmgr01\logs\ffdc" directory.
You can try this before trying to delete the new profile. I had this same problem where console was not coming up. I closed the RAD and re-opened it but didnt work. Go to Window --> Reset Perspective and then go to show view and get the console.
If still you cant see the console, go to customize perspective and click general and enable console.
If this doesnt work then only delete and recreate profile.

Categories