Jhipster delivery as jar packaging : I don't manage to access login page - spring-boot

I just changed the output delivery as jar instead of war inside the pom.xml. But now, I've don't manage to load the login page. Not displayed. Cf. screenshot.
What should I do to make "One file delivery" ?
Thanks
Error loading login page

Resolved.
In fact, it is not needed to change to jar output. The generated war is already executable. (like jar command : java -jar your.war).
Maven spring boot plugin outputs 2 war files : xxx-0.0.1-SNAPSHOT.war and xxx-0.0.1-SNAPSHOT.war.original. The former contains tomcat embedd librairies (and more differences) and then it is the executable one. The latter contains old fashion war file : to be put into an external servlet container.
Thanks.

Related

Spring Boot with Maven Install vs Eclipse Export WAR

I hardly use Maven.The only time for me to use it is for maintaining my web app dependencies.
Now I started to develop web app using Spring Boot. I notice when I run Maven install, a WAR file will be created in the target folder. Then I export WAR using File > Export on my STS IDE and compare the two wars. The size of the 2 files are different. How can this be ? Also, the WAR file created from Maven runs fine on standalone Tomcat 7 while the exported war from Eclipse (STS) doesn't.
What am I missing here ?
It's reasonable to assume that WTP (File > Export > Web etc) would produce a different WAR file from the maven build. Maven build may have plugins applied to the build to produce the desired WAR file. Check your POM file carefully and check if there are any maven plugins used in the build.
Now, I don't exactly know how Eclipse WTP component produces their WAR file (Export WAR file is not from STS - it's Eclipse WebToolsProject) from the project. There might be options in the export wizard to play around with or some configuration file in your project. You'd better off asking that on the Eclipse forum: https://eclipse.org/forums/index.php?t=thread&frm_id=88
Hope this helps.

Read emails on Tomcat: ClassNotFoundException: javax.mail.MessagingException

My application is running on Tomcat 7.
I'm trying to read emails from inbox, and for that I use a normal Java class.
There is also a Servlet that calls the method readMails in the mentioned class.
Now I get an exception:
java.lang.ClassNotFoundException: javax.mail.MessagingException
...
I use IntelliJ IDEA with Maven, I changed the dependency of javax.mail a lot (see http://mvnrepository.com/artifact/javax.mail), but the exception keeps coming up.
I've also changed the Version of Tomcat (7 and 8), and the version of "Project SDK" (1.7 and 1.8) and "Project language level" (7 and 8).
I've read somewhere that there is a difference between reading emails via IMAP with normal Java application and running it on Tomcat.
In a previous project I read emails successfully with a normal Java application.
Can anyone help me with this exception?
JavaMail API is not included by default among Tomcat libraries.
Make sure that JavaMail dependency (mail-X.X.jar) is either packaged together with your application (in WEB-INF/lib) or is in a folder that Tomcat class loaders read (for example $CATALINA_HOME/lib), as described here:
http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
Thanks, it works now.
I put the jar file (javax.mail: javax.mail-api-1.5.4.jar) downloaded by maven (.m2/repository/ ...) into WEB-INF/lib (in my project).
I also needed to put another jar file into WEB-INF/lib (com.sun.mail: javax.mail-1.5.4.jar) due to this exception:
java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger
javax.mail.Session.initLogger(Session.java:226)
javax.mail.Session.<init>(Session.java:210)
javax.mail.Session.getDefaultInstance(Session.java:321)
I added
<packaging>war</packaging>
to my pom.xml. This way maven puts the dependencies in the target folder.

Placeholder in banner.txt are not replaced when deploying war file

I've built a spring boot application and I'm trying to customize the banner to display the version of my application.
After reading the documentation, I've managed to create a banner.txt in the classpath and added the ${application.formatted-version} placeholder inside.
I've also managed to create a manifest file (using Gradle) containing the Implementation-Version.
Everything works fine when executing a jar file directly but when creating a war file, the banner is displayed but the version placeholder is not replaced.
After a bit of debugging, this method seems to be the source of the problem
org.springframework.boot.ResourceBanner.getApplicationVersion()
When running a war file, the call to
sourcePackage.getImplementationVersion() always return null
The manifest file is located at the root of the war file /META-INF/MANIFEST.MF
The application is deployed in a standalone tomcat 8.0.15
Any idea of what's wrong ?
It's a bug/limitation in Tomcat. It fails to find the /META-INF/MANIFEST.MF from an exploded WAR file which causes its ClassLoader to define the package with a null implementation version. This has been fixed in Tomcat, but the fix hasn't made it into a release yet. It'll be in 8.0.25.
There's some more information in this Spring Boot issue and this is the change that was made to Tomcat if you're interested.

Grails run-app causes error generating web.xml file and bootstrap.groovy not included in war file

I am working on an maven application. When I run it from IntelliJ, it successfully launches my application. But bootstrap.groovy file is not being read. I have created a new username to be added to DB in bootstrap and it should allow me to login to the application using that username for the first time. This is not getting invoked during the start of the program. What settings should I do to include bootstrap.groovy.
The same happens when I create a war file and deploy it in the test server. Bootstrap.grrovy is not read. To create the war file, I use mvn package in command line.
My other question with the same application is that when I do grails run-app, I get the following error: Error generating web.xml file.
What is that I am missing? Please let me know.
Well, I fixed the issue. The web.xml was created when I changed the grails dependent jar. I was using 2.3.4 in my application and my jar was incompatible as I had 2.4.3 version of the jar. Now my program is up and running! Hope this helps someone who is facing the same problem.

grails tomcat 7 deployment

So I have a grails 2.0.4 application that works exactly the way I want. I created the war file and deployed it to Tomcat 7. I'm getting an error saying that the application can't find the jar I'm using to connect to oracle (ojdbc6.jar). The jar is listed under mywebapp/WEB-INF/lib. WHY can't it be found?? Any help would be greatly appreciated!
The jar file should be in the toplevel lib directory of your project (or specified as a dependency in a repository), not webapp/WEB-INF/lib. Is the jar file actually inside the warfile? You can test this by opening the war as a zip file, or by running jar tf target/mywebapp*.war and looking for ojdbc6.jar. If it is, it should get deployed and you should see it in tomcat7/webapps/mywebapp/WEB-INF/lib.
The default environment for grails war is production instead of development. Make sure you've got the production data source configured correctly in grails-app/conf/DataSource.groovy

Resources