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

List:       tapestry-user
Subject:    Re: Using Alfresco from within Tapestry
From:       Kaspar Fischer <fischerk () inf ! ethz ! ch>
Date:       2007-11-21 13:44:17
Message-ID: 5698F699-8BD2-4D89-86D4-9310E5143EFC () inf ! ethz ! ch
[Download RAW message or body]

Hi,

I am still working on how to get access, from my Tapestry webapp in  
Tomcat,
to a Spring bean called "nodeService" which is from a different  
webapp of
Tomcat (Alfresco in this case).

In my previous post, I have run into a problem with the load order:  
Alfresco
was loaded by Tomcat after Tapestry and because of this, the bean was  
not
found (it obviously does not yet exist when my Tapestry webapp starts).

I've managed to find a way around this by telling the bean  
"alfrescoContext"
(see below) to load lazily:

  <bean id="alfrescoContext"  
class="org.icarbasel.tapestry.knowledgecenter.alfresco.AlfrescoApplicati 
onContext" lazy-init="true">
   <property name="nodeService">
    <ref bean="nodeService" />
   </property>
  </bean>

(The rest is the same as in my previous post.)

I know get an exception

   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

I am asking myself now: Is Spring using a different "context" and  
does not
look in the webapp Alfresco for "nodeService" but only in Tapestry's  
Spring
"context"?

Any idea what is going wrong here?

Regards,
Kaspar

P.S. For the sake of completness I add my whole set of configuration/ 
Java files.

// WEB-INF/applicatonContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC
     "-//SPRING//DTD BEAN//EN"
     "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
  <bean id="alfrescoContext"  
class="org.icarbasel.tapestry.knowledgecenter.alfresco.AlfrescoApplicati 
onContext" lazy-init="true">
   <property name="nodeService">
    <ref bean="nodeService" />
   </property>
  </bean>
</beans>

// relevant part of web.xml
  <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>WEB-INF/applicationContext.xml</param-value>
  </context-param>

  <listener>
   <listener- 
class>org.springframework.web.context.ContextLoaderListener</listener- 
class>
  </listener>

// AlfrescoApplicationContext.java
package org.icarbasel.tapestry.knowledgecenter.alfresco;
import org.alfresco.service.cmr.repository.NodeService;
public class AlfrescoApplicationContext
{
   private NodeService nodeService;

   public void setNodeService(NodeService nodeService)
   {
     System.err.println("Received nodeService " + nodeService);
     this.nodeService = nodeService;
   }

   public NodeService getNodeService()
   {
     return this.nodeService;
   }
}

// ... and my page which spits out some dummy text
public abstract class NodePage extends BasePage {

   @InjectObject("spring:alfrescoContext")
   public abstract AlfrescoApplicationContext getAlfrescoContext();

   public String getGreetingSubject()
   {
     System.err.println(getAlfrescoContext().getNodeService());
     return "dummy";
   }
}


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