Closed ghost closed 6 years ago
Hi @sredelin,
Would you be able to give a short reproducer? It might be related to which Vaadin annotations you're using, as I didn't find any problems with the following code:
@CDIUI("")
public class WelcomePage extends UI {
@Inject
private TestBean bean;
@Override
protected void init(VaadinRequest request) {
setSizeFull();
Label label = new Label(bean.getMessage());
setContent(new HorizontalLayout(label));
}
}
@RequestScoped
public class TestBean {
public String getMessage() {
return "Hello World! The time is: " + LocalTime.now().format(DateTimeFormatter.ISO_LOCAL_TIME).split("\\.")[0];
}
}
Kind regards,
Matt
actually the problem is not related to how you try to use the vaadin library. you can have an "empty" WAR file (or at least no class that has any Vaadin related code) and only include the vaadin-cdi dependency in your pom.xml, which transitively pulls in the two deltaspike jar files. this is already enough for the WAR file to be undeployable on Payara running inside Docker. It works fine OUTSIDE of a Docker container, but not inside one.
Please have a look again at the Jira ticket Sven provided in his original post, i added some information to that, outlining a workaround and some background.
The "TL;DR" is this: the deltaspike jars use the CDI 1.0 version of the beans.xml that does not explicitly specify the bean discovery mode, which SHOULD mean that discovery mode "all" is used, but instead it seems that Payara falls back to "annotated". This causes some beans in those jar files not to be discovered, because they dont have any CDI annotations and therefore cause an unresolved dependency exception during deployment.
It can be worked around by upgrading the beans.xml file to CDI 1.1+ spec and explicitly setting discovery mode to "all", then it will deploy correctly.
but the behaviour of Payara seems not to be in line with CDI spec in this case, because it should have worked with the original beans.xml file, too....and in fact, outside of a Docker container it DOES work and deploys fine in Payara!
To give you a starting point for debuggin this, include this in the pom.xml of your WAR project:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-cdi</artifactId>
<version>2.0.0</version>
</dependency>
and then try to deploy this in Payara running inside Docker. You don't need to have any code in your project that tries to use this dependency!
CDI 1.1 specifies annotated as the default bean discovery mode. Have you tried switching your application to have a bean discovery mode of all?
it's not the discovery mode of my application that is relevant here. the deltaspike JAR's (transitive dependency of vaadin) have their own beans.xml and they are still in CDI 1.0 format, which implies that they should be treated by Payara as using discovery mode "all" (for that one JAR) but they aren't, they are treated as is they use "annotated", but only if you are inside a docker container.
What docker image are you using? I don't see why docker would make any difference.
Hi @smillidge
CDI 1.1 specifies annotated as the default bean discovery mode.
but only if <beans version="1.1">
or higher is specified (or the respective xsd).
Without any version tag we are still in 1.0 compat mode so to say
An empty beans.xml file or a beans.xml with <beans/>
or <beans></beans>
still leads to 'all' mode as per CDI specs 1.1, 1.2 and even 2.0.
Otherwise the same JAR would behave totally different depending whether you run on an EE6, 7 or 8 container. Which is not what we want, right?
true but this deploys outside of a docker container correctly but not in one which is weird.
Can you provide a test case please if this is still an issue?
Closing due to inactivity
Dear guys, We had some strange issues depending on payaramicro 4.1.2.172 with dependency injection. Basically I solved the first issues of this error in local application by adding annotation of beans which would be injected. But then I got the same problem with a dependency of our application.
Vaadin-cdi-2.0.0 has a dependency to apache/deltaspike, which has the same injection problem. I requested a fix for deltaspike with https://issues.apache.org/jira/browse/DELTASPIKE-1285
Now we changed our upcoming development to use some microservices from vaadin application and used eureka-client-1.8.0 to discover the microservice instances. Unfortunatelly eureka-client-1.8.0 has the problem with dependency injection...
Disableing cdi scanning for these dependencies is not really an option, because then deployment fails due to missing injected beans sometimes.
Expected Outcome
Deployment of API successfull without exceptions.
Current Outcome
We are deploying a vaadin application inside a war-file by using payara-micro-4.1.2.172. The dependencies of the gradle build project are the following.
Steps to reproduce (Only for bug reports)
If necessary I can produce an example application to deploy, which will have the same error. If necessary please contact me. I cannot add the 120mb application of our company here. We deploy with the following call.
java -jar /payara-micro.jar --logProperties /logging.properties --domainConfig /servicedata/domain.xml --deploy /app.war
Environment