Update tomcat version only

775 views
Skip to first unread message

Mohamed Amdouni

unread,
Oct 19, 2023, 6:39:43 AM10/19/23
to cas-...@apereo.org
Hello,

When using cas version 6.6.12 for example the embedded tomcat server is 9.0.80. 
What is the best way to upgrade only the tomcat server to 9.0.81.

For spring boot application with maven it required only to set the tomcat.version pom properties.

Best regards,

King, Robert

unread,
Oct 19, 2023, 8:10:26 AM10/19/23
to cas-...@apereo.org

CAS 6.6.13 was released Oct. 16th and updated the embedded tomcat to 9.0.81.

 

--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/CALmwvcZLU41mQpPub942gXmca2t%3D7eoQau_oPDvKZGaqQNOEiQ%40mail.gmail.com.

Jonathon Taylor

unread,
Oct 19, 2023, 4:30:28 PM10/19/23
to cas-...@apereo.org
We've had a need from time-to-time to upgrade the embedded Tomcat separately and a kind soul helped us so I'll share what he showed us.  Just setting tomcat.version in gradle.properties will not work.  You can modify your build.gradle as follows:

configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, "seconds"
// etc
// Override from base CAS to use tomcatVersion
eachDependency { DependencyResolveDetails dependency ->
def requested = dependency.requested
if (requested.group.startsWith("org.apache.tomcat")) {
// println "Using tomcat version ${tomcatVersion} for ${requested.group}:${requested.name}"
dependency.useVersion("${tomcatVersion}")
}
}
}
exclude(group: "cglib", module: "cglib")
// etc
}

Then within the dependencies block where you would add various bits of CAS functionality:

/**
* CAS dependencies and modules may be listed here.
*
* There is no need to specify the version number for each dependency
* since versions are all resolved and controlled by the dependency management
* plugin via the CAS bom.
**/
implementation "org.apereo.cas:cas-server-support-whatever"
// etc

// Override from base CAS to use specified tomcatVersion
implementation "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}"
implementation "org.apache.tomcat.embed:tomcat-embed-el:${tomcatVersion}"
implementation "org.apache.tomcat:tomcat-catalina-ha:${tomcatVersion}"

And finally within the buildscript block at the end something like this to remove the version of tomcat that the upstream based CAS project is using:

overlays {
/*
Note: The "excludes" property is only for files in the war dependency.
If a jar is excluded from the war, it could be brought back into the final war as a dependency
of non-war dependencies. Those should be excluded via normal gradle dependency exclusions.
*/
cas {
from "org.apereo.cas:cas-server-webapp${project.appServer}:${project.'cas.version'}@war"

provided = false
// Exclude base CAS tomcat jars
excludes = ["WEB-INF/lib/servlet-api-2*.jar", "WEB-INF/lib/tomcat-*.jar"]
}
}

--
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
---
You received this message because you are subscribed to the Google Groups "CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cas-user+u...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/CALmwvcZLU41mQpPub942gXmca2t%3D7eoQau_oPDvKZGaqQNOEiQ%40mail.gmail.com.


--
Jonathon Taylor (he/him)
Information Security Office

Mohamed Amdouni

unread,
Oct 30, 2023, 1:30:41 PM10/30/23
to cas-...@apereo.org
Thank you this is what I’m looking for. Changing only the tomcat version.

Best regards.

Doug C

unread,
Nov 4, 2023, 1:25:30 PM11/4/23
to CAS Community, Jonathon Taylor
I attempted this method to update to Tomcat 9.0.82.  The first two sections of your instructions work for me but when I attempt to remove the version of Tomcat that CAS is using upstream using the third section of your instructions, I receive the following error:

FAILURE: Build failed with an exception.

* Where:
Build file '/cas-overlay/build.gradle' line: 43

* What went wrong:
A problem occurred evaluating root project 'cas'.
> Could not find method overlays() for arguments [build_ep14vlqtz5elu1r5h6m9cwzsu$_run_closure1$_closure4@43ae0bb2] on object of type org.gradle.api.internal.initialization.DefaultScriptHandler.

I'm not sure what I am missing.  Any thoughts?

Thanks!

Jonathon Taylor

unread,
Nov 6, 2023, 1:47:44 PM11/6/23
to Doug C, CAS Community
I think that was a mistake on my part.  We actually have that third section embedded in a stand-alone bootWar block and NOT within the buildscript block.  Here's what that definition looks like in full:

bootWar {
def executable = project.hasProperty("executable") && Boolean.valueOf(project.getProperty("executable"))
if (executable) {
logger.info "Including launch script for executable WAR artifact"
launchScript()
} else {
logger.info "WAR artifact is not marked as an executable"
}

archiveName "cas.war"
baseName "cas"

entryCompression = ZipEntryCompression.STORED

/*
attachClasses = true
classesClassifier = 'classes'
archiveClasses = true
*/

overlays {
/*
Note: The "excludes" property is only for files in the war dependency.
If a jar is excluded from the war, it could be brought back into the final war as a dependency
of non-war dependencies. Those should be excluded via normal gradle dependency exclusions.
*/
cas {
from "org.apereo.cas:cas-server-webapp${project.appServer}:${project.'cas.version'}@war"

provided = false
// Exclude base CAS tomcat jars
excludes = ["WEB-INF/lib/servlet-api-2*.jar", "WEB-INF/lib/tomcat-*.jar"]
/*
excludes = ["WEB-INF/lib/somejar-1.0*"]
enableCompilation = true
includes = ["*.xyz"]
targetPath = "sub-path/bar"
skip = false
*/
}
}
}

Doug C

unread,
Nov 6, 2023, 5:21:10 PM11/6/23
to CAS Community, Jonathon Taylor, CAS Community
That worked perfectly!  Thanks!
Reply all
Reply to author
Forward
0 new messages