Service registry initialisation using JSON files. Help needed

1,658 views
Skip to first unread message

Rémi Cocula

unread,
Aug 9, 2017, 11:53:24 AM8/9/17
to CAS Community

Hi,

Using CAS 5.1

I want to populate the service registry using individual JSON files for each service declaration.

I added this property in my configuration : cas.serviceRegistry.initFromJson=true

Hence, any file myapp-123.json will be scanned to register a service but it only works if such a file reside in a services directory inside the java classpath.

I would like to externalize these files to a desired local directory.

I tried to set that in my configuration : cas.serviceRegistry.config.location=file://D:/entorno/ide/workspace/sso-cas/dist/etc/cas/services

But the D:/entorno/ide/workspace/sso-cas/dist/etc/cas/services does not seam to be scanned.



David Curry

unread,
Aug 9, 2017, 12:15:53 PM8/9/17
to cas-...@apereo.org
You also have to add

    <dependency>
        <groupId>org.apereo.cas</groupId>
        <artifactId>cas-server-support-json-service-registry</artifactId>
        <version>${cas.version}</version>
    </dependency>

to your pom.xml.

--Dave




--

DAVID A. CURRY, CISSP
DIRECTOR OF INFORMATION SECURITY
INFORMATION TECHNOLOGY

71 FIFTH AVE., 9TH FL., NEW YORK, NY 10003
+1 212 229-5300 x4728david...@newschool.edu

The New School


--
- 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+unsubscribe@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/d95f3bd0-fd74-43c4-b634-7a92b6638ca0%40apereo.org.

Bergner, Arnold

unread,
Aug 10, 2017, 3:28:55 AM8/10/17
to cas-...@apereo.org

I think the ability to use external files for this only came in the last Release Candidate:

https://apereo.github.io/2017/08/04/520rc2-release/#minors

 

 

Von: cas-...@apereo.org [mailto:cas-...@apereo.org] Im Auftrag von David Curry
Gesendet: Mittwoch, 9. August 2017 18:16
An: cas-...@apereo.org
Betreff: Re: [cas-user] Service registry initialisation using JSON files. Help needed

 

You also have to add

 

    <dependency>

        <groupId>org.apereo.cas</groupId>

        <artifactId>cas-server-support-json-service-registry</artifactId>

        <version>${cas.version}</version>

    </dependency>

 

to your pom.xml.

 

--Dave

 

 

 

--

DAVID A. CURRY, CISSP
DIRECTOR OF INFORMATION SECURITY
INFORMATION TECHNOLOGY

71 FIFTH AVE., 9TH FL., NEW YORK, NY 10003
+1 212 229-5300 x4728david...@newschool.edu

Das Bild wurde vom Absender entfernt. The New School

 

On Wed, Aug 9, 2017 at 11:53 AM, Rémi Cocula <rco...@gmail.com> wrote:


Hi,

Using CAS 5.1

I want to populate the service registry using individual JSON files for each service declaration.

I added this property in my configuration : cas.serviceRegistry.initFromJson=true

Hence, any file myapp-123.json will be scanned to register a service but it only works if such a file reside in a services directory inside the java classpath.

I would like to externalize these files to a desired local directory.

I tried to set that in my configuration : cas.serviceRegistry.config.location=file://D:/entorno/ide/workspace/sso-cas/dist/etc/cas/services

But the D:/entorno/ide/workspace/sso-cas/dist/etc/cas/services does not seam to be scanned.


--

- 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.

 

--

- 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 view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/CA%2Bd9XANAwcZw%3DkuGEYtNiCzE20Xzy5toXeK6_OgG2C_5fP%2BjcQ%40mail.gmail.com.

Rémi Cocula

unread,
Sep 19, 2017, 11:43:46 AM9/19/17
to CAS Community
Adding the dependency worked.

Thanks !

Didier Capdevielle

unread,
Sep 20, 2017, 4:36:56 AM9/20/17
to CAS Community
Hi all,
I use CAS server 5.1.3 on Debian Stretch with Tomcat8 and Java 1.8
In cas.properties,
cas.serviceRegistry.initFromJson=true

cas.serviceRegistry.config.location=file://etc/cas/json
In pom.xml, the needed dependency.
But don't work (NB: It works if i cas.serviceRedistry.config.location is in comment)

When i want to start Tomcat8, here is the catalina.out :
2017-09-20 10:15:56,974 WARN [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext] - <Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: IO error opening file stream.>
2017-09-20 10:15:56,974 WARN [org.apereo.cas.services.ServiceRegistryConfigWatcher] - <Directory key is no longer valid. Quitting watcher service>
Exception in thread "org.apereo.cas.services.JsonServiceRegistryDao" java.nio.file.ClosedWatchServiceException
        at sun.nio.fs.AbstractWatchService.checkOpen(AbstractWatchService.java:80)
        at sun.nio.fs.AbstractWatchService.checkKey(AbstractWatchService.java:92)
        at sun.nio.fs.AbstractWatchService.take(AbstractWatchService.java:119)
        at org.apereo.cas.services.ServiceRegistryConfigWatcher.run(ServiceRegistryConfigWatcher.java:72)
        at java.lang.Thread.run(Thread.java:748)
2017-09-20 10:15:57.000 INFO net.spy.memcached.MemcachedClient:  Suppressing duplicate attempt to shut down
2017-09-20 10:15:57.005 INFO net.spy.memcached.MemcachedConnection:  Shut down memcached client
20-Sep-2017 10:15:57.024 SEVERE [localhost-startStop-1] org.apache.catalina.core.ContainerBase.addChildInternal ContainerBase.addChild: start:
 org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/cas]]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'serviceRegistryInitializer': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: IO error opening file stream.
(and so on)

Any idea ? any help ?
Thanks in advance.

Best regards,




Andy Ng

unread,
Sep 20, 2017, 9:17:07 PM9/20/17
to CAS Community
Hi Didier,

Seems like your service registry config location is invalid. In my application.properties I always uses file:/ instead of file:// and it works.

Maybe you can tries
cas.serviceRegistry.config.location=file:/etc/cas/json

if not ok, you can also try 
cas.serviceRegistry.config.location=/etc/cas/json

Also, please note that file:/etc/cas/json does not mean [Your CAS project directory]/etc/cas/json. It means [Your disk folder]/etc/cas/json.
In case you want the location to be [Your CAS project directory], you can use cas.serviceRegistry.config.location=classpath:/services

Hope this helps you!
-Andy

Didier Capdevielle

unread,
Sep 21, 2017, 8:56:24 AM9/21/17
to CAS Community
Hi Andy,
Thanks for your answer.
Unfortunately, that don't work.
I yet try any possibilities : file:///etc/cas/json ; file://etc/cas/json ; file:/etc/cas/json ; /etc/cas/json ; ...
In 5.0.x (and perhaps in 4.2.x), it worked but i don't remember the thing(s) i did to make this working (and i delete cas VM).
Thanks.
Best regards,



David Curry

unread,
Sep 21, 2017, 9:33:47 AM9/21/17
to cas-...@apereo.org
Didier,

Is /etc/cas/json a file, or a directory? CAS is expecting it to be a directory, with individual JSON files for each service underneath, like this:

/       <-- file system root
  etc/
    json/
      Apereo-10000002.json
      HTTPSandIMAPS-10000001.json

Assuming you have added the cas-server-support-json-service-registry dependency to pom.xml, a line in cas.properties like this:

cas.serviceRegistry.config.location:    file:/etc/cas/json

should work fine. Make sure the directory and files are accessible by the "tomcat" user (or whatever user you're using to run the Tomcat/CAS server).

You do not need the cas.serviceRegistry.initFromJson property; that only applies to the built-in service registry initialization code, which was superseded when you added the dependency to pom.xml.

--Dave





--

DAVID A. CURRY, CISSP
DIRECTOR OF INFORMATION SECURITY
INFORMATION TECHNOLOGY

71 FIFTH AVE., 9TH FL., NEW YORK, NY 10003
+1 212 229-5300 x4728david...@newschool.edu

The New School


--
- 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+unsubscribe@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/cas-user/3fa40dae-3a90-4a35-a6eb-7de3c6f2f51c%40apereo.org.

Ray Bon

unread,
Sep 21, 2017, 11:44:49 AM9/21/17
to cas-...@apereo.org
Didier,

In your original email your path starts with D:/entorno/...
file:///etc/... is an absolute path on unix like systems.
Try:
file:///D:/entorno/ide/workspace/sso-cas/dist/etc/cas/services



Ray
-- 
Ray Bon
Programmer analyst
Development Services, University Systems
2507218831 | CLE 019 | rb...@uvic.ca

Josef....@t-systems.com

unread,
Sep 21, 2017, 3:19:01 PM9/21/17
to cas-...@apereo.org

Hello Didier,

 

not sure because Iam just beginning to work on it,

but in other mails I saw, that they configure the location-path with only one slash after the file in the string.

 

In your cas may be this “cas.serviceRegistry.config.location: file:/etc/cas/services“ would work?

 

Kind Regards Josef

--
- 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/a98cda0c-83ab-4eb8-91ef-b6f5000b224d%40apereo.org.

Didier Capdevielle

unread,
Sep 22, 2017, 3:34:53 AM9/22/17
to CAS Community

Thanks all (and especially David) for your response,
Stupid i am. Problem was a right access to the directory (and files). Of course.
Making the directory and files accessible by the "tomcat" user (tomcat8 in my case) is the solution (in my case).
Thanks,
Best regards
PS: Many syntax work fine (with = or with :). The problem was not here.




Didier Capdevielle

unread,
Sep 23, 2017, 6:23:16 AM9/23/17
to CAS Community


PS: Many syntax work fine (with = or with :). The problem was not here.

I'm not sure of that. I beleived that but my Ansible role was not up-to-date.
Sorry.
Best regards, 
Reply all
Reply to author
Forward
0 new messages