Out-of-process extension NodesApi bean not found

cancel
Showing results for 
Search instead for 
Did you mean: 
malekgn
Active Member II

Out-of-process extension NodesApi bean not found

Hello,

I created a spring boot application to create an out-of-process application using rest api.
But it failed to run because the missing of the bean NodesApi by displaying the following error message.

Consider defining a bean of type 'org.alfresco.core.handler.NodesApi' in your configuration.

I followed the documentation https://docs.alfresco.com/content-services/latest/develop/oop-ext-points/rest-api-java-wrapper/#list...

initialized the NodesApi with the @Autowired Spring annotation and here is my code :

package com.arondor.alfrescooutofprocessrestapi;

import org.alfresco.core.handler.NodesApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AlfrescoOutOfProcessRestapiApplication implements CommandLineRunner
{

    public static void main(String[] args)
    {
        SpringApplication.run(AlfrescoOutOfProcessRestapiApplication.class, args);
    }

    @Autowired
    NodesApi nodesApi;

    @Override
    public void run(String... args) throws Exception
    {
        // Some code here.
    }

}

And here are the dependencies in my pom.xml file.

<properties>
		<java.version>17</java.version>
		<alfresco.api.version>5.2.2</alfresco.api.version>
	</properties>

	<repositories>
		<repository>
			<id>alfresco-public</id>
			<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
		</repository>
	</repositories>

	<dependencies>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-acs-java-rest-api-spring-boot-starter -->
		<dependency>
			<groupId>org.alfresco</groupId>
			<artifactId>alfresco-acs-java-rest-api-spring-boot-starter</artifactId>
			<version>${alfresco.api.version}</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-apa-java-rest-api-spring-boot-starter -->
		<dependency>
			<groupId>org.alfresco</groupId>
			<artifactId>alfresco-apa-java-rest-api-spring-boot-starter</artifactId>
			<version>${alfresco.api.version}</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-java-event-api-spring-boot-starter -->
		<dependency>
			<groupId>org.alfresco</groupId>
			<artifactId>alfresco-java-event-api-spring-boot-starter</artifactId>
			<version>${alfresco.api.version}</version>
		</dependency>
	</dependencies>



Best regards.

 

3 Replies
angelborroy
Alfresco Employee

Re: Out-of-process extension NodesApi bean not found

You may try adding configuration with @EnableAutoConfiguration, like in this sample:

https://github.com/aborroy/alfresco-outlook-attachments-oop/blob/main/src/main/java/org/alfresco/sdk...

Hyland Developer Evangelist
ftarantino
Active Member

Re: Out-of-process extension NodesApi bean not found

Hi Angel,

@EnableAutoConfiguration is implicit in @SpringBootApplication annotation.

I have the same problem. Step to reproduce:

- start.spring.io with java 17 and spring boot 3.1.1 (last stable version of 3.1)
- add java sdk maven repo and dependency

org.alfresco:alfresco-acs-java-rest-api-spring-boot-starter:5.2.2

- create a Test Controller (empty if you want...) and add NodesApi with @Autowired annotation

Error:
Field nodesApi in it.reindex.ms.test.controller.TestApi required a bean of type 'org.alfresco.core.handler.NodesApi' that could not be found.
Consider defining a bean of type 'org.alfresco.core.handler.NodesApi' in your configuration.

 

With previous java sdk version it works.

ftarantino
Active Member

Re: Out-of-process extension NodesApi bean not found

After a deep investigation, I found that alfresco-java-sdk 5.2.2 (last stable release) doesn't work with spring boot 3.1.x

Compiling alfresco-java-sdk 6.0.0-SNAPSHOT from github (it's not uploaded on maven repo), works fine with spring boot 3.1.x

The README file should be updated in alfresco-java-sdk project. I think that a compatibility matrix could be improve understanding

Federico