2012. november 16., péntek

JBoss AS7 JNDI and Migration from AS6

When you migrate an application from JBoss AS6 to AS7, probably you will encounter a lot of exceptions if you do not read the AS7 migration guide beforehand. :) This is also the case when naming your objects in JNDI, so if you use JNDI lookups, @Resource annotations, ejb-jar.xml or web.xml resource references etc., then make sure to read the AS7 JNDI Reference first. Also please note that in files like web.xml and ejb-jar.xml, the jndi-name element in the resource-ref seems to be mandatory, contrary to AS6 or other application servers.

    My JMS Connection Factory
    jms/MyConnectionFactory
    java:/jms/MyConnectionFactory
    javax.jms.ConnectionFactory
    Container

Keeping things like this in mind can drastically reduce the time spent on investigating deployment errors like the one below:
Unknown error

Unexpected HTTP response: 500

Request
{
    "address" => [("deployment" => "MyApp.war")],
    "operation" => "deploy"
}

Response

Internal Server Error
{
    "outcome" => "failed",
    "failure-description" => {"JBAS014771: Services with missing/unavailable dependencies" => [
        "jboss.deployment.unit.\"MyApp.war\".component.\"javax.faces.webapp.FacesServlet\".START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".jboss.security.jacc Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.MySessionBean1.START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.\"javax.servlet.jsp.jstl.tlv.ScriptFreeTLV\".START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.\"org.apache.catalina.servlets.DefaultServlet\".START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".jndiDependencyService Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.MySessionBean2.START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.\"org.apache.jasper.servlet.JspServlet\".START Missing[JBAS014861: ]",
        "jboss.naming.context.java.module.\"MyApp\".\"MyApp\".env.jms.MyConnectionFactory Missing[jboss.naming.context.java.jboss.resources.jms.MyConnectionFactory]",
        "jboss.web.deployment.default-host./myapp Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.\"org.jboss.as.weld.webtier.jsp.JspInitializationListener\".START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.MySessionBean3.START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.\"javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV\".START Missing[JBAS014861: ]",
        "jboss.deployment.unit.\"MyApp.war\".component.MySessionBean4.START Missing[JBAS014861: ]"
    ]},
    "rolled-back" => true
}
In this example, JBoss complains about every possible component of the web application, so it's kind of difficult to spot the real (and only) error in the deployment:
...
"jboss.naming.context.java.module.\"MyApp\".\"MyApp\".env.jms.MyConnectionFactory Missing[jboss.naming.context.java.jboss.resources.jms.MyConnectionFactory]",
        "jboss.web.deployment.default-host./myapp Missing[JBAS014861: ]",
...
The error was caused by the previously missing jndi-name element which was not needed when deploying the same application to AS6:
...
    java:/jms/MyConnectionFactory
...
After adding the JNDI name to the configuration, the deployment worked fine on AS7.
Note taken.

Nincsenek megjegyzések:

Megjegyzés küldése