Intellij IDEA - Web Application - Glassfish - Logging - java

I wonder if there is a way to see System.out.println Messages in Idea when I´m using Glassfish to handle Websocketconnections. I cant find an Output Window where my messages are displayed. So if this doesnt work: How do you log with this setup ?

My glassfish log is located in the glassfish window under debug when I run debug. System out messages will show up here in the log messages. You can also find them by navigating to your glassfish log file. My file is located at:
C:\glassfish4\glassfish\domains\domain1\logs\server.txt
And here is a pic of that same log in the debug screen. This screen pops up automatically for me when I start the debug server.

Related

Running Weblogic Server in Debug mode on IntelliJ in Windows 10

I am trying to run Weblogic server on IntelliJ in debug mode. But I get the following exception
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate weblogic.management.configuration.DomainMBeanImpl.toString()
I tried deleting all the deployments through IntelliJ and config.xml file, still I get this issue.
However Weblogic is able to run fine when not in Debug mode.
Please feel free to reach out for any further clarifications.

Websphere works when run but fails when debug

I'm using Intellij with WebSphere 8. When I run from within IDE the server works normally. When I try to run it in debug mode however, it fails with the following error:
C:\IBM\WebSphere\AppServer\profiles\AppSrv01\bin\generated_websphere_server_start_script.cmd
C:\IBM\WebSphere\AppServer\java\bin\java -Dfile.encoding=windows-1252 -classpath "C:\IBM\WebSphere\AppServer\runtimes\com.ibm.ws.admin.client_8.5.0.jar;C:\IBM\WebSphere\AppServer\plugins\com.ibm.ws.security.crypto.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\webSphereIntegration\lib\webSphereIntegration.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\JavaEE\lib\javaee-impl.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\lib\openapi.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.1.3\plugins\webSphereIntegration\lib\specifics\webSphereClientImpl.jar" com.intellij.javaee.oss.process.JavaeeProcess 62847 com.intellij.j2ee.webSphere.agent.WebSphereAgent
Error: JDWP agent already loaded - please check java command line options
[2014-08-11 01:58:59,248] Artifact x.ear: Server is not connected. Deploy is not available.
JVMJ9TI064E Agent initialization function Agent_OnLoad failed for library jdwp, return code -1
Detected server admin port: 8880
JVMJ9VM015W Initialization error for library j9jvmti26(-3): JVMJ9VM009E J9VMDllMain failed
Detected server http port: 9080
Disconnected from server
I tried almost everything I have no idea what the problem is. I did google it for several hours with no luck.
Do anyone know what this all is about and how can it be fixed?
Here is my server configuration:
Solution 1
unchecked the Pass environment variables check box and restart the server in debug mode. it should work properly.
Run --> Edit Configuration --> websphere server --> Startup/Conections tab
select debug, you will see the Pass environment variables check box. it need to be unchecked for debug to work.
Solution 2
if debug mode of websphere is working in eclipse and not working in intellij that reason i found out is debugging serverice on the websphere is already started and intellij is again trying to start the debggin service. so stop the service from websphere console (Servers > Server Types > WebSphere application servers > [serverName] > Debugging Service) and all the default configurations in intellij should work.
I had the same problem. Finally I figure it out. I hope this solution helps. I'm using Intellij idea 2019.1.3.. and WebSphere 8.5.5.13
check WebSphere start server script find debug env variable name (in my script (WebSphere\AppServer\bin\startServer.bat)
WAS_DEBUG)
add same debug option name to intelliJ IDEA
run- debug configuration environment tab.
Since default env variable is debug and cannot be overridden
check pass env variables
add WAS_DEBUG option as I did
or you can update WAS_DEBUG as DEBUG (same as default in IntelliJ) in server startup.bat script.
Both should work.
Pretty old, but i was able to experience too!
They will try to fix this now in: https://youtrack.jetbrains.com/issue/IDEA-193580
firstly, sorry if the translation is not good, I am Brazilian and I would like to share the solution I made.
First: Locate the file "startServer.bat in "WebSphere\AppServer\bin" and open it with any text editor.
Second: Search for the second incidence of the word "WAS_DEBUG" and replace it with "DEBUG", as shown in the image...
Third: In Intellij, go to the server settings and in the "Startup/Connection" tab, select debug.
Fourth: Now uncheck the "use default" checkbox in "Startup script" and point to the location of the "startServer.bat" file in the webSphere directory.
Fifth: Right on the left side of the checkbox, there is an option to enter a parameter. Click and a "Program Arguments" field will appear. Enter the server name, in my case it was "server1".
Okay, now just test
enter image description here
enter image description here

Java Debugging Deployed Glassfish #PostConstruct Unable to Debug

I can debug a Java application in NetBeans and have debugged other projects in NetBeans. However, when deploying a Singleton in Glassfish and setting a breakpoint on the #PostConstruct annotation I am unable to debug. I have set the target server to debug on and I set the breakpoint where the debugger should debug from and I start the server in debug mode. However, I am still unable to debug in NetBeans. Below is the code:
#Startup
#Singleton
public class Listener {
#PostConstruct
public void init() {
System.out.println("init");
}
}
I set the breakpoint on the System.out.println("init") statement. The steps that I follow are:
1) Build Jar file
2) Start Glassfish server
3) Deploy the Jar file
4) Start the server in Debug mode
5) The "init" is printed in the Console in NetBeans but I am unable to debug.
I have tried attaching a debugger on many different ports, but I either get connection refused or it can't debug.
I am using NetBeans 1.7.2. I have tried the same with other versions of NetBeans but still the same problem.
The above is only a sample code, but there is more code but I am unable to debug. I can't find any solution on Google.
Could you give this a try?
You have to:
Start server in debug mode (when it start's dt_socket port is printed)
Attach debugger Debug -> Attach Debugger...
Set breakpoint
Deploy your app
#PostConstruct is called during deployment, so the order of steps you provided is incorrect, because the code is invoked before you attached to debugger.
Did you try this with eclipse?
As I remember, I had no problem in debugging the #PostConstruct method in eclipse.
On more thing to mention:
- A #Singleton bean lives as long as your application lives on the server... So if you want to debug its #PostConstruct, I would suggest opening the glassfish server console, and using the disable application option from console... until that, the #PostConstruct won't be called, since the bean is container managed...

Deploying a java play application

I created a small play application and generated the dist files using "play dist"
After running the "start" script, the application works locally, but when I try to unzip the file generated on a server or giving it to other colleagues, the output says :
./start
Play server process ID is 13585
[info] play - Application started (Prod)
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
When i access the server on port 9000 (http://correct-server-url-or-ip:9000) , the browser shows that the page is loading but it never loads.
If I kill the process on the server, the browser immediately shows an error.
I am not sure why it works on my machine but doesn't deploy on other machines with similar configurations.
Did anyone have a problem like that? or know how to fix it?
Thank you

dev_appserver - How to get error log

I use netbeans to develop a gae java app.
When i try to debug by
dev_appserver.cmd -p 8962 D:\Documents\NetBeansProjects\Reader\build\web
I got Error 500 null on http://localhost:8962.
I think there is something wrong with my program, I want to get the error log, but dev_appserver only show me INFO log, how to get error log?
In Google App Engine Launcher click on "Logs".

Categories