I'm unable to debug applet when it is in the WAR file. I use Eclipse IDE and Win8. My java version is 7 15.
I'm going to list my steps and maybe there is something that I do wrong:
1) First of all, I go to "Control panel->Programs->Java", then on "Java" tab I select "View". New window opens.
2) Then I enter the following line into "Runtime parameters": (without quotes) "-Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,address=1888,suspend=n", then I click "OK", "OK".
3) In Eclipse IDE I build war file.
4) Then I navigate to "Servers" tab, right click on my tomcat server and select "Debug". Now I can reach my project on my browser using this address: "localhost:8080/myProjectName".
5) On Eclipse IDE I go to "Run->Debug Configurations...->", then I select "Remote JAVA application" tab. Let's say there are no elements on that tab, so I right click on "Remote JAVA application" and select "New".
6) I set connection type to "Standart (Socket Attach)" and then I set "port" to 1888 and host to "localhost", then I click apply.
7) After clicking apply I do not close that window and I click "Debug". Window closes and IDE spits out error window "Problem occured. 'Launching myProjectName(1)' has encountered a problem. Failed to connect to remote VM. Connection refused."
--- Additional info ---
I use java server pages on this project too and then I set
JPDA_OPTS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
in catalina.bat file and run server from command line by typing
catalina.bat jpda start
I'm able to debug java beans, but not the applets.
This is because beans are running on the server side and the applet runs on the user side.
My whole application or applet was not signed, so my system failed to attach runtime parameters for debugging from Java Control Panel.
Related
When I am developing I run my application locally on an OC4J instance on my PC and I can start the server from eclipse, deploy the application to OC4J with maven, view it in the browser and debug it in eclipse. I am trying get the same set up in IntelliJ.
The steps to set it up the server in eclipse are:
Preferences > Servers > Runtime Environments -> Add (Oracle > Oracle
OC4j Standalone 10.1.3n)
Open the server configuration/overview window from the servers view
Server Properties > set username, password, port etc
Click "Open Launch Configuration"
Arguments tab > set VM arguments
Classpath tab > User entries shows oc4j.jar ~ C:\oc4j\j2ee\home
Source tab > shows my project directory and a 'Default' directory
JRE tab displays the jdk I am using
When all this is set I can run the server from eclipse and debug my application.
I've done the following in IntelliJ (but it's not working...)
Run > Edit configurations
Add new configuration
Select JSR45 Compatible Server (I've read this is the one to choose for OC4J)
Give it a name, mainly use default values, add OC4J_JVM_ARGS to 'VM Options Variable' box
add -start to VM Options (I've also tried adding all the vm args from eclipse in here)
Startup/connection tab: add C:\oc4j\bin\oc4j.cmd to Startup script box (I can't add the oc4j.jar from C:\oc4j\j2ee\home)
Now when I try to run the server from intellij I get the following output:
C:\oc4j\bin\oc4j.cmd
Usage: oc4j.cmd [Options]
Options:
-start : start OC4J
-shutdown -port -password : stop OC4J
-version : display the version
-help : display this message
Disconnected from server
This seems to be normal and is what happens when you run C:\oc4j\bin\oc4j.cmd, but I don't know what start up script I should be setting in intellij
Can anyone advise? Where should I specify -user and -password in Intellij? Thanks a lot
It seems that the 'Startup script' and'Shutdown script' boxes on the Startup/Connection tab in IntelliJ are not just file inputs, you can also type commands in there. So OC4J can be started by changing my intellij steps as follows:
Run > Edit configurations
Add new configuration
Select JSR45 Compatible Server
give it a name
mainly use default values
add any VM Options you have
add OC4J_JVM_ARGS to 'VM Options Variable' box
Startup/connection tab:
add "C:\oc4j\bin\oc4j.cmd -start" to Startup script box
add "C:\oc4j\bin\oc4j.cmd -shutdown -port=(your port number) -password=(your password)" to Shutdown script box
OC4J can now be started from intellij
How can I use the Netbeans visual debugger in a Java Web Application ? I have no main method in my project.
Is it possible?
I'm doing the following steps:
Start Apache Tomcat in Debug Mode.
Right click on Project -> Debug
Web Application is correctly launched. But execution doesn't stop and wait on the selected breakpoints.
I created setenv.bat file in tomcat\bin folder with these commands:
set JAVA_HOME=C:\Program Files (x86)\Java\jdk1.8.0_92
set JRE_HOME=C:\Program Files (x86)\Java\jre1.8.0_92
CATALINA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n"
In Attach Debugger I specified SocketAttach, dt_socket, Host=localhost, Port=8000
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.
I have an application that I deployed in tomcat. Later I configured the code as a project in Eclipse. I want to connect to the tomcat via eclipse and debug the application.
Trying to setup a remote debug connection is throwing up errors. Is there any entry that I need to add somewhere in tomcat?
First, you need to run Tomcat in debugging mode. The easiest way to do that is to modify the startup file (.bat or .sh depending if you are Windows or not). Find the line near or at the end of the file that contains the start command, and change it to jpda start. This will cause Tomcat to start in debugging mode listening on port 8000.
Next, to connect to this process via Eclipse, select the Run menu and choose Debug Configurations.... In the pane on the left, choose Remote Java Application and click the New launch configuration button above the list. The important settings to note are the Host and Port fields. The host value must match the hostname of the Tomcat process, and the port should be 8000. You also might need to add entries on the Source tab to ensure that all of the source code is available to step through.
Create a new tomcat server
Create a new dynamic web project
Export war to tomcat server
Tomcat debug configuration(important), first double click tomcat server, then select "Use Tomcat installation (takes control of Tomcat installation)"
Add breakpoints
Run tomcat in debug mode
Test war in web browser
Edit source path
Debug source code in Tomcat
The war file is available here.
yes, you need to configure tomcat to accept remote debugging connections. There is a FAQ on how to do it with various IDEs.
http://wiki.apache.org/tomcat/FAQ/Developing#Q2
Simply change the line in startup.bat (if you are using Windows)
from:
call "%EXECUTABLE%" start %CMD_LINE_ARGS%
to:
call "%EXECUTABLE%" jpda start %CMD_LINE_ARGS%
Right Click on the project you want to debug and go to Debug As Menu and in the list click on Debug Configurations.
Then Double click on the Remote Java Application from left menu list. browse for the project u wanna add in then click apply.
Also change the listening port to 7999, then after you started the web app from your localhost click the debug button on the same window. Then any break point's will be hit after that.
Steps to setup the tomcat Debugger with eclipse
Install the following things:
java 1.8+
eclipse EE version
download tomcat 8+
open eclipse and go to servers tab and add a new server(window-> show View-> Others -> Search Servers)
Mark your project as Dynamic web Project(Rightclick on Project-> project facets -> select Dynamic web module)
Export war (File-> Export-> search war -> select module and choose the path)
Run as -> Run on Server
Start the tomcat Server in Debug or Run Mode
check on localhost:8080
Debug worked for me. I was using tomcat 8, configured on centos 7. Debug port opened for me after changing 2 settings.
Open tomcat/conf/bin/startup.sh and added below lines
export JPDA_ADDRESS=8000
export JPDA_TRANSPORT=dt_socket
In the same file startup.sh, added jpda before start command.
exec "$PRGDIR"/"$EXECUTABLE" jpda start "$#"
Restart the tomcat.
In eclipse go to Run>Debug configuration>Remote java application>Add host ip and port(8000) where tomcat is running.
In my case i required to open 8000 through firewall too.
firewall-cmd --zone=public --permanent --add-port=8000/tcp
firewall-cmd --reload
Beside remote debugging, you can debug your app locally within eclipse if you added tomcat in eclipse.
just start server and wright click your app and from debug menu hit debug on server.
If you have multi module maven project, debug on server just shown up for module with war packaging.
If you want debug a class that runs at startup by self, like methods that annotated with #PostConstruct, remember that you should increase server timeout.
To do that, go to server view and double click on tomcat and in server preview tab, increase the timeout value.
I'm using netbeans 6.1.
I've got the following in my java run time settings:
-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n
and the following in the attach dialog in netbeans:
Debugger: JPDA Debugger
Connector: Shared Memory Attach (Attaches by shared memory to other VMs)
Transport: dt_shmem
Name: jdbconn
I got the above settings from the FaqDebuggingAppletRemotely page on the netbeans Wiki.
The applet is in an aspx page (the applet, whcih is signed, is a method of communicating via the client browser to a legacy platform, I'm a C# developer really). I've managed to get the security warning to display which gives me a chance to attach to the applet but whenever I try to attach I see:
Attaching to jdbconn
shmemBase_attach failed: The system cannot find the file specified
in the output window in netbeans.
Any help gratefully received!
I would bet anything (almost anything ... maybe a few dollars at least, or a cookie) that the JVM installation your applets are running on is NOT the same as the default JVM installation that is installed on your system.
To find the JVM installation that your browser and applets are using in Windows 7:
1) Close all applications that use the JVM (especially the browser).
2) Open the windows task manager (CTRL+ALT+DELETE->Task Manager), and click on the processes tab.
3) Make sure there are not any java*.exe processes running.
4) Open your browser and go to the applets page, and start the applet up again.
5) Now go back to the Task Manager->Processes tab and look for the java*.exe that is now running (it will most likely be "java.exe *32" literally, as in it will literally have an asteriks in the name of the process. If you don't see that one, then just use whichever one IS running).
6) Right click on that process, and in the context menu select "Open File Location". This should bring you to the "bin" folder location of the installed JVM that your browser is using to run your applets! Are you surprised that it is not the same as what you thought it would be?
To find the task on linux or other systems:
I've only ever had this problem on Windows, but here's how you do it anyhow.
Open a shell, and type the following
ps -e | grep java
And make a note of the pid(s).
Now that you know which JVM your applets are using:
We need to open the Java Console for that partivular installation (as opposed to the default installation we tried to modify before).
To open the Console of the JVM installation that your applets are using, and set the runtime parameters:
1)Open a command prompt (shell or whatever) in the bin folder of the JVM installation. (In windows 7, from the explorer, you can shift+right-click on the bin folder, and select "Open Command Prompt Here").
2) Run the following command to open the console:
javaws -viewer
This also ends up opening the "Java Cache Viewer" window, which we do not need. Close that window, but keep the "Java Control Panel" window open.
3) You can now go to the Java tab, click on view, and modify the runtime parameters just as you did before:
-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n
4) Click "OK", and then click "Apply" in the main java console window to apply and save all the changes you made.
5) WAIT! There is one last thing that I suggest you do; clear out the java WebStart cache to make sure your applets download fresh using the new parameters:
javaws -uninstall
Be sure and run this in the bin directory of the JVM installation that your applets are using, since this might not be the same bin directory that is pointed to by your Path (or PATH) system environment variable.
Now start up your applet from your browser, and create another shared memory connection inside your NetBeans IDE! Setup break points in the correct source code you are debugging ("source" tab in NetBeans), and start using your applet. You should now see that Netbeans is breaking on your break points!
At least, I hope so...
When you debug with the shared memory option (transport=dt_shmem), you're using Windows internal shared memory objects to communicate between the debugger and the jvm.
This means that if you're:
a. Not debugging from the same physical machine as your jvm, or
b. Not working on a Windows OS,
You can not debug in this mode.
I'm not sure what would happen if you ran a Window on a VM on a Linux station...Might work and might not.
If both of the above are fine, it would require a deeper investigation to find out the problem, but in the mean time, you could attach with a plain socket.
In the Java run time parameters specify:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=y
This tells your jvm to run in debug mode, load the jdwp library, wait for connection to attach in port 8000, and suspend execution until such a connection arrives.
In your IDE set the remote debugger accordingly. I don't know Netbeans, but it would be something like Connector = socket connector, address=8000.
When you start your web page, the applet will freeze loading until you connect, and of course you can't connect until it has reached the listening stage.
Good luck!