This week's book giveaway is in the Go forum.
We're giving away four copies of Head First Go and have Jay McGavren on-line!
See this thread for details.
Win a copy of Head First Go this week in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

code not running when deployed as WAR in tomcat but runs fine as springboot app  RSS feed

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What could be the reason behind my following code which runs fine when I use the following path in Eclipse:

Right Click on Project -->Run As --> Springboot App

I can see this line of code printing the message from the ActiveMQ Queue.

However, when I deploy the project as a WAR into Tomcat, I don't see the same code running. I mean, the messages stays in the queue and doesn't get printed. I was expecting, as soon as I keep on adding the messages in the queue, it would keep on printing those messages but it's not working like this. What am I doing wrong here?

Here's my code (which is coming from here: https://javainsider.wordpress.com/2012/09/25/simple-guide-to-java-message-service-jms-using-activemq/#comments) :





And here is the pom.xml

 
Marshal
Posts: 24198
54
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:However, when I deploy the project as a WAR into Tomcat, I don't see the same code running.



Tomcat expects you to write a web application, with servlets processing HTTP requests. You didn't write any such code, and rightly so because your requirements don't include HTTP requests. So expecting Tomcat to do anything with your code is a category error.
 
Saloon Keeper
Posts: 1113
36
IBM DB2 Java Netbeans IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Spring boot allows you to build a fat jar and run it as a standalone application as well as build a war file meant to be deployed in a servlet container capable appserver as Tomcat. You need to change the class responsible for bootstrapping spring application context to achieve this (sorry, I don't remember by heart the details).
 
Jack Tauson
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Jack Tauson wrote:However, when I deploy the project as a WAR into Tomcat, I don't see the same code running.



Tomcat expects you to write a web application, with servlets processing HTTP requests. You didn't write any such code, and rightly so because your requirements don't include HTTP requests. So expecting Tomcat to do anything with your code is a category error.



Ok. Could you explain how come this piece of code runs properly? Here it's using JMS 2.0 instead of JMS 1.X that I am using in my code above:

 
Ranch Hand
Posts: 277
2
Fedora Netbeans IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you put a war in a tomcat server it unpacks the war and makes servlets or something like that. Its not going to run like a regular application.
 
Paul Clapham
Marshal
Posts: 24198
54
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:Ok. Could you explain how come this piece of code runs properly?



No, I can't. You didn't tell me anything about the context in which it runs. So how should I know?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!