Error while deploying springboot app to ibm cloud - ibm-cloud

Getting below error when trying to deploy an springboot app to ibm cloud, the same app is working fine on my local. I have a trial account on ibm cloud.
"**RuntimeError: Application can not be run by more than one container: JAR, java-main, unknown, liberty-20.0.0_3 "
Let me know what is wrong.

You need to deploy a war file instead of a jar.
In my case, I have a maven-based app and my packaging property is set to war:
<packaging>war</packaging>
Also, you need to mark your tomcat (or whatever container you are using) dependency as provided:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Basically you get this setup when choosing war packaging in the spring initializer site.

Related

Trying to install glassfish-3 for Java EE 6 tutorial examples

I am trying to install glassfish-3 with NetBean. The tutorial page below asks me to install Java EE 6 SDK first, which I did.
http://docs.oracle.com/javaee/6/tutorial/doc/gexaj.html
But I am unable to find the location of Java EE 6 on my PC. Any idea how I might find it?
Download Glassfish from here https://glassfish.java.net/downloads/3.1.2.2-final.html
download a version of choice , on Netbeans , under Services, right click server, and add server,choose glassfish and select install location,admin ports and http port. jee6 comes shipped in Glassfish module if you are using an ANT project. I will advice you use maven project , add this your dependency pom as this using maven allows you to use specific jee dependency.
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>

Convert Spring MVC template to GAE

Anyone have some template to Transform spring MVC template to run on GAE ?
I already tried different aproaches without success.
Last thing I tried was to add GAE dependency and plugin and criate appengine-web.xml file...
I allways get the message "this project is not a google app engine project"
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.14</version>
</dependency>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.9.14</version>
</plugin>
Spring and Google App Engine can be made to work together however the structure of a Google App Engine Java Project is very different from the standard Spring or Java Web Project.
If you want to use Maven with Google App Engine I'd suggest copying one of the example/template archetypes and adding the Spring libraries to the project. I've had much greater success with doing it this way. However I have opted not to use Maven with Google App Engine and Spring because the latest version of Spring does not play well with Google App Engine.
The easiest option is to start from a Maven Archetype that contains the key components you want. If you want to progress without Maven you can create a standard Google App Engine project in Eclipse and incorporate the Spring libraries.
Word of warning. Follow the instructions linked below else you'll end up with an application that takes a very long time to start up instances. Due to the way Spring autowires it can take a minute or more for an application to start when deployed to App Engine without correct configuration.
Best of luck!
Read More:
https://cloud.google.com/appengine/docs/java/tools/maven
https://cloud.google.com/appengine/articles/spring_optimization

How to run jersey-examples-helloworld-webapp in netbeans 7.4

I did as oracle documentation said...build and run...but it asked me to select deployment server.
Then I selected glassfish server 4.0(The only choice); however this project couldn't run.
I found it newly created a glassfish-web.xml in folder WEB-INF(the project already had web.xml there before).
I thought may be it just didn't connect the project with the server well.
for me it helped to update the pom.xml to omit 2.x compatibility and restart the glassfish domain.
Thanks
Richard
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!--artifactId>jersey-container-servlet-core</artifactId -->
<!-- use the following if you don't need servlet 2.x compatibility -->
<artifactId>jersey-container-servlet</artifactId>
</dependency>
Removing the jersey-container-servlet-core.jar from the web-inf/lib folder solved this problem for me.

Tomcat goes to .m2 directory for the jsp, servlet, etc. jars and crashes

I am having trouble getting Tomcat to run JSPs on my maven-enabled project (Eclipse 3.7 with latest m2 plugin on Tomcat 6, running as a server in Eclipse Java EE):
java.lang.NullPointerException
at org.apache.jsp.index_jsp._jspInit(index_jsp.java:22)
This error indicates that the Tomcat-supplied jars for JSP, servlet, etc. are clashing with project jars. It does appear that everything is set up properly, though:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
If I turn on class tracing on the VM, I see that upon startup the jsp jar from Tomcat's lib directory is being used for JspFactory:
[Loaded javax.servlet.jsp.JspFactory from file:/C:/tomcat-6.0.28/lib/jsp-api.jar]
When the server is up and I'm ready to hit the jsp page for the first time, however, I get a different result:
[Loaded javax.servlet.jsp.JspFactory from file:/C:/Users/alice/.m2/repository/javax/servlet/jsp/jsp-api/2.1/jsp-api-2.1.jar]
So, for some reason that is beyond me, the jsp jar from the m2 repo is being used by the web application, even though the scope in the pom.xml is set to provided. I've exhausted google searching. What other configuration issues might be causing this problem?
Over the last several years, I've regularly seen all sorts of configuration-related issues with the Tomcat Eclipse plugin.
I'd suggest doing yourself a huge favor - dump the plugin. Run a standalone Tomcat.
It's not that hard to do.
It's also easy to configure Tomcat to point to the war file that Eclipse builds, so that you don't have to explicitly deploy it.
It's also really easy to set up debugging of a standalone Tomcat instance.
The upside is that you don't have to deal with vagaries of the plugin, and generally speaking, stuf just works. As far as I can tell, there is no downside.

How to add HSQLDB library to SpringMVC in Maven?

I would like to ask how to add HSQLDB library hsqldb.jar in Maven? I have project in Eclipse created as Spring Template Project from SpringSource Tool Suite. It uses Maven as far as I know. I would like my project to use and work with HSQL database. And at this moment I want my Tomcat server to use HSQLDB library file. So If I added this library file in Maven, my project would work properly with HQL database. This is my assumption.
I have found this example http://slu.livejournal.com/5965.html but adding the jar file to the class path isn't very good programmig practice, is it?
I'm newbie in Maven and also in Spring Framework.
Newest version:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>2.2.8</version>
<scope>runtime</scope>
</dependency>
Remember about runtime scope in such artifacts (most people forget about it), since you use some generic API/SPI (ORM or JDBC probably) for database access and HSQLDB is only some kind of vendor for run-time implementation of such API/SPI.