casinthecloud / cas-overlay-demo

CAS server demo using the Maven overlay
https://www.casinthecloud.com
73 stars 36 forks source link

Not able to run this demo #13

Closed ceciliazcx closed 8 years ago

ceciliazcx commented 8 years ago

I was able to run cas server last week (but cas-management does not work). I get the newest version of code from master branch today, and firstly, I got following failure when building it:

[INFO] CAS Overlay demo ................................... SUCCESS [ 0.357 s] [INFO] CAS Overlay server demo ............................ SUCCESS [ 11.574 s] [INFO] CAS Overlay management demo ........................ FAILURE [ 3.659 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 15.720 s [INFO] Finished at: 2016-05-02T14:25:55-07:00 [INFO] Final Memory: 20M/1412M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.2:war (default-war) on project cas-overlay-management-demo: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

then I add web.xml to management demo as following:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0" metadata-complete="true">
</web-app>

After this change, I can build successfully. But there is error when I try to run the project, the 2 main errors are as following: The first error is as following:

java.lang.ClassNotFoundException: org.jasig.cas.CasEnvironmentContextListener at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247) at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:429) at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:382) at org.eclipse.jetty.server.handler.ContextHandler.loadClass(ContextHandler.java:1514) at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitListener(StandardDescriptorProcessor.java:1831) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85) at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72) at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:337) at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1236) at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706) at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480) at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:293) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:277) at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511) at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364) at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:516) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

The second error is as following:

2016-05-02 14:02:28,951 ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [/WEB-INF/spring-configuration/*.xml]; nested exception is java.io.FileNotFoundException: ServletContext resource [/WEB-INF/spring-configuration/] cannot be resolved to URL because it does not exist at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:229) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:609) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:510) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:326) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:771) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:411) ~[jetty-servlet-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:763) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:247) ~[jetty-servlet-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1238) ~[jetty-webapp-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:480) ~[jetty-webapp-8.1.7.v20120910.jar:8.1.7.v20120910] at org.mortbay.jetty.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:293) ~[jetty-maven-plugin-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) ~[jetty-util-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:172) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) ~[jetty-util-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:229) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) ~[jetty-util-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.server.Server.doStart(Server.java:277) ~[jetty-server-8.1.7.v20120910.jar:8.1.7.v20120910] at org.mortbay.jetty.plugin.JettyServer.doStart(JettyServer.java:65) ~[jetty-maven-plugin-8.1.7.v20120910.jar:8.1.7.v20120910] at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) ~[jetty-util-8.1.7.v20120910.jar:8.1.7.v20120910] at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:511) ~[jetty-maven-plugin-8.1.7.v20120910.jar:8.1.7.v20120910] at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:364) ~[jetty-maven-plugin-8.1.7.v20120910.jar:8.1.7.v20120910] at org.mortbay.jetty.plugin.JettyRunMojo.execute(JettyRunMojo.java:516) ~[jetty-maven-plugin-8.1.7.v20120910.jar:8.1.7.v20120910] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ~[?:?] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ~[?:?] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) ~[?:?] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) ~[?:?] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) ~[?:?] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) ~[?:?] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) ~[?:?] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) ~[?:?] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) ~[?:?] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) ~[?:?] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) ~[?:?] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) ~[?:?] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) ~[?:?] at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_60] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_60] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) ~[?:?] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) ~[?:?] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) ~[?:?] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) ~[?:?] Caused by: java.io.FileNotFoundException: ServletContext resource [/WEB-INF/spring-configuration/] cannot be resolved to URL because it does not exist at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:156) ~[spring-web-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:419) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:287) ~[spring-core-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1269) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:216) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]

leleuj commented 8 years ago

In fact, the CAS server and management webapp have been "Spring bootified", so I must change the demos to match that. I'll try to do that next week (in holidays this week).

ceciliazcx commented 8 years ago

oh. Got it. Thx. I am going to use other branch. Could I ask a question here? I use Branch 4.0.x. When I use cas client(spring-webmvc-pac4j-boot-demo) to call it, the return casProfile is as following: profile: <CasProfile> | id: jleleu | attributes: {} | roles: [] | permissions: [] | isRemembered: false | I want to also have roles and attributes in the return data. the mock data is fine. I read deployerConfigContext.xml, I saw the code as following:

<!--
    Bean that defines the attributes that a service may return.  This example uses the Stub/Mock version.  A real implementation
    may go against a database or LDAP server.  The id should remain "attributeRepository" though.
    +-->
    <bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"
            p:backingMap-ref="attrRepoBackingMap" />

    <util:map id="attrRepoBackingMap">
        <entry key="uid" value="uid" />
        <entry key="prénom" value="eduPersonAffiliation" /> 
        <entry key="groupMembership" value="groupMembership" />
    </util:map>

I assume the above code is means we already have the mock data to be add to the attributes of return data. DO I misunderstand anything? How could I add a mock attribute and role to the return data? Thanks

leleuj commented 8 years ago

There are two issues to get the user attributes:

ceciliazcx commented 8 years ago

Thanks for your reply. For the client, I am so confused. what is the meaning of login url minus /login plus /p3? I do not think I have any login in url. In the server part, I have deployerConfigContext.xml as following: primaryAuthenticationHandler:

<bean id="primaryAuthenticationHandler" class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler">  
        <property name="users">  
            <map>  
                <entry key="test" value="1234"/>  
            </map>  
        </property>  
    </bean>

primaryPrincipalResolver:

<bean id="primaryPrincipalResolver"
          class="org.jasig.cas.authentication.principal.PersonDirectoryPrincipalResolver" >
        <property name="attributeRepository" ref="attributeRepository" />
    </bean>

attributeRepository:

<bean id="attributeRepository" class="org.jasig.services.persondir.support.StubPersonAttributeDao"
            p:backingMap-ref="attrRepoBackingMap" />

    <util:map id="attrRepoBackingMap">
        <entry key="uid" value="uid" />
        <entry key="prénom" value="eduPersonAffiliation" /> 
        <entry key="groupMembership" value="groupMembership" />
    </util:map>

And I use the following link to view the attribute. but there is no attribute. DO I missing anything?

http://localhost:8888/cas/login?service=http://localhost:8080 http://localhost:8888/cas/serviceValidate?ticket=ST-1-TPB23eEGopR02dcIv9Fh-cas01.example.org&service=http://localhost:8080

leleuj commented 8 years ago

To be straight, you should use the following url: http://localhost:8888/cas/p3/serviceValidate?ticket=ST-1-TPB23eEGopR02dcIv9Fh-cas01.example.org&service=http://localhost:8080 Note the /p3 part

ceciliazcx commented 8 years ago

But there still no attribute showing there. My server is exactly as my last reply. Did I still missing anything?

leleuj commented 8 years ago

Can you turn on DEBUG logs on org.jasig.cas on client side? To see what's going on...

ceciliazcx commented 8 years ago

I did not use client at this moment. only the server part and use "cas/p3/serviceValidate?ticket=" to call the server.

leleuj commented 8 years ago

I updated the 4.2.x branch, it should be ok on this one.