How to run Jetty server in a LAN? - java

I'm running in some troubling deploying my app on a Jetty Server.
If i try to access my app using localhost:8080/appName it works just fine. But if I try to use my IP it doesn't work (I mean on the same computer, ip given by the ipconfig tool)
I don't really know why, All I know is that I launch my server directly from Eclipse with the Goals set to "-jetty.host=0.0.0.0 -Djetty.port=8080 jetty:run" funny thing is, that even if I forgot or put something else for the jetty.host parameter (like Djetty.host=127.0.0.1) I always have "2014-06-18 16:59:52.238:INFO:oejs.ServerConnector:main: Started ServerConnector#1b79a565{HTTP/1.1}{0.0.0.0:8080}" in my console output.
Any idea where I do something wrong ?
Thanks !

Related

.bat file not running when executed by app as windows service

So, I have this client-server app which is written in 4th Dimension Language, that runs as a service so it restarts automatically if something happens to the server. This language has a built in function which allows you to run cmd commands and I have another java app in the same folder, that is in charge of sending emails, something my server side app cant handle. We use a command for running this jar from cmd and send the parameters from there, creating and xml for it to create an html from that and send it via email. The thing is when I run this command with the app running as a service, the command simply does not run, but, if I run the app normally, it works like charm, with no problems whatsoever.
At first I thought it could be the paths, so I got all the paths to be absolute, using the full route, yet it doesnt work still. Also I tried exporting the command as a bat and running it by hand, in the exact same path were the server is, and it works just fine. I thought that maybe the service needs some sort of admin privileges, so I started it as Admin from the service, but it changed nothing.
Is there any chance the service has some sort of limitation which doesnt allow the app to execute external commands? If so, is there anyway to bypass this limitation?
Well, I couldn't make it work when it was running by service, so I made a bat with the command the service uses and pasted it in the Windows Startup Folder, so it "opens manually" when windows starts. It's not the real answer, but is workaround for needing to use the service.

Using awt.Robot with Tomcat service

I am trying to simulate user input (keyboard) using Robot library from java.awt, and it is working on my development enviroment, but when deploying to Tomcat (installed as a service on a different machine), it wont work at all. My OS is Windows.
Is there any configuration that I am missing? I already tried "let tomcat interact with the desktop" option, changing users to run the service, changing java used by tomcat (from jre/ to jdk/jre/..), but still I can't make it work.
Also, if it is not possible, is there another way to achieve this?
I finally solved this, not in the best way I guess.
I stopped Tomcat Service, and then started it from CMD as the current user.
Steps to open tomcat from cmd:
Open cmd.exe
Path-to-tomcat\bib\tomcat7.exe
And then opened my browser, went to the application, tried the proccess and the robot worked correctly!
I know this is not the best way as it can led to security issues, but I couldn't make it work using it as a Service because the different user sessiones (Session 0).

Running a Web Service without opening Eclipse or any IDE

I want to develop a Java based Webservice on my laptop. This webservice will take one input parameter, query my SQL Server database and will fetch information and will return it back.
I know, I do not need a webservice here. But, right now, I am just testing my android application which will call this webservice and will show return data on my device.
So, I have developed a java program which connects my SQL Server Database (which is present on my laptop) and returns a value against the parameter passed. I have made it a webservice by creating endpoints and publishing it from another class.
For reference, something like answer on this thread
So, when I run it from my Eclipse, I can go to a browser and run my webservice, pass parameter and get result.
But, once I close my eclipse, its no more accessible. I am new to this and after studying I am guessing that I will need IIS to host it on my laptop.
I want to ask, whether it is possible to run/publish it locally on my laptop as a background process so that I can test my android app by calling the same?
Future scope -
I am going to deploy this webservice in my company which will connect my database. Both webservice and sql server will be on same machine. I am going to call this webservice remotely over internet from my android device to show the results.
I guess, I will need IIS in future right? Is there any other way to fulfill this requirement? Please provide some ideas.
If, within Eclipse, you can get your web application deployed so that it is accessible via a browser, then you definately can do it without eclipse.
Eclipse uses plugins like Tomcat or Glassfish to run your webserver. These programs are available outside of Eclipse as standalone services. You can install these and run them as background processes at the command line.
Just figure out which one you are using in eclipse (or which one you want to use) and look for a standalone copy on the web.
Here's Tomcat, btw.
I am done with this.
What I did is, I went to Eclipse, selected my Project-> Right Click -> Export -> Under General -> Ant Buildfiles
This created, Build.xml in my Project directory.
I deleted all the class files and recompiled them using ant command.
In my case, target name was build-project which compiles all the java files.
So, I did ant build-project
Note - This was done as Eclipse was using different JDK version.
Now, I called my publish class to publish my webservice with
ant publish
This was half done as this was running in interactive mode.
Then I created a bat file with following command -
"path_for_ant_bin_directory\ant" -buildfile "path_to_build_file\build.xml" publish
This was opening up the command box. So, I created a vb script to run the bat file in background
Set oShell = CreateObject ("Wscript.Shell")
Dim strArgs
strArgs = "cmd /c path_to_bat_file\my_bat.bat"
oShell.Run strArgs, 0, false
And, now it nicely runs in background and I can access my webservice.
Hope it helps someone with similar requirement.

Trying to view deployed JSP page online. XAMP / Tomcat

I've been using XAMP and it's features for some php sites and it's working fine. I'm now needing to use it for JSP development for a project we're about to start working on.
So far it's functioning on my local machine in that I downloaded the sample war file from Tomcat and it deploys fine and is visible when using localhost:8080/sample.
The problem is that I can't seem to access it from a browser using the domain name. I tried www.mydomain.com/sample but receive a 404 error.
The same when using my local IP address instead.
I've searched online for a while now and have come across a few sources that hint at integrating apache with tomcat but nothing concrete enough to try and get a working solution.
I've also tried (and miserably failed) to watch the video that is referenced in a few other questions.
Any help is hugely appreciated,
Thanks.
that's because tomcat works on port 8080 unlike apache - when you run php sites they are just behind the apache which is visible on port 80 (which the default one in browsers), you can go through "http://mydomain.com:8080/sample" and it would work the same as through localhost
you can also change tomcat's settings and change it's connector's port from 8080 to 80, and then it would work as you expected

Connection Error: javax.microedition.io.ConnectionNotFoundException:TCP open

I posted this error here cuz it has been disturbing me for long time whenever i try to connect to my web api from my j2me application.I just would like to share this if somebody has same problem as me.
When this error happened to me, it was because my web server (tomcat) was not running. Make sure that your web server is up and running then try again.
my solution to this error is i changed in host file which is located at C:\Windows\system32\drivers\etc\ and i opened the ip that i m trying to call.
the other attempt i did if this one is not working is check the instances whether they are already run or not. This is also one option which really did solve the TCP open error.

Categories