cancel
Showing results for 
Search instead for 
Did you mean: 

Hosting Spring-based dynamic webapps with Alfresco WCM

bjornl
Champ in-the-making
Champ in-the-making
Is it possible in an easy way to host spring-based web applications with Alfresco WCM? As was pointed out in another post regarding using java technologies other than plain jsp/servlets, it should theoretically work but for frameworks accessing for example configuration files, it might not (see http://forums.alfresco.com/viewtopic.php?t=3630).

I have further tried it out making a simple example, but I experience some class loading issues. I assume this might be due to the fact that the spring.jar is loaded from common/lib of the virtualization server, so by a classloader that does not have access to my deployed web application classes directly if I'm not mistaken. I don't find a good way to solve these issues I am experiencing anyway.

Has anyone tried this, or can anyone provide some further insight to the topic?

Best regards,
Björn
3 REPLIES 3

alexander
Champ in-the-making
Champ in-the-making
You might need to mount you alfresco AVM share as V: drive (on windows) or /media/alfresco/cifs/v on Linux.

jcox
Champ in-the-making
Champ in-the-making
For now, try removing the Spring jar file from your
webapp, and rely upon the one pre-loaded by the
virtualization server.  In the near future, I hope to
make this unnecessary, but for now that's what
you've got to do.

Tomcat's classloader hiararchy looks like this:
                    
                              Bootstrap
                                  |
                               System
                                  |
                               Common
                              /      \
                         Catalina   Shared
                                     /   \
                                Webapp1  Webapp2

Classloader rules:
  • Classloaders will only load the "same" class once.

  • Two classes are only the "same" if they have the same name, and were loaded by the same classloader.

  • When your webapp references a class, if it's not already loaded, the search order goes:
  • yourWebapp –>  Shared –> Common –> System –> Bootstrap
Currently, the virtualization server needs the Spring jar file within
$VIRTUAL_TOMCAT_HOME/common/lib/  (i.e.: Common in the diagram above).

Thus, your webapp does have access to the pre-loaded Spring libs in Common.
It also has access to the Spring jar you've got in your webapp…
and that's the problem.

What I'm planning on doing is restructuring things a bit so that
the virt server's use of Spring is completely invisible to the webapps
it hosts. I've just filed a bug so you can see when this issue is resolved:
http://issues.alfresco.com/browse/WCM-494

jcox
Champ in-the-making
Champ in-the-making
I've just fixed WCM-494.

Therefore, given your build is new enough, you should now be able to
virtualize webapps that contain Spring without doing anything special
(i.e:  you don't need to remove spring.jar from your webapp).

  Cheers,
  -Jon