Return to Jive Software

This Question is Answered (go to answer)

1 "helpful" answer available (2 pts)
1,420 Views 3 Replies Last post: Dec 2, 2008 8:25 AM by Todd West RSS
Sean Thatcher Novice 16 posts since
May 21, 2008
Currently Being Moderated

Dec 1, 2008 8:02 PM

How do I get my plugins spring beans with JiveContext?

In developing a plugin I came into a situation where I needed to lookup a spring bean (without injection) but wasn't sure exactly how to within the clearspace framework (version 2.5.4).  First off, the reason: I'm placing a link on the Actions tab of a community but I'm using a <when> tag in my plugin.xml to determine whether the link should be shown or not. The test is somewhat complex and is part of a Manager class.  In order to support the <when> tag I created a class with a static function that tries to lookup the Manager (which is configured as a Spring Bean) via the JiveContext.getJiveManager() function but I get the following error:

 

22:42:24,187 [http-8080-2] ERROR com.jivesoftware - Error loading proxy 'TestManager' for class 'com.test.impl.TestManagerImpl, returning unproxied object
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'TestManager' is defined
    at com.jivesoftware.community.lifecycle.spring.JiveDefaultListableBeanFactory.getBeanDefinition(JiveDefaultListableBeanFactory.java:348)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:968)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:246)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)

The spring.xml file is:

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"
       default-destroy-method="destroy">

 

    <bean id="testManager" class="com.test.impl.TestManagerImpl" parent="jiveManager">
        <property name="communityManager" ref="communityManagerImpl"></property>
    </bean>

 

</beans>

 

Attached is an example of plugin and that produces the above error and is the same error given for the plugin that I'm developing.  Otherwise everything else is working with no other errors.  I have at least determined that spring is indeed creating the class. Any suggestions??

 

Regards,

 

Sean

Attachments:
Tags: plugins, spring
Todd West Jive Employee 15,912 posts since
Jul 14, 2008
Currently Being Moderated
Dec 2, 2008 6:19 AM in response to: Sean Thatcher
Re: How do I get my plugins spring beans with JiveContext?

Hi Sean,

 

I haven't been able to test this but what if you do something like:

TestManager testManager = (TestManager) JiveApplication.getContext().getSpringBean("testManager");

 

 

-Todd

Todd West Jive Employee 15,912 posts since
Jul 14, 2008
Currently Being Moderated
Dec 2, 2008 8:25 AM in response to: Sean Thatcher
Re: How do I get my plugins spring beans with JiveContext?

Hi Sean,

 

The difference between the context and the effectiveContext depends on which kind of managers you are looking to retrieve. Using just straight context will get unproxied managers which means that effectively no permissions are enforced on these objects. Using the effectiveContext will return proxied managers which will ensure that the user executing this code has the appropriate permissions to do so.

 

If the user is a system admin they will get unproxied managers in either case. So basically, you would want to use the effectiveContext if you are looking to restrict access to managers based on permissions. Hopefully that makes sense. Thanks.

 

-Todd

More Like This

  • Retrieving data ...

Bookmarked By (0)