nflow icon indicating copy to clipboard operation
nflow copied to clipboard

Q: Starting nFlow JAX-RS inside Quarkus throws

Open nikos opened this issue 3 years ago • 2 comments

Since I interpreted the Getting Started guide, that you should be able to start nFlow REST API also in a non-Spring (but JEE) environment, I thought it should be possible to embed it into Quarkus (quarkus.io) adding to a bare minimum Quarkus app simply pom.xml:

    <dependency>
        <groupId>io.nflow</groupId>
        <artifactId>nflow-engine</artifactId>
        <version>${nflow.version}</version>
    </dependency>

I added two lines in application.properties to allow CDI to discover the JAX-RS beans

quarkus.index-dependency.nflow.group-id=io.nflow
quarkus.index-dependency.nflow.artifact-id=nflow-rest-api-jax-rs

But unfortunately that seemed not to be sufficient, still some beans can not be wired, on Quarkus (dev) startup the following dependencies are claimed:

ERROR [io.qua.dep.dev.IsolatedDevModeMain] (main) Failed to start quarkus: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: Found 15 deployment problems: 
[1] Unsatisfied dependency for type org.springframework.core.env.Environment and qualifiers [@Default]
	- java member: io.nflow.rest.config.jaxrs.CorsHeaderContainerResponseFilter#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.config.jaxrs.CorsHeaderContainerResponseFilter], qualifiers=[@Default, @Any], target=io.nflow.rest.config.jaxrs.CorsHeaderContainerResponseFilter]
[2] Unsatisfied dependency for type io.nflow.rest.v1.converter.StatisticsConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.StatisticsResource#statisticsConverter
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.StatisticsResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.StatisticsResource]
[3] Unsatisfied dependency for type io.nflow.engine.service.StatisticsService and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.StatisticsResource#statisticsService
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.StatisticsResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.StatisticsResource]
[4] Unsatisfied dependency for type io.nflow.engine.service.WorkflowInstanceService and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowInstanceResource#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.WorkflowInstanceResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowInstanceResource]
[5] Unsatisfied dependency for type io.nflow.rest.v1.converter.CreateWorkflowConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowInstanceResource#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.WorkflowInstanceResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowInstanceResource]
[6] Unsatisfied dependency for type io.nflow.rest.v1.converter.ListWorkflowInstanceConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowInstanceResource#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.WorkflowInstanceResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowInstanceResource]
[7] Unsatisfied dependency for type io.nflow.engine.workflow.instance.WorkflowInstanceFactory and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowInstanceResource#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.WorkflowInstanceResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowInstanceResource]
[8] Unsatisfied dependency for type io.nflow.engine.internal.dao.WorkflowInstanceDao and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowInstanceResource#<init>()
	- declared on CLASS bean [types=[java.lang.Object, io.nflow.rest.v1.jaxrs.WorkflowInstanceResource], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowInstanceResource]
[9] Unsatisfied dependency for type io.nflow.rest.v1.converter.MaintenanceConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.MaintenanceResource#converter
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.MaintenanceResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.MaintenanceResource]
[10] Unsatisfied dependency for type io.nflow.engine.service.MaintenanceService and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.MaintenanceResource#maintenanceService
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.MaintenanceResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.MaintenanceResource]
[11] Unsatisfied dependency for type io.nflow.engine.service.WorkflowExecutorService and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowExecutorResource#<init>()
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.WorkflowExecutorResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowExecutorResource]
[12] Unsatisfied dependency for type io.nflow.rest.v1.converter.ListWorkflowExecutorConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowExecutorResource#<init>()
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.WorkflowExecutorResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowExecutorResource]
[13] Unsatisfied dependency for type io.nflow.engine.service.WorkflowDefinitionService and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource#<init>()
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource]
[14] Unsatisfied dependency for type io.nflow.rest.v1.converter.ListWorkflowDefinitionConverter and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource#<init>()
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource]
[15] Unsatisfied dependency for type io.nflow.engine.internal.dao.WorkflowDefinitionDao and qualifiers [@Default]
	- java member: io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource#<init>()
	- declared on CLASS bean [types=[io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource, java.lang.Object], qualifiers=[@Default, @Any], target=io.nflow.rest.v1.jaxrs.WorkflowDefinitionResource]

nikos avatar Jan 29 '21 13:01 nikos

Seems like some of the beans (like converters) are annotated with org.springframework.stereotype.Component which does not make CDI happy, resp. refer to spring core: org.springframework.core.env.Environment

So what would be your recommendation to make use of nFlow inside an Quarkus application? Concentrate on leveraging the core engine functionality probably?

nikos avatar Jan 29 '21 13:01 nikos

nFlow does not currently support CDI. Getting started guide is a maybe a bit outdated and misleading here - the "non-Spring" option means you don't need to learn Spring to use nFlow - internally nFlow still uses Spring.

However, there is an option to use Guice DI instead of Spring DI, so I don't see why it would not be possible to support CDI as well. It probably requires some additional annotations here and there etc., but if you're already familiar with CDI, it should not be too difficult. Could you consider making a PR for CDI support?

efonsell avatar Feb 14 '21 19:02 efonsell