How to run java application automatically when EC2 instance starts without having to run it manually with java -jar file_name-SNAPSHOT.jar? - amazon-ec2

I tried the following steps but when I access my application in the browser using the url link, it returns a blank page. Here is what I did:
Copy My jar file to /home/ec2-user/
cp myApp-0.0.1-SNAPSHOT.jar /home/ec2-user
Next, I opened the rc.local in the VI editor and appended myApp-0.0.1-SNAPSHOT.jar
vi /etc/rc.local
#
#
#
#
touch /var/lock/subsys/local
//Append the below command:
java -jar /home/ec2-user/myapp-0.0.1-SNAPSHOT.jar
/:wq
Give permission to the symlink by running the following command:
chmod +X /etc/rc.d/rc.local
So I stopped my ec2 instance and after a while, I started it again to see if I was able to test my endpoints without having to manually run my appl with java -jar myApp-0.0.1-SNAPSHOT.jar But it did not succeed. I was told this way of doing is now obsolete. I also tried to follow the following link but the file naming was not obvious to me so I messed up some steps and got to the same result: failed Please can anyone direct me? Thanks! I tried the following steps but when I access my application in the browser using the url link, it returns blank page.

Related

Docker - Unable to mv a file inside a container

I am trying to give a set of bash instruction to my docker container when it launch.
but when I try to launch this docker file everything works great until the 'mv' command as you can see here :
but when I try to move the file directly from the container (the exact same command as my docker file) it works :
does anyone has an idea why its not working with the docker file instruction but working fine when I run the command manually ?
The directory /fuseky/configuration does not exist.
In the container you are doing it the right way so just change the command in the dockerfile:
mv safetybimontology_reasoner.ttl /home/configuration
and you should be fine
I fixed the issue by adding the creation of the folder named /fuseki/configuration in the set of instruction. It works fine and I can see this log :
[2022-07-05 12:41:26] Config INFO Load configuration: file:///fuseki/configuration/safetybimontology_simple.ttl

how to delete created server WebSphere Application Server Liberty Profile

I am working on docker images
setting up in docker file ...
# - Liberty installation of required features
RUN /opt/wlp/bin/featureManager install adminCenter-1.0 localConnector-1.0 jaxrs-1.1 jsp-2.2 jdbc-4.0 jndi-1.0 cdi-1.0 servlet-3.0 beanValidation-1.0 --when-file-exists=ignore --acceptLicense
RUN /opt/wlp/bin/server create my-server
...
but getting error
CWWKE0005E: The runtime environment could not be launched.
CWWKE0045E: It was not possible to create the server called cca-dist-d because the server directory /srv/www/servers/my-server already exists.
ERROR: Service 'appserver' failed to build: The command '/bin/sh -c /opt/wlp/bin/server create my-server' returned a non-zero code: 1
Is there way to remove such server before creation or any suggestions?
just for notice that rm -R does not work :-(
RUN /bin/bash -c 'rm -R /opt/wlp/bin/server/my-server'
---> Running in 83f*****bd
rm: cannot remove '/opt/wlp/bin/server/my-server': Not a directory
Regarding Liberty profile server deletion, it is as simple as to delete the entire directory. For example
rm -R WLP_HOME/usr/servers/my-server
Now about your error message, you should check why the server exist. Sounds like you have a problem in your setup.
And if you want to delete the my-server anyway, then you should remove the right directory. In your case:
rm -R /srv/www/servers/my-server
The servers are created into servers directory from WLP_USER_DIR environment. And the variable can be used to specify an alternate location for ${wlp.user.dir}. If this is specified, the runtime will look for shared resources and server definitions in the specified directory. Check server start script or README file for more information about the different environment variables.
In your case it seems that the WLP_USER_DIR is /srv/www/

Installing and starting the H2 database on Ubuntu

I would like to use the H2 database on Ubuntu 12.10, and went to the website and got the platform independent install file.
The installation instructions are quite literally, "To install the software, run the installer or unzip it to a directory of your choice."
I'm not a Linux novice, so I've used many of the usual install procedures before, but I have no idea what I am supposed to do here. There are no configure or makefiles that I can find, and the documentation doesn't mention anything, and there I can't find anything using google.
I don't know if I am missing something obvious. Can anybody help please?
A shell script to start the H2 server and browser GUI is included. I don't have Ubuntu right now, but the steps should be:
Download the H2 zip file (for example h2-2013-07-28.zip).
Open a terminal window
And then run:
cd <download directory>
unzip h2*.zip
cd h2/bin
chmod +x h2.sh
./h2.sh
This should start the H2 server tool and open a browser window that lets you connect to a database.
The content of the h2.sh script is relatively simple, it is:
#!/bin/sh
dir=$(dirname "$0")
java -cp "$dir/h2-1.3.173.jar:$H2DRIVERS:$CLASSPATH" org.h2.tools.Console "$#"
What you can also do is double click the h2*.jar file (if double click is configured to start java), or run this on a command line:
java -jar h2-1.3.173.jar
this bash script start the server:
#!/bin/bash
java -cp h2*.jar org.h2.tools.Server
you need the h2-version.jar in the current directory as well
Download h2 from here http://www.h2database.com/h2-2015-01-16.zip, then once the download has completed, unzip in home directory and run the following:
cd (directory path ).
cd h2/bin.
chmod +x h2.sh.
./h2.sh.
If you're using Maven to download h2 database, then try to find out where does it saves (~/.m2/repository/com/h2database/h2/.../h2-version.jar). Since h2 dependency has all downloaded for you, then you just doubleclick on jar file (the web browser should open h2 GUI or look for h2 icon on system tray). And yes, GUI is the same as Standalone package has.
Update: as long as icon displays on tray - h2 will be launched. To disable it - right mouse click -> Exit

IntelliJ needs to copy tomcat/conf directory to project directory

I have a freshly installed Tomcat 7 server, and I'm trying to make IntelliJ deploy a HelloWorld Spring MVC app to Tomcat.
My Tomcat home is /usr/share/tomcat7 and Tomcat base is /var/lib/tomcat7
However, when I try to run the project, IntelliJ throws an error saying:
Error running Tomcat : Error copying configuration files from /var/lib/tomcat7/conf to /home/adonis/.IntelliJIdea12/system/tomcat/Tomcat__SpringMVCApp/conf : /var/lib/tomcat7/conf/tomcat-users.xml (Permission denied)
Here is a screenshot - http://i.imgur.com/CQ3z0e1.png
Any permissions I need to set up?
Try chmod -R 777 /var/lib/tomcat7/conf/, it works to me.
Make sure that files under /var/lib/tomcat7/conf/ directory have read permission for the user IntelliJ IDEA is running from.
chmod -R 644 /var/lib/tomcat7/conf/
should help.
Also check that /home/adonis/.IntelliJIdea12/system/tomcat/ has correct permissions and owner. Could be that it was created from a different user and your current user doesn't have the rights to write into it.
If it doesn't help, download and unpack a new Tomcat installation from .tar.gz file, configure IDEA to use this installation instead.
Note that Tomcat installed using the package manager on some Linux systems has non-standard layout and permissions, and therefore will not work with IDEA.
I had the same problem and these steps helped me to Start my tomcat7 from Intellij :
I have Linux Mint 17,and Tomcat 7 which is installed using apt-get
CATALINA_HOME in /usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7
1- First I created a soft link which references /etc/tomcat7
cd /usr/share/tomcat7
ln -s /etc/tomcat7 conf
2- Then you have to change the access permissions of /etc/tomcat7
sudo chmod -R 655 /etc/tomcat7/
That's it.
For me, this worked for Tomcat 8 on Manjaro Linux:
sudo chmod -R 755 /usr/share/tomcat8/
I added my own user account to the tomcat7 group.
And chmod g+r /var/lib/tomcat7/conf/tomcat-users.xml
Had the same error with usr/share, dont just blindly run a command to act as magic-wand as many just tell you you run this and that on a mother-directory.
this is Linux, always some stupid thing with the permissions.
all you garra do is using chmod 666 or chmod 777 on files that are causing the error, but you need to look at those files first using ll and ls to make sure you are not decreasing some access, you may have a directory with 77x and when you do 666 you mess things up.
just gradually and one by one increase the chmod level and check whether problem goes away or not.
Sorry I didn't give you some code to fix all the problems.
This also happens to me, and I managed to solve it for Tomcat version 9, this problem is related to the configuration of Tomcat and you just need to give it permissions to be deployed.
You can use this link for more instructions.

Grails create-app error

Anyone know why I would get this error when trying to create a grails app using terminal.
mycomputer:test-apps mailboxe$ grails create-app demo
| Configuring classpath
| Error Error executing script CreateApp: /Users/bla/.grails/ivy-cache/resolved-org.grails.internal-grails-2.0.3.xml (Permission denied) (Use --stacktrace to see the full trace)
As #Phillip Tenn mentions, this is a permissions issue. Chances are something got installed into a cache with the sudo command so the root user owns the file and your normal user can't modify it.
The easiest thing to do is probably to just whack your ~/.grails directory, by default, there isn't anything but cached information in there. So unless you've put something in there manually (like a config file), it's safe to delete and let it regenerate with the next grails command. To do that, just:
cd ~
sudo rm -r .grails
It'll prompt you for your password to ensure you want to run this command as the root user.
Alternatively, you could try to find the offending file and chown it to your user and group (by default on OSX the group is staff). So for this example:
sudo chown bla:staff /Users/bla/.grails/ivy-cache/resolved-org.grails.internal-grails-2.0.3.xml
Grails needs to be able to write to a .grails folder under your user directory.
Without knowing the details of your development environment, the error message you are getting says (Permission denied) when you try to run grails create-app demo.
I would look into your directories:
/Users/bla/.grails/
/Users/bla/.grails/ivy-cache/
and ensure that you have proper write permissions.

Resources