-
1. Re: How to deploy angular and spring boot app in same ear in JBoss
zhurlik Sep 27, 2019 9:49 AM (in response to lmachado)Hi,
Does it mean that you would like to make a spring context to be shared between web applications?
Thanks,
Vlad
-
2. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Sep 27, 2019 12:58 PM (in response to zhurlik)No. It's the opposite. I would like my angular app to be made available as a static web application, with no web or spring initializer. The other two war apps are deployed correctly.
As an additional comment I tried to exclude the weld subsystem for my angular app and I got another error:
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<sub-deployment name="my-angular-web-app.war">
<exclude-subsystems>
<subsystem name="weld" />
</exclude-subsystems>
</sub-deployment>
</jboss-deployment-structure>
Error (it does not call WebInitilizer, but I get the following):
10:17:16,872 ERROR [org.jboss.as.controller.management-operation] (External Management Request Threads -- 1) WFLYCTL0013: Operation ("add") failed - address: ([("deployment" => "my-bundle.ear")]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"my-bundle.ear\".\"my-angular-web-app.war\".beanmanager"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"my-bundle.ear\".\"my-angular-web-app.war\".batch.artifact.factory is missing [jboss.deployment.subunit.\"my-bundle.ear\".\"my-angular-web-app.war\".beanmanager]"]
}
-
3. Re: How to deploy angular and spring boot app in same ear in JBoss
zhurlik Sep 30, 2019 5:19 AM (in response to lmachado)Hi,
Could you share youк folder structure in the ear file and all xmls under META-INF and WEB-INF folders?
Thanks,
Vlad
-
4. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Oct 3, 2019 12:56 PM (in response to zhurlik)Hi, Vlad,
The ear file structure is:
.
├── angular-client-app.war
├── lib
│ ├── antlr-2.7.7.redhat-4.jar
│ ├── aspectjrt-1.9.3.jar
│ ├── byte-buddy-1.8.17.jar
│ ├── cache-api-1.1.1.jar
│ ├── classmate-1.3.4.jar
│ ├── datasource-proxy-1.5.1.jar
│ ├── dom4j-2.1.1.jar
│ ├── hibernate-commons-annotations-5.0.1.Final-redhat-2.jar
│ ├── hibernate-core-5.3.7.Final.jar
│ ├── hibernate-entitymanager-5.3.7.Final.jar
│ ├── jackson-annotations-2.9.0.jar
│ ├── jackson-core-2.9.8.jar
│ ├── jackson-databind-2.9.6.jar
│ ├── jackson-datatype-jsr310-2.9.8.jar
│ ├── jandex-1.2.2.Final-redhat-1.jar
│ ├── javassist-3.18.1.GA-redhat-1.jar
│ ├── javax.activation-api-1.2.0.jar
│ ├── javax.annotation-api-1.3.2.jar
│ ├── javax.persistence-api-2.2.jar
│ ├── jboss-logging-3.1.4.GA-redhat-2.jar
│ ├── jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-2.jar
│ ├── jboss-transaction-api_1.2_spec-1.0.1.Final-redhat-1.jar
│ ├── jjwt-api-0.10.5.jar
│ ├── jjwt-impl-0.10.5.jar
│ ├── jjwt-jackson-0.10.5.jar
│ ├── jul-to-slf4j-1.7.25.jar
│ ├── log4j-1.2.9.jar
│ ├── log4j-api-2.11.1.jar
│ ├── log4j-to-slf4j-2.11.1.jar
│ ├── logback-classic-1.2.3.jar
│ ├── logback-core-1.2.3.jar
│ ├── reactive-streams-1.0.2.jar
│ ├── security-annotation-aspectj-4.10.3.jar
│ ├── security-api-4.10.3.jar
│ ├── security-command-4.10.3.jar
│ ├── security-configuration-4.10.3.jar
│ ├── security-consume-api-4.10.3.jar
│ ├── security-consume-soap-4.10.3.jar
│ ├── security-context-api-4.10.3.jar
│ ├── security-context-spring-4.10.3.jar
│ ├── security-core-4.10.3.jar
│ ├── security-exception-4.10.3.jar
│ ├── security-extension-web-4.10.3.jar
│ ├── security-model-4.10.3.jar
│ ├── security-utility-4.10.3.jar
│ ├── slf4j-api-1.7.2.redhat-3.jar
│ ├── snakeyaml-1.8.0.redhat-3.jar
│ ├── spring-aop-5.1.2.RELEASE.jar
│ ├── spring-beans-5.1.2.RELEASE.jar
│ ├── spring-boot-2.1.1.RELEASE.jar
│ ├── spring-boot-autoconfigure-2.1.1.RELEASE.jar
│ ├── spring-boot-starter-2.1.1.RELEASE.jar
│ ├── spring-boot-starter-cache-2.1.1.RELEASE.jar
│ ├── spring-boot-starter-logging-2.1.1.RELEASE.jar
│ ├── spring-boot-starter-security-2.1.1.RELEASE.jar
│ ├── spring-context-5.1.2.RELEASE.jar
│ ├── spring-context-support-5.1.2.RELEASE.jar
│ ├── spring-core-5.1.2.RELEASE.jar
│ ├── spring-data-commons-2.1.8.RELEASE.jar
│ ├── spring-data-jpa-2.1.8.RELEASE.jar
│ ├── spring-expression-5.1.2.RELEASE.jar
│ ├── spring-jcl-5.1.2.RELEASE.jar
│ ├── spring-jdbc-5.1.2.RELEASE.jar
│ ├── spring-orm-5.1.2.RELEASE.jar
│ ├── spring-security-config-5.1.2.RELEASE.jar
│ ├── spring-security-core-5.1.2.RELEASE.jar
│ ├── spring-security-web-5.1.2.RELEASE.jar
│ ├── spring-tx-5.1.2.RELEASE.jar
│ ├── spring-web-5.1.2.RELEASE.jar
│ └── spring-webmvc-5.1.2.RELEASE.jar
├── META-INF
│ ├── application.xml
│ └── MANIFEST.MF
├── spring-app1.war
└── spring-boot-app2.war
And the xmls:
application.xml:
- - - cut here - - -
<?xml version="1.0"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="6">
<display-name>app-release</display-name>
<module>
<web>
<web-uri>spring-app1.war</web-uri>
<context-root>spring-app1</context-root>
</web>
</module>
<module>
<web>
<web-uri>spring-boot-app2.war</web-uri>
<context-root>spring-boot-app2</context-root>
</web>
</module>
<module>
<web>
<web-uri>angular-client-app.war</web-uri>
<context-root>angular-client-app</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>
- - - cut here - - -
beans.xml for spring-boot-app2 (necessary for other reasons):
- - - cut here - - -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" bean-discovery-mode="annotated">
<scan>
<exclude name="org.apache.cxf.transport.http.Servlet3ContinuationProvider" />
<exclude name="org.springframework.http.server.ServletServerHttpAsyncRequestControl" />
<exclude name="org.springframework.web.context.request.async.StandardServletAsyncWebRequest" />
</scan>
</beans>
- - - cut here - - -
There is an orm.xml for spring-app1 (in WEB-INF/classes/META-INF), but that's for database purposes and I didn't include it here. No other xmls exist.
Thanks for your reply.
Regards.
Leonardo
-
5. Re: How to deploy angular and spring boot app in same ear in JBoss
zhurlik Oct 4, 2019 4:25 AM (in response to lmachado)Hi,
Could you add more xml files under WEB-INF from your *.war, that's needed to be able to understand dependencies between ear/lib/wars.
Do you have jboss-deployment-structure.xml?Thanks,
Vlad
-
6. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Oct 4, 2019 7:13 AM (in response to zhurlik)Hi, Vlad,
Thanks again for your interest and help.
As I said, there are no other xml files under WEB-INF. Those are spring apps that are automatically initialized with ApplicationInitializers.
Regards.
Leonardo
-
7. Re: How to deploy angular and spring boot app in same ear in JBoss
zhurlik Oct 4, 2019 7:37 AM (in response to lmachado)Hi,
Hmm... In that case I guess you need to move your spring-*.jar file from /lib into either separated jboss modules or at least try to put them under each war where you need to up spring context.
I would like to suggest to look at Class Loading in WildFly - WildFly 10 - Project Documentation Editor
To understand how Class loading works under JBoss/Wildfly and how you can manage dependencies using jdoss-deployments-structure.xml
Thanks,
Vlad
-
8. Re: How to deploy angular and spring boot app in same ear in JBoss
ctomc Oct 4, 2019 9:43 AM (in response to lmachado)Does your angular war deploy on its own?
aka if you deploy it as standalone war, and not as part of ear.
If that works, there could be some too eager spring init scanning, which can configured.
-
9. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Oct 4, 2019 10:41 AM (in response to zhurlik)Hi, Vlad,
I want to keep my war files as small as possible. If I place spring*.jar and other common jars in them them, I won't have that. Today there are few apps and little libraries overlap, but in the future this can be a big problem. In order for you to have an idea, by keeping the wars as thin as possible, I was able to more than half the ear final size.
Can I have a separate module that are libraries (set of jars) in an ear (without placing them in lib directpry) and explicitly say that some war modules use it? AFAIK, a module can be a war, jar ou rar, but not a set of jars.
Thanks again and regards.
Leonardo
-
10. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Oct 4, 2019 11:12 AM (in response to ctomc)Hi,
Yes the angular war deploys if outside the ear. That's actually how I am doing right now: one war with angular app and an ear with both server side spring wars.
I wish I could tell spring not to load that specific war as a spring app.
Thanks and regards.
Leonardo
-
11. Re: How to deploy angular and spring boot app in same ear in JBoss
zhurlik Oct 5, 2019 3:30 PM (in response to lmachado)Hi,
Once again, I suggest that you design your libraries (jars under lib) as JBoss modules. After that, you will not need to put them into ear/war files.
You will be able to use them as dependencies.For example I am using this gradle plugin for building modules GitHub - zhurlik/gradle-jboss-modules-plugin: This is a plugin for gradle allows to create modules for JBoss/Wildfly ser…
The main idea is to have a separated modules for all jars to be able to use its references in the dependencies.
Wildfly uses this approach and consists of modules.
Thanks,
Vlad
-
12. Re: How to deploy angular and spring boot app in same ear in JBoss
ctomc Oct 7, 2019 4:35 AM (in response to lmachado)What happens if you add WEB-INF/web.xml to your angular war app that contains directive metadata-complete=true
example of such web.xml would be
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
</web-app> -
13. Re: How to deploy angular and spring boot app in same ear in JBoss
lmachado Oct 8, 2019 12:51 PM (in response to ctomc)Hi, Tomaz,
When I try the following web.xml in WEB-INF for the angular client war:
- - - cut here - - -
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0"
metadata-complete="true">
</web-app>
- - - cut here - - -
I get the following error trying to access the url in the browser (deploy is ok):
- - - cut here - - -
java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction$$Lambda$796/1862671731.call(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction$$Lambda$797/1477071607.call(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction$$Lambda$797/1477071607.call(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction$$Lambda$797/1477071607.call(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction$$Lambda$797/1477071607.call(Unknown Source)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction$$Lambda$797/1477071607.call(Unknown Source)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)
at java.lang.Thread.run(Thread.java:745)
- - - cut here - - -
Thanks