Senin, 03 Desember 2012

JNDI look-up JBOSS 7

I used to access JNDI lookup for datasource in JBOSS AS 5 as well as JBOSS AS 6 by using this way:

Unfortunately, it seems doesn't work in AS 7, as it produces error:
javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.omega.war:main" from Service Module Loader

Thanks to this link, the solution is quite simple, only put the INITIAL_CONTEXT_FACTORY to org.jboss.as.naming.InitialContextFactory.

One additional note, put the JNDI name with prefix java:/ or java:jboss/.

Minggu, 04 November 2012

HHH000196

While  starting seam 2.3 application on jboss server, I found an ERROR:

11:01:37,629 ERROR [org.hibernate.internal.util.xml.ErrorLogger] (MSC service thread 1-4) HHH000196: Error parsing XML (6) : cvc-complex-type.3.1: Value '1.0' of attribute 'version' of element 'entity-mappings' is not valid with respect to the corresponding attribute use. Attribute 'version' has a fixed value of '2.0'.

The root cause of these error is the wrong version of orm.xml. On my project it used the version 1.0, while as my entity manager using JPA 2.0

<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_1_0.xsd"
version="1.0">
Replace with
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence/orm
http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0"> 

Jumat, 02 November 2012

JBAS015052

I was deploying my ear applications into jboss-as-7.1.1-Final on standalone server and got some errors on deployment.

ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015052: Did not receive a response to the deployment operation within the allowed timeout period [60 seconds]. Check the server configuration file and the server logs to find more about the status of the deployment.

The resolution is quite easy:
  1. Goto $JBOSS_HOME/standalone/configuration/
  2. Open standalone.xml then find node
    <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
       <deployment-scanner path="deployments"
          relative-to="jboss.server.base.dir"
          scan-interval="5000" />
    </subsystem>
  3. Add attribute deployment-timeout, the value is in seconds. I chose the deployment time-out after 20 minutes. So the scanner node looks like:
    <subsystem xmlns="urn:jboss:domain:deployment-scanner:1.1">
         <deployment-scanner path="deployments" relative-to="jboss.server.base.dir"
          scan-interval="5000" deployment-timeout="1200"/>
    </subsystem>

Reference: https://docs.jboss.org/author/display/AS7/Deployment+Scanner+configuration