Issues using CAS JSON Service Registry. CAS 5.0.0.RC4-SNAP

932 views
Skip to first unread message

Facundo Bove

unread,
Oct 19, 2016, 8:38:11 AM10/19/16
to CAS Community
Hello,

I am having an issue when I add cas-server-support-json-service-registry to my cas-gradle-overlay project.
Imho it has something to do with the defaultTemplateResolver.

It loads well:

2016-10-17 10:25:09,134 INFO [org.apereo.cas.web.CasWebApplication] - <The following profiles are active: native>
2016-10-17 10:25:21,909 INFO [org.apereo.cas.services.AbstractResourceBasedServiceRegistryDao] - <Watching service registry directory at /tmp/cas/services>
2016-10-17 10:25:22,273 INFO [org.apereo.cas.services.DefaultServicesManagerImpl] - <Loaded 3 services from JsonServiceRegistryDao.>

But then it crashes:

2016-10-17 10:25:25,709 WARN [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'passwordManagementConfiguration': Unsatisfied dependency expressed through field 'loginFlowDefinitionRegistry'; nested exception isorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'casWebflowContextConfiguration': Unsatisfied dependency expressed through field 'registeredServiceViewResolver'; nested exception isorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'casThemesConfiguration': Unsatisfied dependency expressed through field 'thymeleafViewResolver'; nested exception isorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$Thymeleaf3ViewResolverConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]:Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.NullPointerException>
2016-10-17 10:25:25,712 WARN [org.apereo.cas.services.ServiceRegistryConfigWatcher] - <Directory key is no longer valid. Quitting watcher service>

Currently targeting:

gradle.version=3.0
sourceCompatibility
=1.8
targetCompatibility
=1.8

cas
.version=5.0.0.RC4-SNAPSHOT
springboot
.version=1.4.1.RELEASE


I have added this dependency to build.gradle:

runtime("org.apereo.cas:cas-server-support-json-service-registry:${project.'cas.version'}")

My cas-gradle-overlay-app/etc/cas/config/application.yml  has this setting, among others.

cas:
  serviceRegistry
:
    watcherEnabled
: true
    repeatInterval
: 120000
    startDelay
: 15000
    initFromJson
: true
    config
:
      location
: classpath:/services


This folder: cas-gradle-overlay-app/cas/src/main/resources/services  contains this json:

{
  
"@class" : "org.apereo.cas.services.RegexRegisteredService",
  
"serviceId" : "testId",
  
"name" : "testJsonFile",
  
"id" : 103935657744185,
  
"evaluationOrder" : 1
}

Any help would be appreciate.
Extra info: I am using LDAP connector and get logged in correctly.

If I am lacking or misunderstanding something please let me know.

Regards,

Misagh Moayyed

unread,
Oct 20, 2016, 4:05:39 AM10/20/16
to CAS Community, Facundo Bove

You will need to submit your overlay to the issues project so it can duplicated. This is more likely pilot error.

--
CAS gitter chatroom: https://gitter.im/apereo/cas
CAS mailing list guidelines: https://apereo.github.io/cas/Mailing-Lists.html
CAS documentation website: https://apereo.github.io/cas
CAS project website: https://github.com/apereo/cas
---
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 post to this group, send email to cas-...@apereo.org.
Visit this group at https://groups.google.com/a/apereo.org/group/cas-user/.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/34ab9655-7abb-4eae-90d4-299a741e88e2%40apereo.org.
For more options, visit https://groups.google.com/a/apereo.org/d/optout.
-- 
Misagh

Facundo Bove

unread,
Oct 20, 2016, 3:06:48 PM10/20/16
to CAS Community, fjb...@gmail.com, mmoa...@unicon.net
Hello Misagh,
Thanks for answering :)

I have isolated the issue. It seems to be related to the gradle overlay.

If you add cas-server-support-json-service-registry to a clean cas-gradle-overlay version 5.0.0.RC3 and try to run it, it fails.
However if you add cas-server-support-json-service-registry in cas-maven-overlay version 5.0.0.RC3 and run it, it works well.

Both overlays are a clean checkout without modifications (except adding the json registry dep)

Regards,


El jueves, 20 de octubre de 2016, 5:05:39 (UTC-3), Misagh Moayyed escribió:

You will need to submit your overlay to the issues project so it can duplicated. This is more likely pilot error.

Misagh Moayyed

unread,
Oct 20, 2016, 5:38:46 PM10/20/16
to CAS Community

I am confused. You had RC4 initially in your config, yet your report in your last email references RC3. Please clarify. 


From: Facundo Bove <fjb...@gmail.com>
Reply: Facundo Bove <fjb...@gmail.com>
Date: October 20, 2016 at 10:36:57 PM
To: CAS Community <cas-...@apereo.org>
Cc: fjb...@gmail.com <fjb...@gmail.com>, mmoa...@unicon.net <mmoa...@unicon.net>
Subject:  Re: [cas-user] Issues using CAS JSON Service Registry. CAS 5.0.0.RC4-SNAP
Hello Misagh,
Thanks for answering :)

I have isolated the issue. It seems to be related to the gradle overlay.

If you add cas-server-support-json-service-registry to a clean cas-gradle-overlay version 5.0.0.RC3 and try to run it, it fails.
However if you add cas-server-support-json-service-registry in cas-maven-overlay version 5.0.0.RC3 and run it, it works well.

Both overlays are a clean checkout without modifications (except adding the json registry dep)

Regards,

El jueves, 20 de octubre de 2016, 5:05:39 (UTC-3), Misagh Moayyed escribió:

You will need to submit your overlay to the issues project so it can duplicated. This is more likely pilot error.

From: Facundo Bove <fj...@gmail.com>
Reply: Facundo Bove <fj...@gmail.com>
-- 
Misagh

Facundo Bove

unread,
Oct 20, 2016, 11:44:15 PM10/20/16
to CAS Community, mmoa...@unicon.net
Yes, sorry. I did not explained that.

The same issue happens with RC4.Snapshot and RC3 Gradle Overlay + Json Service Registry.

Regards,


El jueves, 20 de octubre de 2016, 18:38:46 (UTC-3), Misagh Moayyed escribió:

I am confused. You had RC4 initially in your config, yet your report in your last email references RC3. Please clarify. 

Misagh Moayyed

unread,
Oct 21, 2016, 2:59:39 AM10/21/16
to CAS Community, Facundo Bove

Perfect. Thanks. Could I ask you to file an issue on the overlay project and include details, logs, etc? Just so we don’t forget to get to it. 


From: Facundo Bove <fjb...@gmail.com>
Reply: Facundo Bove <fjb...@gmail.com>
Date: October 21, 2016 at 7:14:25 AM
To: CAS Community <cas-...@apereo.org>
Cc: mmoa...@unicon.net <mmoa...@unicon.net>
Subject:  Re: [cas-user] Issues using CAS JSON Service Registry. CAS 5.0.0.RC4-SNAP

Yes, sorry. I did not explained that.

The same issue happens with RC4.Snapshot and RC3 Gradle Overlay + Json Service Registry.

Regards,

El jueves, 20 de octubre de 2016, 18:38:46 (UTC-3), Misagh Moayyed escribió:

I am confused. You had RC4 initially in your config, yet your report in your last email references RC3. Please clarify. 


From: Facundo Bove <fj...@gmail.com>
Reply: Facundo Bove <fj...@gmail.com>
Date: October 20, 2016 at 10:36:57 PM
-- 
Misagh

Yauheni Sidarenka

unread,
Oct 21, 2016, 6:07:27 AM10/21/16
to CAS Community, fjb...@gmail.com, mmoa...@unicon.net
Hello,

I have the same issue for Pac4j delegation using Gradle WAR Overlay. I tried 5.0.0.RC3 and 5.0.0.RC4-SNAPSHOT.
I am using Oracle JDK 1.8.0_60.

I added this to cas\build.gradle:
compile("org.apereo.cas:cas-server-support-pac4j-webflow:${project.'cas.version'}")

Properties:
cas.server.name: https://mymachine.mycompanycom:8445
cas
.server.prefix: https://mymachine.mycompany.com:8445/cas
cas
.adminPagesSecurity.ip=127\.0\.0\.1
logging
.config: file:/etc/cas/config/log4j2.xml
cas
.authn.accept.users=
cas
.authn.pac4j.typedIdUsed=true
cas
.logout.followServiceRedirects=true
server
.port=8445

I tried to start CAS on embedded Tomcat using "java -jar cas\build\libs\cas.war" and I got this:

←[36m
  __  ____     _     ____  __
 
/ / / ___|   / \   / ___| \ \
| | | |      / _ \  \___ \  | |
| | | |___  /
___ \  ___) | | |
| |  \____|/_/   \_\|____/  | |
 
\_\                       /_/

CAS
Version: 5.0.0.RC4-SNAPSHOT
Build Date/Time: 2016-10-21T08:39:25.088Z
System Temp Directory: C:\Users\Yauheni_Sidarenka\AppData\Local\Temp\
Java Home: C:\Program Files\Java\jdk1.8.0_60\jre
Java Vendor: Oracle Corporation
Java Version: 1.8.0_60
JCE
Installed: no
OS
Architecture: amd64
OS
Name: Windows 7
OS
Version: 6.1

←[0m
2016-10-21 11:43:03,788 INFO [org.apereo.cas.web.CasWebApplication] - <The following profiles are active: native>
2016-10-21 11:43:09,311 WARN [org.apereo.cas.services.InMemoryServiceRegistryDaoImpl] - <Runtime memory is used as the persistence storage for retrieving and persisting service definitions. Changes that are made to service definitions during runtime WILL be LOST upon container restarts.>
2016-10-21 11:43:09,342 INFO [org.apereo.cas.services.DefaultServicesManagerImpl] - <Loaded 0 services from InMemoryServiceRegistryDaoImpl.>
2016-10-21 11:43:09,545 WARN [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletContainer' defined in class path resource [org/apereo/cas/config/CasEmbeddedContainerConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration': Unsatisfied dependency expressed through field 'errorViewResolvers'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pac4jWebflowConfiguration': Unsatisfied dependency expressed through field 'loginFlowDefinitionRegistry'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'casWebflowContextConfiguration': Unsatisfied dependency expressed through field 'registeredServiceViewResolver'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'casThemesConfiguration': Unsatisfied dependency expressed through field 'thymeleafViewResolver'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$Thymeleaf3Configuration$Thymeleaf3ViewResolverConfiguration': Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration$ThymeleafDefaultConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultTemplateResolver' defined in class path resource [org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration$Thymeleaf3Configuration$DefaultTemplateResolverConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver]: Factory method 'defaultTemplateResolver' threw exception; nested exception is java.lang.NullPointerException>
And application has stopped.

The external Tomcat is more talkative, see logs attached for RC3 and RC4-SNAPSHOT.

Also I tried to start via "gradlew bootRun" and I got this:
Copying configuration to /etc/cas/config
:cas:compileJava UP-TO-DATE
:cas:processResources UP-TO-DATE
:cas:classes UP-TO-DATE
:cas:findMainClass
:cas:bootRun FAILED

FAILURE
: Build failed with an exception.

* What went wrong:
Execution failed for task ':cas:bootRun'.
> Process 'command 'C:\Program Files\Java\jdk1.8.0_60\bin\java.exe'' finished with non-zero exit value 1

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 4.902 secs

I noticed that when I added pac4j dependency to overlay some extra library have appeared in the cas.war file. I mean thymeleaf-2.1.5.RELEASE.jar and thymeleaf-spring4-2.1.5.RELEASE.jar. But there are also new versions of these libraries: thymeleaf-3.0.1.RELEASE.jar and thymeleaf-spring4-3.0.1.RELEASE.jar. It seems to be wrong to have two versions together.
I has debugged org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration.Thymeleaf3Configuration.DefaultTemplateResolverConfiguration and the problem is it tries to find method
setCheckExistence(boolean) in class SpringResourceTemplateResolver, which does not have this method in version 2.1.5, but has one in version 3.0.1 as inherited from AbstractTemplateResolver

As far as there are two versions of library in classpath I may guess that application loads old version of class instead of the new one because the older version comes first alphabetically.

Regards, Yauheni


On Friday, October 21, 2016 at 9:59:39 AM UTC+3, Misagh Moayyed wrote:

Perfect. Thanks. Could I ask you to file an issue on the overlay project and include details, logs, etc? Just so we don’t forget to get to it. 

5.0.0.RC3.log
5.0.0.RC4-SNAPSHOT.log
Reply all
Reply to author
Forward
0 new messages