With nearly two decades of experience working in the IT industry in various roles as Enterprise technology consultant, Java Architect, project leader, Engineer, Designer and Developer, Mr. Knutson has gained a wide variety of experience in disciplines including JavaEE, Web Services, Mobile Computing and Enterprise Integration Solutions. Over the course of his career, Mr. Knutson has enjoyed long lasting partnerships with many of the most recognizable names in the Health Care, Financial, Banking, Insurance, Manufacturing, Telecommunications, Utilities, Product Distribution, Industrial and Electronics industries employing industry standard full software life cycle methodologies including the Rational Unified Process (RUP), Agile, SCRUM, and Extreme Programming (XP). Mr. Knutson has also undertaken speaking engagements, training seminars, white paper and book publishing engagements world-wide. As an active Blogger and tweeter, Mr. Knutson has also been inducted in the prestigious DZone.com Most Valuable Blogger (MVB) group and can be followed at http://www.dzone.com/page/mvbs and twitter at http://twitter.com/mickknutson. Able to quickly and effectively adapt to any phase of an existing project from Business Modeling to Production Support, Mr. Knutson’s wide array of technical expertise in OOA / OOD / OOP, Java, J2EE, Internet, Oracle, Enterprise Integration and Message Oriented Middleware allow him to seamlessly integrate into your Information Systems project at any phase and provide immediate productivity. Mr. Knutson is exceptional at team building and motivating either at a peer-to-peer level, or in a leadership role with excellent communications skills and the ability to adapt to all environments and cultures with ease. Mick is a DZone MVB and is not an employee of DZone and has posted 18 posts at DZone. You can read more from them at their website. View Full User Profile

Enable Java assertions in Maven for Tomcat and Jetty

11.27.2012
| 2731 views |
  • submit to reddit

I wanted to enable assertions while running Jetty and Tomcat plugin’s with Maven and have not found any postings talking about how to enable assertions other than with surefire unit tests, and with a custom eclipse or intellij IDEA runner.

So what about on the command line?

Java assertions are enabled by the following syntax:

--ea[:...|:] or enableassertions  (to enable assertion at a particular package and class level)

But how can I enable them for the Tomcat Maven plugin?

I had tried the following options with no success:

export JAVA_OPTS="-ea"
export JAVA_ARGS="-ea"
export CATALINA_OPTS="-ea"
...
export JAVA_OPTS="-enableassertions"
export JAVA_ARGS="-enableassertions"
export CATALINA_OPTS="-enableassertions"

But the solution for adding MAVEN_OPTS as depicted:

export MAVEN_OPTS="-ea"
... or ...
export MAVEN_OPTS="-enableassertions"

Hopefully this can help other to use more assertions.


Published at DZone with permission of Mick Knutson, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)