how to do a clean deployment in dev_appserver? - java

How to do a clean deployment into app-engine dev server?
I am using google app-engine java and command line tools (ant, ant runserver).
When I submit new request through chrome, I am getting response from my old code.
I am not sure where my old code was cached. Am I missing anything?
Checked following things,
class file timestamp, ~\app1\war\WEB-INF\classes
servlet-mapping
cache setting in jsp,
I am not able to locate, compiled .class file for .jsp
other details,
app-engine java sdk 1.6.3.
JAVA_HOME=C:\glassfish3\jdk7
JRE_HOME=C:\glassfish3\jdk7\jre
chrome (latest)
windows vista

Maybe you are running the application twice via a zombie process? check using netstat -o (in the command line) which process is holding the port and kill it or just reboot.

Related

Apache Tomcat will not start on Mac

I cannot get Apache Tomcat to start. I followed the instructions for installing Tomcat on the Mac found at https://www.dev2qa.com/how-to-install-tomcat-in-macos/.
After I type the command to start Tomcat, the response from the command line is that Tomcat has started.
However, when I go to the browser, the default page is not showing up. I further checked to see if the port was being used by using the command
lsof -nP -i4TCP:8080 | grep LISTEN
which showed that no program is using the port. I also read the 'RUNNING.txt' that instructed me on setting the environmental variables, which I did. Any suggestions on why Tomcat is not starting up.
I'm using jdk 1.8.0_202 and Apache Tomcat 9.0.14 that is running of Mac OS High Sierra.
BatChmod
After downloading a fresh version of Tomcat, I use the BatChmod app to alter the file permissions. Tomcat will not launch properly without altering the permissions.
I do not know the command-line equivalent, but here is a screenshot of the settings I have used for years successfully.
Plea for help
If anyone can write the equivalent as a shell script for macOS, please post!
Even better, explain how to wrap such a script as an AppleScript for drag-and-drop execution in Finder.
The problem turned out to be a permissions problem. When I installed Tomcat, I put the folder in the '/Library/Tomcat' directory. Even though the Tomcat files were changed to be executable, the user and group ownership remained the same. To get Tomcat to run, I moved the directory to 'Users/MyUserName/Tomcat'. Once I did that, the default Tomcat page ran.

How to run a Java application on Ec2?

I want to deploy a a project to ec2. It was modify in Intellij which used MAVEN. It work perfect in Intellij. Below is the configuration of Intellij.
I have tried command line like java, javac. These kind of comment lines are all failed. I am wondering there must some way to convert Intellij configuration to command lines. I was relying too much on IDE. XD. Now I am regreted.
EC2 is the amazon cloud service for instances. If you aren't very experienced with it - the easiest you can do is to hire a machine with your fav operating system - for example Windows and use remote desktop to log in it and just do your normal IDE setup and run your app. You will have your app running on your instance and it will be working, even it is done the hard way. I will get downvotes for that, but it will work as a Swiss watch.
It depends from the kind of EC2 instance you're using.
For me would be simpler if it was a Linux instance.
I'll connect via ssh and git clone my project there from my bitbucket/github repository.
Then I'll use Maven, and there are many different options to run your project with Maven.
As suggested in the comments you could use the exec plugin.
But even in this way you'll have a list of problems to overcame.
For example your linux instance does not came with an preinstalled Java Runtime.
You have to install at least Java and Maven (choose ubuntu distro, so you can do easily with a package manager like apt-get).
Or, for example, another not easy task is connect via ssh to a Linux instance.
AWS generates a key.pem file that you have to use in order to successfully connect to your instance.
ssh -i .ssh/your-key-file.pem username#your-ec2-instance-address
And again, AWS does not tell you the name of the default user you must use to connect to your EC2 instance (if you choose ubuntu distro the username is ubuntu).
And again, when you save your-key-file.pem in your computer it must have the right permission
-rw-------# 1 freedev staff 1692 Apr 21 09:46 /Users/freedev/.ssh/your-key-file.pem
or your ssh client wont read it.
...looking back it was really a long way make a deploy on a EC2 instance.
I have solved it by myself.
Use mvn package to generated jar file for maven project.
nohup java xx.jar debug.xml & use this to run jar in shell. By using this command line, when exit (abort remote connection), the process / command will not get killed.
Command line jcmd is used to check running process pid.

Wrapping a jar file in a Windows service

Have you had experience with running a jar file using a command line, wrapped in a Windows service?
I'm trying to find a way to run a jar file without being logged into the machine, and since it allows command shell, I was wondering if it's a good idea.
Thanks!
Original Post:
I'm trying to run Associated Press's Web Feeds Manager, which is basically a jar file that can be run when logged in by double clicking it.
I'd like to run the same file but without being logged in to the machine. In their manual (http://wfm.ap.org/admin/content/help/Running_Agent_on_a_Remote_Server.htm) they write how to do that, using a commandline parameter.
Basically I'd like the jar to run as a Windows service, regardless of who's logged in, but Googling it showed it was problematic.
Have you had experience with remotely running jar files? What are the pitfalls?
Thanks!
On a google search, I came across this article -
Running Jar Applications as a Windows Service
It mentions about open source Java Service Wrapper project from Tanukisoftware.org for accomplishing this task.
Note: I've not used this personally.
If you are not interested in having the service started/stopped at boot/shutdown, but you just want the program to be started manually and keep running after logout, here is what you do:
$ nohup java -jar foobar.jar > foobar.log 2>&1 &
which means: start my foobar.jar (java -jar) and keep it running after I logout (nohup) redirect stdout to foobar.log (>) and also the stderr (2>&1), and make it running in background (& at the end).
Instead, if you are interested in installing a "service" in your linux box, there are many options, depending on what distribution you are using.
The most common are upstart (for ubuntu) and System V init scripts (Redhat or others). Also cron can be used to start/stop services at startup/shutdown.
You can find an example of installing a java app (hudson) on an init system here, or doing the same thing with upstart. Or, as I said, cron could be an option.
On Windows, there is Java Service Wrapper. And not much more.
For windows Java Service Wrapper is a better choice
My favourite is the upstart on linux, but it is Ubuntu only.
On Windows I see many alternatives according to this forum.

How do I run a Java .jar file as a Windows service on Windows Server 2008?

How do I run a Java .jar file as a Windows service on a Windows 2008 server? I have a jar file called SomeJavaFile.jar located under the C:\SomeDirectory directory on a Windows Server 2008 box. I usually just run this jar manually in the command line with: java –cp SomeJavaFile.jar com.ctg.SomeJavaFile and I let it run 24/7.
The problem with our Windows Server is if it restarts I need to run it as a service so it will automatically start as a service upon startup, because our processing for Vistakon runs 24/7. I have Googled around and tried to use a service wrapper and the sc.exe command to create the service.
I put the wrapper service.exe in the C:\SomeDirectory\. I use the following command to create it: sc.exe SomeJavaService binPath= “C:\SomeDirectory\service.exe \”java –jar C:\SomeDirectory\SomeJavaFile.jar\”” type= own start= auto error= ignore. This creates the SomeJavaService service correctly but when I try to start it I get an error that says the service on Local Computer started then stopped.
Some services stop automatically if they are not in use by other services or programs. Do I need to alter my sc.exe command to have the exact previous working command line maybe, by adding in the com.ctg.SomeJavaFile? So should I change This jar should just run in the background and constantly poll/ping the C:/poll directory then if there is data present it processes the data and sends an export file to another directory.
I have used this same .jar file for years successfully and it hasn't changed, but I cannot get it to run as a Windows service. This is the site I use to get the service wrapper http://code.google.com/p/simple-service-wrapper/. Any help would be greatly appreciated!
"winsw" is the standalone version of the Windows Service installer shipping with the Glassfish Java EE reference implementation.
Works well, but is not a fully polished product - I have used it for exactly this purpose for a couple of years. Requires .NET in some recent version on the Windows machine.
https://github.com/kohsuke/winsw
I think that the best bet would be wrap your java app with Procrun of Apache Commons Daemon .
Procrun is a set of applications that allow Windows users to wrap
(mostly) Java applications (e.g. Tomcat) as a Windows service.
The service can be set to automatically start when the machine boots
and will continue to run with no user logged onto the machine.
As per my analysis,
The Idle Solution will be writing a VC++ (.net) Windows Service creation program to launch the .bat (that triggers the jar file)/.exe as a System service with all the required call back methods to SCM.
Note : 1. Wrapping the process with sc.exe / srvany.exe would not work as it does not have any call back process to the SCM (Service Control Manager). 2. And java service Wrapper is a third party API (many are LGPL licensed).
If you start your Java code from commandline by using java -j some.jar does it run until you terminate the program, or does it stop by itself?
There needs to be a NON-Deamon Thread, that is running all the time. A JVM will terminate, if there is no thread running, that is not flagged as daemon.
If you have a little budget, buy an installer tool. I use instll4j. With that tool, you can create service launcher and install them during instllation.
The following solution is working fine for me having OpenFire Connection Manager (which is a jar file) running as service on Windows Server.
Download and install the Non-Sucking Service Manager
I didn't use the batch made by OpenFire team, because it didn't work for me (dependencies not found error...) So, make a batch file with the following code :
#ECHO OFF
cd /D "E:\connection_manager\lib"
java -jar startup.jar
and save it as cm_startup.bat in the bin folder of connection manager.
After that you can create the service with NSSM.
So, open a cmd.exe and run the following command :
nssm install ConnManager "E:\connection_manager\lib\cm_startup.bat"
.
Doc & examples
More documentation and examples for the Non-Sucking Service Manager here : https://nssm.cc/usage Actually NSSM as a lot of options available.
Here is a more complexe example :
nssm install solr "%JavaExe%" -Dsolr.solr.home="\"%CD%\solr"\"
-Djetty.home="\"%CD%"\" -Djetty.logs="\"%CD%\logs"\" -cp
"\"%CD%\lib\*.jar"\";"\"%CD%\start.jar"\" -jar "\"%CD%\start.jar"\"

how to use appcfg.py for google-app-engine projects created using google's eclipse plugin?

I have created a google-app-engine java project in Eclipse using Google's Eclipse plugin. My previous attempt to deploy failed. Now, when I retry, I get the following message:
Unable to update app: Error posting to URL : http://appengine.google.com/api/appversion/create?app_id=mybdaywisherversion=1
409 conflict
Another transaction for this user is already in progress for this app and major version. That user can undo the transaction with appcfg.py's "rollback" command.
Now, I have always used the google-app-engine features from inside Eclipse only and have not a clue how to run the appcfg.py command.
Could not get much help from documentation available over the internet. The only thing I could make out was for mac (I'm on mac), the command to be used is appcfg.sh. Inside Eclipse, I looked where App-Engine SDK is located on my machine and went to that location.
Even found appcfg.sh there. But when I try to run it, it only reports the error "command not found". Tried various alternatives to run it (like tried running it with sudo, tried running it as ./appcfg.sh by going to whether its located) but no success
Can someone please tell me the step I will have to follow to run the apcfg command?
As the result of an Internal Server Error during app deployment,
I am now left with a pending transaction, that I need to rollback
before I can deploy again.
Creating staging directory
Scanning for jsp files.
Scanning files on local disk.
Initiating update.
java.io.IOException: Error posting to URL:
409 Conflict
Another transaction by user is already in progress for this app and major
version. That user can undo the transaction with appcfg.py's "rollback"
command.
this was how I did it (all from the command line) which is a slightly simpler
method, which achieved the same effect.....
C:\Documents and Settings\Amit\My Documents\newproject>"C:\Program
Files\eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.2.5.v200909021031\appengine-java-sdk-1.2.5\bin\appcfg"
rollback war
Reading application configuration data...
2009-09-17 20:47:35.859::INFO: Logging to STDERR via org.mortbay.log.StdErrLog
Beginning server interaction for idebanet...
0% Rolling back the update.
Success.
Cleaning up temporary files...
C:\Documents and Settings\Amit\My Documents\newproject>
Courtesy:JOHN
I dont think these answers were that helpful.
using the commmand line cd into you application directory. for me this is
cd /Sites/appengine_myapp
Now you have done this.
appcfg.py --no_cookies --email=YOUR_EMAIL_HERE#gmail.com --passin rollback ./
You should be prompted for your password.
Try running appcfg.py with rollback option. See the docs:
appcfg.py [options] rollback
Undoes a partially completed update for the given application. You
can use this if an update was
interrupted, and the command is
reporting that the application cannot
be updated due to a lock.
for mac / linux user:
1.cd /"sdkdirectory"/bin
2. chmod +x appcfg.sh
3. ./appcfg.sh -s appengine.google.com -e XXX#Gmail.com rollback /Users/"...."/workspace/yourapp/war
Better perspective gained about the problem.
Documenting the problem here for the benefit of on-lookers:
I was using Google's Plugin for Eclipse for a Google App Engine project. An attempt to deploy the application on app-engine server failed because of network problems. Subsequent attempts were failing because the previous attempt had created some kind of lock and that transaction had to be rolled back. The plugin does not provide any way to do this. One has to use appcfg program over command line to rollback. http://code.google.com/appengine/docs/java/tools/eclipse.html has details. The problem I was facing was occuring becuase of OS level permissions on appcfg.sh. Ga ve permission to self using chmod and could get it working.
When you are using Linux, try a solution posted in this link:
http://www.patternizando.com.br/2011/04/another-transaction-that-user-can-undo-the-transaction-with-appcfg-pys-rollback-command-gae/
for deploying your application using command line , follow these steps:
cd "/Library/Google/google_appengine"
./appcfg.py update "path-to-project/src"
you will be prompted for your email and password.
I was having issues to run those appcfg provided by Eclipse. I had to install Python+ App Engine sdk for python and benefit from appcfg.py functinnalities. It was on Windows though.

Categories