Spring boot application wont start in openshift - spring-boot

I created openshift project with DIY cartridge, added postresql for DB.. now I pushed sources to cloud, but I'm getting error like the guy here (but he was not using springboot): I can't start tomcat 7 server on linux openshift - Failed to start end point associated with ProtocolHandler ["http-nio-12345"]
Failed to start end point associated with ProtocolHandler
It's obvious that if I run the app twice the error message 'Failed to start end point associated with ProtocolHandler' appears. I tried rhc app-tidy, restarted APP via openshift interface, i made change, pushed to cloud, build success, but the message appeared again. How to stop the app so that I can run it properly? Didn't the app being stopped after the restart I performed?
UPDATE: Have I chosen the right steps? (with DIY cartridge), do You have a simple (& working) guide how to deploy such an app to openshift? I tried few I found over the net, but none of them worked :(

Here is steps I follow using DIY cartridge, hope this would help
Go to home directory of project perform following tasks
Create Settings.xml and refer maven repo by updating settings.xml as shown in following xml snippet below. And also add the file to git repo
<settings>
<localRepository>${OPENSHIFT_DATA_DIR}/m2/repository</localRepository>
</settings>
Got to .openshift directory and delete all the files except action_hooks
Go to action_hooks and perform following task
i. Delete README.md
ii. Create deploy file (note the file extension while create should not be txt) and add following code snippet
(It basically creates and downloads and sets up java8 and maven
#!/bin/bash
set -x
if [ ! -d $OPENSHIFT_DATA_DIR/m2/repository ]
then
cd $OPENSHIFT_DATA_DIR
mkdir m2/repository
fi
if [ ! -d $OPENSHIFT_DATA_DIR/jdk1.8.0_51 ]
then
cd $OPENSHIFT_DATA_DIR
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
tar xvf *.tar.gz
rm -f *.tar.gz
fi
if [ ! -d $OPENSHIFT_DATA_DIR/apache-maven-3.3.3 ]
then
cd $OPENSHIFT_DATA_DIR
wget http://mirror.fibergrid.in/apache/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
tar xvf *.tar.gz
rm -f *.tar.gz
fi
cd $OPENSHIFT_REPO_DIR
export M2=$OPENSHIFT_DATA_DIR/apache-maven-3.3.3/bin
export MAVEN_OPTS="-Xms500m -Xmx500m"
export JAVA_HOME=$OPENSHIFT_DATA_DIR/jdk1.8.0_51
export PATH=$JAVA_HOME/bin:$M2:$PATH
mvn -s settings.xml clean install
iii. Add the deploy file to git
iv. Edit start file with following snippet.
#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
set -x
export JAVA_HOME=$OPENSHIFT_DATA_DIR/jdk1.8.0_51
export PATH=$JAVA_HOME/bin:$PATH
cd $OPENSHIFT_REPO_DIR
nohup java –Xms500m –Xmx500m -jar target/*.jar --server.port=${OPENSHIFT_DIY_PORT} --server.address=${OPENSHIFT_DIY_IP} &
v. Edit stop with following code snippet
#!/bin/bash
source $OPENSHIFT_CARTRIDGE_SDK_BASH
PID=$(ps -ef | grep java.*\.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
client_result "Application is already stopped"
else
kill $PID
fi
vi. Make deploy file executable (Note: This is very important and its common mistake, if not executable your project will not start)
Commit the changes along with your maven src and pom.xml your application should automatically start once the commit is done, Note: for first time it will take time as it needs to download maven repo.
For debuging purpose, its better to add logback.xml in your class path(src/main/resources)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOG_FILE" value="${OPENSHIFT_LOG_DIR}/kp-apps.log" />
<include resource="org/springframework/boot/logging/logback/base.xml" />
<logger name="org.springframework.web" level="DEBUG" />

Related

ClientLibs are not getting updated and resources folder getting deleted after mvn clean install

I am using AEM cloud SDK with archetypeVersion 39 project after running mvn clean install my clientlib folders are not getting updated (issue is with only clientlibs rest are working as expected)and even I observed that the folder which I have added most recently i.e., resources is getting deleted PFB looks like this. I have created project by using the below command : mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=39 -D appTitle="WKND Sites Project" -D appId="wknd" -D groupId="com.adobe.aem.guides" -D artifactId="aem-guides-wknd" -D package="com.adobe.aem.guides.wknd" -D version="0.0.1-SNAPSHOT" -D aemVersion="cloud"
enter image description here
enter image description here

How to send war file from local to aws server using putty?

I am trying to send war file built in Java Web application to AWS EC2 instance. Here is the command which I have far used for sending war file.
cd/ usr/share/tomcat8/webapps/
As I have my previous war file in this folder. After that I have use command ls from which something like this come
com.metokart com.metokart.war host-manager manager ROOT ROOT-OLD-1
At this .war is the previous one, First I have rename the folder ROOT to another name using this command-
sudo mv ROOT ROOT-OLD-6
After that I have deleted both the .war file and com.metokart folder from the webapps
sudo rm -rf com.metokart.war
sudo rm -rf com.metokart
Then I have gone to default directory to upload the new war file
sudo cp -i com.metokart.war /usr/share/tomcat8/webapps/
After that I have change the ROOT folder name back to ROOT.
sudo mv ROOT-OLD-6 ROOT
At last I have restarted my tomcat
sudo services tomcat8 restart
But still I don't know where I am doing the mistake. Hope anyone can help.
You should use pscp from within putty. Here is a helpful link that should guide you https://it.cornell.edu/managed-servers/transfer-files-using-putty.

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/

Through vagrant running mvn command

I am working on writing vagrantfile for automation of local setup.
Through vagrant, i am creating docker image for my app and running it inside vm. Everything is under one command i.e. vagrant up
But one thing i have to do manual i.e. creating jar file for my app by using mvn clean package.
I am wondering is there any way to run mvn command from vagrantfile, so that when i issue vagrant up, it should build the JAR and do the rest of the work.
as #Patrick mentions, the shell provisioning is a good fit - I personally use for gradle but the same can be done for maven. Here is how I call my script
config.vm.provision "shell", path: "script/run-test.sh", privileged: false, run: 'always'
path : is the path for my shell script from the project directory
privileged : if not set, root will run the script, if maven is installed for your vagrant user, make sure to set it to false else you will see issue
run: 'always' : this is my use-case (up to you to choose if it makes sense for you), the script will always run when I run vagrant up
the shell script will be something like
#!/bin/bash
if [ -d "/home/vagrant/test" ];then
cd /home/vagrant/test && git pull
cd /home/vagrant/test && maven compile
cd /home/vagrant/test && maven deploy
.....
else
git clone <your project> /home/vagrant/test
fi
This is an example, basically first time I create the instance it will clone a git repo - then it will pull from git latest files and run your maven command.
Again this is a simple example, use it for your own need

SOLR 4.1 throws: Unknown commit parameter 'waitFlush'?

I'm running Magento EE 1.11 and I've deployed SOLR 4.1 with tomcat7. I've copied solrconfig.xml and schema.xml provided by Magento and fixed all the issues SOLR was having with the two files because they were intended for SOLR 3.6 and properly configured Magento.
Now, when I reindex search in Magneto at the very last moment SOLR spits out this exception:
org.apache.solr.common.SolrException: Unknown commit parameter 'waitFlush'
and Magento reverts back to saying a search re-indexing is required. Has anyone ran into this problem? From all the googling I've done there seems to be a patch for this, but where and how do I apply it?
You should really use SOLR 3.x rather than 4 with Magento EE.
Here's a walk-through for configuration and installation.
On Debian/Ubuntu
The most straightforward installation is pretty easy using tomcat and your package manager. The dependencies will be met automatically.
apt-get install tomcat6
On CentOS/RedHat
You need to grab some alternative repo's to make this possible
Eg.
rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Then you can install the package from yum
yum install yum-priorities ant tomcat6 tomcat6-admin
cd /usr/src/
mkdir sun-java
cd sun-java
Now it gets a little trickier. Sun used to permit direct downloads; but they now have a stupid session validation in place - so download the binary via your PC and upload it to the machine.
You need both the Linux JDK and JRE.
The commands would have been:
wget -O jdk.rpm.bin http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jdk-6u29-linux-x64-rpm.bin
wget -O jre.rpm.bin http://download.oracle.com/otn-pub/java/jdk/6u29-b11/jre-6u29-linux-x64-rpm.bin
You can alternatively use OpenJDK
wget http://jpackage.org/jpackage50.repo -O /etc/yum.repos.d/jpackage50.repo
yum install -y java-1.6.0-openjdk
Once you've uploaded the binaries
chmod +x *.bin
./jre.rpm.bin
./jdk.rpm.bin
ln -s /var/lib/tomcat6 /usr/share/tomcat6
Then the remaining steps
Then drop in your respective selection of solr
mkdir /usr/src/solr
cd /usr/src/solr
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org/lucene/solr/3.6.1/apache-solr-3.6.1.tgz
tar xvfz apache-solr-3.6.1.tgz
cd apache-solr-3.6.1
cp dist/apache-solr-*.war /var/lib/tomcat6/webapps/solr.war
mkdir -p /var/lib/tomcat6/solr
Then add the Magento solr configuration
INSTALL_DIR="/var/lib/tomcat6/solr"
touch $INSTALL_DIR/solr.xml
CORES=( "staging" "development" "live" )
for CORE in "${CORES[#]}"; do
mkdir -p $INSTALL_DIR/$CORE/conf $INSTALL_DIR/$CORE/data
cp -par /usr/src/solr/apache-solr-3.6.1/example/solr/conf/* $INSTALL_DIR/$CORE/conf
cp -par /home/path/public_html/lib/Apache/Solr/Conf/* $INSTALL_DIR/$CORE/conf
done
Then set up the cores
cat > /var/lib/tomcat6/solr/solr.xml << EOF
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true" sharedLib="lib">
<cores adminPath="/admin/cores">
<core name="staging" instanceDir="staging" config="solrconfig.xml" schema="schema.xml" />
<core name="development" instanceDir="development" config="solrconfig.xml" schema="schema.xml" />
<core name="live" instanceDir="live" config="solrconfig.xml" schema="schema.xml" />
</cores>
</solr>
EOF
Then finally, clean up permissions and restart solr
chown -R tomcat6:tomcat6 /var/lib/tomcat6/solr
/etc/init.d/tomcat6 restart
Then in Magento, you've now got 3 possible independent cores you can use for your store environments.
staging/solr
development/solr
live/solr
Attribution: http://www.sonassi.com/knowledge-base/multiple-solr-cores-for-magento-on-debianubuntucentosredhat/

Resources