[prev in list] [next in list] [prev in thread] [next in thread] 

List:       tapestry-user
Subject:    Re: Using Alfresco from within Tapestry
From:       carlos f <car_lost () yahoo ! com>
Date:       2007-11-20 17:29:02
Message-ID: 13861372.post () talk ! nabble ! com
[Download RAW message or body]




hbf wrote:
> 
> and everything works beautifully up to the load order of the webapps:
> As my module starts before Alfresco, I cannot reference the (yet non-
> existing) bean of Alfresco that represents the Alfresco Node Service!
> 
> . . . 
> 
> Everything works fine up to the point when I change '<value>Foo</value>'
> to '<ref bean="nodeService" />' in my bean (and of course change the
> type in the bean class from String to Alfresco's NodeService).
> 
> At this point I get at startup
> 
> ERROR main org.springframework.web.context.ContextLoader - Context
> initialization failed
> org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'alfrescoContext' defined in  
> ServletContext resource
> [/WEB-INF/applicationContext.xml]: Cannot resolve reference to bean
> 'nodeService' while setting bean property 'nodeService'; nested  
> exception
> is  
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No
> bean named 'nodeService' is defined
> 
> And I sort of understand it: At this point, Alfresco is started by
> Tomcat after my Tapestry webapp and it seems that due to its multi-
> threaded nature, one cannot require a particular order in which the
> webapps are deployed.
> 
> Any suggestion as to what I could do?
> 
> I though about calling Spring's getBean() not at startup but at a later
> point but do not have any idea which application context to use, i.e.,
> how to obtain an application context at all!?
> 

If I understanding you have two spring application contexts defined in two
separate web applications:

- alfresco (3rd party CMS system that defines a bean you want to use)
- mywebapp (custom tapestry application that will consume a bean defined by
alfresco)

If that is the case, I think your core problem is that by default, web
application contexts don't span web applications.  So a particular war's
beans are referenced through the web application context stored in that
application's servlet context.  The web application context in turn, is
built exclusively using all the context files listed in that web
application's contextConfigLocation param (or the default
applicationContext.xml file).

A web application context, is pretty isolated to the particular servlet
context in which it is defined.   Although your web application context can
access external resources, such as WS, JDBC, JNDI, JMS etc, the client/proxy
beans you are using to access those external resources are always local to
your web application context.

I might be living in a cave, but I don't know of an out of the box method
for DIRECTLY accessing beans defined in one servlet context to access beans
defined in another servlet context.

If that is true . . . I am not quite sure what your best options are.

- If you have access to the application context files in the alfresco war,
you could add some sort of remote exporter (WS, RMI etc) so that the spring
application context in your tapestry web application could consume it. 
However, remote calls are far more expensive than local communication and
some of the remoting options baked into spring may not support the services
you want to export (e.g. HttpInvoker requires java.io serialization).  

- Depending on the servlet container you are using you could try to
programmatically access servlet context A from servlet context B.  If you
can get access to the servlet context then you can get access to the spring
web application context that is stored in it.  Doing that would allow you,
in some fashion, to access context A beans from context B.  Spring
application contexts support the concept of application context hierarchies. 
Perhaps you can use that to make the context in B treat the context in A as
its parent.  You will also need to time the startup of the web application
contexts so that the alfresco context is always completely initialized
before your application starts initializing its context.  I would search
around the spring forums for any suggestions or existing solutions.

Good luck.

Carlos

-- 
View this message in context: \
http://www.nabble.com/Using-Alfresco-from-within-Tapestry-tf4831087.html#a13861372 \
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic