Having problems creating a new kind of Webscript
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2011 10:59 AM
I am trying to create custom tag in my webscript description file the would represent an extension to the description URI.
I am using the example java code in the Alfresco Professional
Chapter 11; Creating a new Kind of Web Script
NodeWebScript.java and NodeWebScriptExtension.java
after deploying my java classes and the nodewebscript-context.xml below shown
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.org.example.nodewebscript"
class="org.example.NodeWebScript" parent="webscript" scope="prototype">
<property name="repository" ref="repositoryHelper"/>
</bean>
<bean id="webscriptdesc.org.example.nodewebscript"
class="org.example.NodeWebScriptExtension"/>
</beans>
Alfresco Application does not start but throws the following exception
Exception
15:01:18,661 ERROR [management.subsystems.ChildApplicationContextFactory$ChildApplicationContext] Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'googledocs': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:209)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:132)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:86)
at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:87)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
at org.springframewor
I dont seems to understand where this exception is coming from
I am using the example java code in the Alfresco Professional
Chapter 11; Creating a new Kind of Web Script
NodeWebScript.java and NodeWebScriptExtension.java
after deploying my java classes and the nodewebscript-context.xml below shown
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN' 'http://www.springframework.org/dtd/spring-beans-2.0.dtd'>
<beans>
<bean id="webscript.org.example.nodewebscript"
class="org.example.NodeWebScript" parent="webscript" scope="prototype">
<property name="repository" ref="repositoryHelper"/>
</bean>
<bean id="webscriptdesc.org.example.nodewebscript"
class="org.example.NodeWebScriptExtension"/>
</beans>
Alfresco Application does not start but throws the following exception
Exception
15:01:18,661 ERROR [management.subsystems.ChildApplicationContextFactory$ChildApplicationContext] Exception thrown from ApplicationListener handling ContextClosedEvent
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'googledocs': Singleton bean creation not allowed while the singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:209)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1008)
at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:132)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:86)
at org.alfresco.repo.management.SafeApplicationEventMulticaster.multicastEvent(SafeApplicationEventMulticaster.java:87)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:294)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:296)
at org.springframewor
I dont seems to understand where this exception is coming from
Labels:
- Labels:
-
Archive
4 REPLIES 4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2011 11:06 AM
You can probably ignore that error, since its due to a problem shutting down alfresco. The cause of Your problem is probably higher up.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2011 11:16 AM
I just took a closer look at all the Stack Trace and then i found this line which i think is the actual case of the problem am having
Am not having this exception at shutdown, am having it at launching the Alfresco Application
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'repository' of bean class [org.example.NodeWebScript]: Bean property 'repository' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1012)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:857)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
Am not having this exception at shutdown, am having it at launching the Alfresco Application
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'repository' of bean class [org.example.NodeWebScript]: Bean property 'repository' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1012)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:857)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:76)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2011 11:38 AM
O.K. That's a straightforward problem with your code, you need to make sure your class has a public setRepository method.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2011 11:47 AM
My code has a setRepository public method, the listing of my code is show below
package org.example;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.*;
//import org.alfresco.web.scripts.Cache;
//import org.alfresco.web.scripts.DeclarativeWebScript;
//import org.alfresco.web.scripts.Status;
//import org.alfresco.web.scripts.WebScriptException;
//import org.alfresco.web.scripts.WebScriptRequest;
public class NodeWebScript extends DeclarativeWebScript{
private Repository repository;
public void setRepository(Repository repository)
{
this.repository = repository;
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache)
{
// extract node path from description extensions
Map<String, Serializable> extensions =
getDescription().getExtensions();
String path = (String)extensions.get("path");
// search for folder within Alfresco content repository
String nodePath = "workspace/SpacesStore/" + path;
NodeRef node = repository.findNodeRef("path", nodePath.split("/"));
// validate that node has been found
if (node == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND,
"Path " + path + " not found");
}
// construct model for response template to render
Map<String, Object> model = new HashMap<String, Object>();
model.put("node", node);
return model;
}
}
what could be wrong with it
package org.example;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import org.alfresco.repo.model.Repository;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.webscripts.*;
//import org.alfresco.web.scripts.Cache;
//import org.alfresco.web.scripts.DeclarativeWebScript;
//import org.alfresco.web.scripts.Status;
//import org.alfresco.web.scripts.WebScriptException;
//import org.alfresco.web.scripts.WebScriptRequest;
public class NodeWebScript extends DeclarativeWebScript{
private Repository repository;
public void setRepository(Repository repository)
{
this.repository = repository;
}
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache)
{
// extract node path from description extensions
Map<String, Serializable> extensions =
getDescription().getExtensions();
String path = (String)extensions.get("path");
// search for folder within Alfresco content repository
String nodePath = "workspace/SpacesStore/" + path;
NodeRef node = repository.findNodeRef("path", nodePath.split("/"));
// validate that node has been found
if (node == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND,
"Path " + path + " not found");
}
// construct model for response template to render
Map<String, Object> model = new HashMap<String, Object>();
model.put("node", node);
return model;
}
}
what could be wrong with it
