javax.ws.rs.webapplicationexception http 400 bad request

Jboss or Wildfly

While working on deploying a web application on WildFly which implements rest services, we came across below issue of REST services not starting up and all the packaged modules in ear was not initializing and many places it was complaining about the missing dependants. So to avoid this issue of conflicts with Wildfly bundled apis we need to include jboss-deployment-structure.xml file to our applications war file.

jboss-deployment-structure.xml is a new JBoss specific optional deployment descriptor for JBoss EAP 6+. This deployment descriptor provides control over class loading in the deployment in a fine grained manner. A brief write up about the same can be found here in JBoss Deployment Structure File and Add dependency configuration to jboss-deployment-structure.xml links.

It should be placed in the top level deployment, in META-INF (or WEB-INF for web deployments). It can do the following:

– Prevent automatic dependencies from being added
– Add additional dependencies
– Define additional modules
– Change an EAR deployments isolated class loading behaviour
– Add additional resource roots to a module

Error Seen in Logs:

13:14:57,268 INFO  [jacorb.orb] (MSC service thread 1-2) Property "jacorb.hashtable_class" is set to: java.util.HashMap
13:15:26,379 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./devopsapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./devopsapp: Failed to start service
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_45]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_45]
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_45]
Caused by: javax.ws.rs.WebApplicationException: HTTP 400 Bad Request
        at com.devopsapp.controller.api.application.filters.ServiceController.onStartup(ServiceController.java:100)
        at org.glassfish.jersey.server.internal.ConfigHelper$2.onStartup(ConfigHelper.java:103)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:173)
        at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:363)
        at javax.servlet.GenericServlet.init(GenericServlet.java:244)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117)
        at org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:79)
        at io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103)
        at io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:220)
        at io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:125)
        at io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:508)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:88)
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
        ... 3 more

13:15:26,388 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "devopsapp.ear")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./devopsapp" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./devopsapp: Failed to start service
    Caused by: javax.ws.rs.WebApplicationException: HTTP 400 Bad Request"}}
13:15:26,431 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 30) JBAS018559: Deployed "devopsapp.ear" (runtime-name : "devopsapp.ear")
13:15:26,433 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014777:   Services which failed to start:      service jboss.undertow.deployment.default-server.default-host./devopsapp: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./devopsapp: Failed to start service

13:15:26,466 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management
13:15:26,467 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
13:15:26,467 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.2.0.Final "Tweek" started (with errors) in 50943ms - Started 620 of 695 services (3 services failed or missing dependencies, 131 services are lazy, passive or on-demand)
13:15:26,670 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010418: Stopped Driver service with driver-name = devopsapp.war_oracle.jdbc.OracleDriver_12c
13:15:26,674 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017535: Unregistered web context: /jspellhtml
13:15:26,674 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017535: Unregistered web context: /jspelliframe
13:15:26,726 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.1.3.Final
13:15:26,847 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-3) JBAS015974: Stopped subdeployment (runtime-name: devopshelper.war) in 182ms
13:15:26,854 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015974: Stopped subdeployment (runtime-name: devopsui.war) in 188ms
13:15:26,962 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015974: Stopped subdeployment (runtime-name: devopsapp.war) in 296ms
13:15:26,990 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015877: Stopped deployment devopsapp.ear (runtime-name: devopsapp.ear) in 325ms
13:15:27,062 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "devopsapp.ear" (runtime-name: "devopsapp.ear")
13:15:27,065 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.deployment.subunit."devopsapp.ear"."devopshelper.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."devopsapp.ear".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsui.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."devopsapp.ear".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."com.devopsapp.security.keymanagement.kma.bootstrap.KMAServletStarter".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."com.devopsapp.security.keymanagement.kmp.bootstrap.KMPServletStarter".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."com.devopsapp.controller.client.servlet.Dispatcher".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."com.devopsapp.controller.client.servlet.URLTransformationFilter".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.env.EnvironmentLoaderListener".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.servlet.ShiroFilter".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.AuthenticatedTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.GuestTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.HasAnyRolesTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.HasPermissionTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.HasRoleTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.LacksPermissionTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.LacksRoleTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.NotAuthenticatedTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.PrincipalTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.shiro.web.tags.UserTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.apache.velocity.tools.view.jsp.VelocityViewTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.glassfish.jersey.servlet.ServletContainer".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.context.ContextLoaderListener".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.BindErrorsTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.BindTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.EscapeBodyTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.EvalTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.HtmlEscapeTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.MessageTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.NestedPathTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.ParamTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.ThemeTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.TransformTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.UrlTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.ButtonTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.CheckboxTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.CheckboxesTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.ErrorsTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.FormTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.HiddenInputTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.InputTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.LabelTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.OptionTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.OptionsTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.PasswordInputTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.RadioButtonTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.RadioButtonsTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.SelectTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".component."org.springframework.web.servlet.tags.form.TextareaTag".START (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
      service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService (missing) dependents: [service jboss.deployment.unit."devopsapp.ear".deploymentCompleteService]
      service jboss.undertow.deployment.default-server.default-host./devopsapp (missing) dependents: [service jboss.deployment.subunit."devopsapp.ear"."devopsapp.war".deploymentCompleteService]
JBAS014777:   Services which failed to start:      service jboss.undertow.deployment.default-server.default-host./devopsapp

To avoid above issue and let only your applications API’s loaded to WildFly create a jboss-deployment-structure.xml file with below content and package it in your war file at Ear/War/WEB-INF/ folder and redeploy the app after clearing the WildFly tmp folder to make the changes take effect.

jboss-deployment-structure.xml file:

 

<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="resteasy" />
<subsystem name="jaxrs" />
<subsystem name="webservices" />
</exclude-subsystems>
<exclusions>
<module name="javaee.api" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
<module name="org.slf4j.ext" />
<module name="org.slf4j.jcl-over-slf4j" />
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
</exclusions>
<dependencies>
<module name="javax.activation.api" />
<module name="javax.annotation.api" />
<module name="javax.ejb.api" />
<module name="javax.el.api" />
<module name="javax.enterprise.api" />
<module name="javax.inject.api" />
<module name="javax.interceptor.api" />
<module name="javax.jms.api" />
<!--<module name="javax.jws.api"/>-->
<module name="javax.mail.api" />
<module name="javax.management.j2ee.api" />
<module name="javax.persistence.api" />
<module name="javax.resource.api" />
<module name="javax.rmi.api" />
<module name="javax.security.auth.message.api" />
<module name="javax.security.jacc.api" />
<module name="javax.servlet.api" />
<module name="javax.servlet.jsp.api" />
<module name="javax.transaction.api" />
<module name="javax.validation.api" />
<!--<module name="javax.ws.rs.api"/>-->
<module name="javax.xml.bind.api" />
<!--<module name="javax.xml.soap.api" />-->
<!--<module name="javax.xml.ws.api" />-->
<module name="javax.api" />
</dependencies>
</deployment>
</jboss-deployment-structure>

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.