peholmst / SpringSecurityDemo

An example application demonstrating how to use Spring Security in a Vaadin application
56 stars 33 forks source link

Circular View Path Exception #4

Open myungsunscott opened 6 years ago

myungsunscott commented 6 years ago

Hi Peter, thanks for the Spring Security Filtering Demo. It's exactly what I'm trying to include in a Vaadin spring boot project of my own, but I'm having trouble replicating your example.

I'm getting a "Circular View Path" exception.

I've included the following dependencies (plus all the other relevant stuff):

compile 'com.vaadin:vaadin-spring-boot-starter:1.2.0'
compile 'org.springframework.boot:spring-boot-starter-security:1.3.3.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-velocity:1.3.3.RELEASE'

I've also tried using newer versions of the dependencies above, but no luck.

compile 'com.vaadin:vaadin-spring-boot-starter:3.0.0'
compile 'org.springframework.boot:spring-boot-starter-security:1.5.10.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-velocity:1.4.7.RELEASE'

One thing I notice in the demo's startup logs is that Velocity starts up, a SpringResourceLoader becomes available for Velocity and the /templates/ folder is assigned as a resource path. See below:

o.s.w.s.v.velocity.VelocityConfigurer    : ClasspathResourceLoader with name 'springMacro' added to configured VelocityEngine                                                        
o.s.ui.velocity.SpringResourceLoader     : SpringResourceLoader for Velocity: using resource loader [org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplication
Context@1d15d980: startup date [Thu Mar 15 14:22:56 GMT 2018]; root of context hierarchy] and resource loader paths [classpath:/templates/] 

However, I never see these Velocity startup logs in my own application.

So, I'm guessing Velocity isn't configured correctly in my app, but I don't see where it's configured in the demo.

Can you help? Thanks!

peholmst commented 6 years ago

The first thing I would check in this case is to make sure you have not accidentally protected the views that you are redirecting to when access is denied, like requiring authentication to be able to access the login view.

myungsunscott commented 6 years ago

Thanks for the tip!

I eventually found out that Apache Velocity was the issue (not supported in spring boot 1.4 and above. I replaced it with Freemarker, then adjusted the templates and it is now ALMOST working as expected.

I can access the login page and successfully authenticate with Spring Security. Then, the Vaadin UI loads up, but none of the views are available!

I've debugged and neither the navigator nor viewProvider are null. It's just the views aren't being added to the navigator.

java.lang.IllegalArgumentException: Trying to navigate to an unknown state

I've followed the examples you outlined in your filtering example for the views, navigator, view provider, UI etc.

@peholmst do you think it's a versioning issue yet again?

here are relevant dependencies as they stand:

compile 'com.vaadin:vaadin-spring-boot-starter:3.0.0'
compile ('org.springframework.boot:spring-boot-starter-security:1.5.9.RELEASE'){
   exclude group: 'org.springframework', module: 'boot'
}
compile ('org.springframework.boot:spring-boot-starter-freemarker:1.5.9.RELEASE'){
   exclude group: 'org.springframework', module: 'boot'
}