I am currently developing a web server. I am at a stage where 99% of the work is building the business logic, data logic and running tests. In other words, I have no need for the project to run in tomcat.
Right now, I created a test class that runs a mixture of the current code I am working on and prints info to the console. I have to restart the web server each time I make a change, which wastes a few minutes each time. Then I have to GET the localhost:8080 and wait for the page to load before I can read the printed output to the console.
Is it possible to run a Main type function that simply prints to the console without having to run trough tomcat.
Related
I want to achieve some kind of remote control web application.
What I have now is a java application that runs on my computer. I want it to listen for commands from a web page, which I run in ASP.net on my own server. The Java application should do it's business, but at the same time listen for commands. If a command is recieved from the server, it should break what it is doing, and do what the command says.
Example:
*The Java application is currently feeding dogs. It gives them 1 treat every second.
*I navigate to my web application, and press the button "Feed cats 1 treat every second".
*The Java application stops feeding the dogs, and starts feeding the cats.
*I navigate to my web application again, and change the amount to 4 treats every second.
*The Java application changes the amount to 4 treats per second.
How would I approach the connection between the Java application and my ASP.net application? I've read about Sockets and Serversockets, but I'm a little unsure on what to use for this exact issue.
On Ubuntu 12 server and Tomcat 7, I load test my spring mvc application for one specific REST get method. (using an online load test tool)
For 1 user per second and over a minute it works fine. But when I load test 50 users per second, after a short while tomcat shutsdown, so I have to restart it again. I checked logs but no error was there.
Where can I start to find the problem? Becoming slow, or unresponsive could be something that I could understand, but shuting down dont make sense.
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.
i have written a small java application which is called by an java application running as a windows service.
My java application calls the print method in order to print the word document:
java.awt.Desktop.getDesktop().print(new File(targetfile));
It works if i call the java application but it does not work if it is executed by the windows service.
What happens is that i have multiple ms word processes running in the background each time the window service tries to execute my java application.
Do you know how i can print from a windows service ?
Thanks,
Asad
If I had to guess... you need to run the Windows Service as a user with appropriate permissions to print.
By default a service will run as System or LocalUser, which will not be able to print. That's why it works when you call it but not the service. Try and set the Log On account for the service to your personal account and see if it works.
I have been working on a Web Application for Intranet use only. I work with Apache 7 and Windows Server 2003.
In one of my page, I need to open an external application that we can locate in C:/Program Files/etc... with some parameters already initialized. Of course, the user has to use the web application on the server to make it work (that will be the case).
To open the application, I use the ProcessBuilder object.
The problem:
When I work locally with Eclipse and run the server by hand, it works perfectly. Any application can open itself from a web page.
But when I use the tomcat windows service (and that's what we want to use on the server), it just never launches. Or to be more specific, it launches and stops the application directly. No java errors thrown and process.waitFor() with an exit value of 0. The fact is that we can run processes via the web application (I tried to run simple batch files), but when there is an UI involved, it will never appear.
Again, on the server this time, if I launch tomcat7.exe (that we can find in the %CATALINA_HOME%/bin directory) with a double click or cmd, the UI in the web application will appear. If I launch it with services.msc or tomcat7w.exe or tomcat7 start via cmd, it will not.
I thought of several things:
use another user to start the service
change the way the service is launched (StartMode: jvm, java. I did not succeed with exe)
I read Tomcat 7 Windows Service How-To many times but didn't find out anything to solve my issue.
Have you any idea of what is happening, and how to solve this issue ?
What is the big difference between running tomcat as a service and from the command line?
Option 1
If you open your service's properties window, go to the Log On tab then check the "Allow service to interact with desktop" check box you will get the behavior you want. Also depending on what app you what to run you may need to change the log on account.
see Launching GUI App from Windows Service - Window Does Not Appear
Option 2
Did you try start a cmd and there use
start /c "c:\path to\exe"
in cmd.exe type
help start
Option 3
You will need a daemon service that is not run as a service. windows puts certain restrictions on service apps.
This sleeping app can be started by tomcat or other your self. it can listen on a port or poll a folder for a new file, and when it gets a job to do it starts the app you want. Via port or text file you can send the parameters.