hello.
I try to create additional module for Alfresco.
I created project All-in-One by instruction https://github.com/Alfresco/alfresco-sdk/blob/master/docs/getting-started.md
SDK 4.0, Alfresco 6.1
in class DemoComponent
import org.alfresco.repo.nodelocator.NodeLocatorService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
private NodeService nodeService;
private NodeLocatorService nodeLocatorService;
public NodeRef getCompanyHome(){
return nodeLocatorService.getNode("companyhome", null, null);
}
<bean id="testpackage.DemoComponent" class="testpackage.platformsample.DemoComponent" parent="module.baseComponent" >
<property name="moduleId" value="testartifact-platform" /> <!-- See module.properties -->
<property name="name" value="DemoComponent" />
<property name="description" value="A demonstration component" />
<property name="sinceVersion" value="2.0" />
<property name="appliesFromVersion" value="2.0" /> <!-- 1.0 would not work here when using SNAPSHOT version in project -->
<property name="nodeService" ref="nodeService" />
<property name="nodeLocatorService" ref="nodeLocatorService" />
</bean>
I run project (./run.sh build_start), but line getCompanyHome() take me error
java.lang.NullPointerException
at testpackage.platformsample.DemoComponent.getCompanyHome(DemoComponent.java:93)
at testpackage.platformsample.DemoComponent.executeInternal(DemoComponent.java:61)
at testpackage.platformsample.HelloWorldWebScript.executeImpl(HelloWorldWebScript.java:129)
at testpackage.platformsample.HelloWorldWebScriptControllerTest.testController(HelloWorldWebScriptControllerTest.java:47)
How can I get nodeService, nodeLocatorService?
Maybe anybody link me to example project, please.
I would be very grateful for the information. Thanks to all.
Tetyana
Do you have a setter service for NodeService and NodeServiceLocator beans in your Java class?
only this
in DemoComponent:
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
public void setNodeLocatorService(NodeLocatorService nodeLocatorService) {
this.nodeLocatorService = nodeLocatorService;
}
Remember to write the setter method
public void setNodeService(NodeService nodeService) { this.nodeService = nodeService; }
... for each Spring injected field.
If the method is missing you will get null exception!
Ok I saw now that methods are there.
Maybe the problem is the property injection on xml.
The correct way is
<property name="nodeService" ref="NodeService" />
Note the initial uppercase on ref attribute.
it`s not solution
Is it possible for you to share the project you have created using SDK4.x? You can zip it and attach here.
The project is on GitHub
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.