How to see GWT Jetty devmode from another machine? - java

When I fire up Jetty, it gives me the standard URL: http://127.0.0.1:8888/index.jsp?gwt.codesvr=127.0.0.1:9997
Great. I can see this URL from my machine. However, I cannot access this URL from other machine, and replacing the 127.0.0.1 with my actual IP address does not work either.
Does anyone know how I can make my server "sharable" so that other people in my network can hit off my machine as well?

Try to start the server with -bindAddress option using your external IP. See this.

Just follow the following Steps,
Right Click on Project
Go to run as ---- > Run Configurations
Select Arguments and add -bindAddress 0.0.0.0 to Program Arguments
Click On Apply & Run

Related

Java proxy settings - Ubuntu

How do I set the Java proxy settings in Ubuntu (10.04 or 12.04), from the command line?
What I am aiming at is to get direct connection, but by default it takes it from browser settings which are meant to go via a proxy - just I don't want Java to go via the proxy.
I am running an application server in Ubuntu which serves remote desktop sessions. I can put the Java control panel into the user's desktop, and then they (each individual user) can set the proxy settings under Network Settings. However - this means I have to tell each user to make this setting, which is not workable.
I want it set via some command line or environment variable on the server itself, so it defaults to "direct connection". I am not familiar with Java programming and it won't help much to give me Java code for this, I think it must be possible to set the defaults upon Java startup? Any pointers are welcome.
How can I do this?
Instead of command line you can edit $javaDirectory/jre/lib/net.properties.
Remove # in-front of:
http.proxyHost="proxy host"
http.proxyPort="proxy port"
https.proxyHost="proxy host"
https.proxyPort="proxy port"
and set your proxy there.
You can export the http_proxy environment variable via command line.
Ex:
$ export http_proxy=http://proxy-server:port
There is a environment variable ftp_proxy also, just in case you need it.

How do I debug Java servlet filters, on-the-fly, from a remote machine (I'm using Eclipse and Apache Tomcat 5.5)

I wrote a Java servlet filter on my local machine and deployed it a remote (machine) web server. Unfortunately, it's been very difficult and time-consuming trying to trace errors reported by Apache Tomcat 5.5, my JSP/servlet engine. I can't keep writing System.out.println(...), saving, deploying, testing JSP pages, and so on. It's taking too long. There has to be a better, faster way.
Is it possible to remotely debug servlet filters? I don't have a web server on my local machine, which is why I'm asking about remote debugging. Specifically, I'm looking for a way to debug, line-by-line, the servlet filter, on-the-fly, as it's happening on the remote web server. Does such a method exist?
Or, is there a better method than writing to standard output. It's taking too long and I feel that must be a more efficient means of debugging Java servlet filters.
Note: I'm using Eclipse for development.
Thank you very much for any help.
Update
Thank you all for your help. I really appreciate it.
I added the JVM argument to Tomcat, restarted Tomcat. Then, on the machine with Eclipse, I entered in the appropriate info in the Debug config, put the breakpoint in, and tested. Unfortunately, it did not work. In the config, I left it as Socket Attach, clicked apply, and that was it. I pressed the debug button and it said the connection was refused. I tried ports 8000 and 8001 and both did not work.
Let me explain what I'm trying to do, that might be better.
I have a login page called login.jsp. On that page, is a form whose action attribute is servlet/LoginServlet. When the user submits the form, it calls servlet/LoginServlet, which is mapped to a class in the web.xml file. Let's call this class com.mysite.mypkg.classA. In class A, it calls a method from another class called com.custom.mypkg.classB. I want to put a breakpoint in classB.
So, using the url with login.jsp page in the Eclipse debugger won't call it. I tried using servlet/LoginServlet and that also did not work.
What should I put in for the URL? Or, do I debug this type of setup?
Thank you.
Update 2
I found this site here, which is pretty comprehensive. I ran netstat -a and noticed that the debug port is not listed. Windows Firewall is turned off, but there could be another thing blocking the port, who knows. Anyway, I placed the VM argument here and it's not working.
Thank you.
For remote debugging you need to start the server in debug mode. There are couple of ways doing that.
1 > start the server using
catinlina.bat jpda start
2 > Add an jvm argument to the tomcat java process
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
Once the server is started in debug mode , you need to change the perspective of the project in eclipse to debug.
Then go to Run - > Debug configuration.
Double click remote java application and enter the details such as
Remote IP address
Debug port . Default tomcat debug port is 8000. If you use jvm argument, use the port mentioned in the jvm argument.
Click Apply
Go to the java file you want to debug.
Put a break point in the source code and run the scenario you want to test (Eg Web application using browser)
Also , ensure that the code in the java file is in sync with code deployed on remote server.
Happy Debugging!!!
Peace.
Sanket Raut
You can attach a debugger to a running Tomcat instance, provided that you gave it the right command line options when you launched it.
The Tomcat Development Wiki explains how to do this, and as a bonus gives you instructions on how to set up to debug from the Eclipse or NetBeans IDEs.
Of course, attaching a debugger to a running Tomcat has both security and performance implications*.
* And OH&S issues - you might get badly scratched if you tried this on the wrong kind of tomcat ...
You should run your remote tomcat with the following starup parameter:
bin/catalina.bat jpda start
Then in Eclipse on your local machine go to Run -> Debug Configurations -> Remote Java Application, create new configuration here, use IP of the remote machine as a host and 8000 as a port there
Run this configuration and use the breakpoints in Eclipse for debugging

Remote Debugging with Intellij Idea

I came to know of the remote debugging procedure under Idea recently. What I do is copy the configuration of remote debug under Run | Debug Configuration in Idea to the command line java execution parameters. The actual command line parameters are:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
If it is a script, I add these commands to it. By doing so, the command line displays the message:
Listening for transport dt_socket at address: 8000
So the debugging can happen using the local source code. However, I don't properly understand how remote debugging work. Anyone who knows how remote debugging actually works, please give me an explanation.
Thank you!
Remote debugging means that you can run your Java code anywhere, either on the local or remote machine. When it's running in the debug mode, you can connect to it from the IDE using TCP network connection and perform debugging. IDE needs to have the source code for the running classes so that you can place breakpoints inside this code and perform stepping, inspecting variables, etc.
If you are interested in technical details, refer to the JPDA documentation.
Consider a scenario where you want to fix something in your application but your application only can run over a server machine because of other dependencies.
That is where Remote Debugging come into picture. You Just connect the sever by providing the hostname and port and connect it with your respective environment.
How It works:
Application to be debugged will attach a socket to itself and then will start listening debug instructions.
Debugger will bind itself to that socket and then send instructions.
This is best way to test your code which are in different environment .
we need to have below points for sure before you are using remote debug .
we are using JBOSS in our servers.
configure - JBOSS_HOME/bin/run.conf
JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
now add the server IP and port number into the intellij remote debugging .
4.your should have the latest version of the project in local that is in synch with the server else debug will not be allowed.
you need to start the intellij server for the project .
Then start the remote debug .
place a debug point in local and when we start testing in the server , when it hits the debug point it will stop and wait untill you process it .
The other point is , it will hold all the request in the queue and will not allow anyone to go through the break point which may stop other users to test it .

GWT run on External Server

I need to test my client application on an external server, with the development mode to a better debug.
i try to run in eclipse the application on the external server, but it doesn't run.
i realy need a step-by-step example
thanks for the help
Check out THIS page. There they have a command how to start your server with GWT debug mode on.
Than make sure your URL is pointed to the right server.
This is how it should look on your machine:
http://{local ip or host name}:8080/AppName/?gwt.codesvr=127.0.0.1:9997
This is what should be entered on the external clint on the same network:
http://[YOUR-IP]:8080/AppName/?gwt.codesvr=[YOUR-IP]:9997
Make sure both ports are matching. Mine is running 8080 because I'm running Java server, you might have different port.

Cannot debug on an Android device

I've connected my Nexus One device to the PC. The USB debugging on the device is on. When I run the app from Eclipse, it works fine on the device. However, if I attempt to Debug, i get a message box on the Nexus One stating that it's waiting for the debugger to attach. On the Eclipse side, after about 20 or so seconds of thinking I get the following in the Console
Attempting to connect debugger to 'com.angryhacker.printerfun' on port 8600
Launch error: Failed to connect to remote VM. Connection timed out.
What am I missing?
1) Enabling USB debugging on the device is the first step. It sounds like you've done that ... but it wouldn't hurt to double check everything:
http://developer.android.com/guide/developing/device.html
2) As the same link also says, make sure debugging is enabled in your project's AndroidManifest.xml
3) Definitely check your host PC's firewall (for example, Windows firewall) to make sure it isn't blocking any ports.
4) For troubleshooting purposes, you can also try:
a) setting a longer timeout
b) trying a different port#
ADDENDUM:
Q: I'm assuming you've NEVER successfully downloaded and run an .apk from your Eclipse compiler to your NexusOne handset. Correct?
Q: I'm also assuming that when you try "Debug As", you see your physical handset in the GUI, and you've selected it. Correct?
Test to see if it works when your PC is not connected to the net (no WiFi, no network cables). If it does work under those conditions, then it may be that you need to make sure that addresses are resolving to localhost properly. The messages that DDMS and adb.exe use for debugging and communicating to the VM must properly resolve to localhost on your PC. (Yes, it's odd that other commands using DDMS & adb work just fine but debugging doesn't. Seems that something in DDMS or adb needs to be standardized so they all work under the same conditions.)
If you need to make sure that things are resolving to localhost properly:
1) Make sure that this line is in your /Windows/System32/drivers/etc/hosts file:
127.0.0.1 localhost
(you can have any amount of whitespace between "127.0.0.1" and "localhost")
2) If that doesn't work, then you may need to also add your PC's IPv4 address to the hosts file, and resolve it to localhost. (You can find out the IPv4 address for your machine with the ipconfig command.) If, for example, your machine's IPv4 address is 192.168.1.100 then you'd add the line
192.168.1.100 localhost
to your hosts file. (You can add it below the "127.0.0.1 localhost" line in the file.)
You can verify that adb (and your emulator if you're running one) is listening on ports by using the netstat -b command. (Note that you need admin privileges for the -b option. I open a command window using "Run as Administrator.")
I had the same error on Windows 8. I tried all the points as suggested by the answer from #paulsm4 but still nothing worked.
The problem got fixed when I set the compatibility mode for eclipse.exe to Windows XP SP3.
Hint: Right click on eclipse.exe => Properties => Compatibility => Compatibility Mode => Set the compatibility mode to "Windows XP (Service Pack 3)"
One more possible cause of such issues is the intent-filters in your activity.
When some intents are defined for your activity, you might not be able to debug the application. For example:
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<action android:name="com.android.setupwizard.COMPLETED" />

Categories