venerdì 28 ottobre 2011

Jboss 4.0.5 problemi nel deploy EJB

Mi è capitato di incappare in un curioso problema, praticamente lanciando da Eclipse una workspace preesistente cou un Ear project da deployare su Jboss, avevo un errore di questo tipo:


org.jboss.deployment.DeploymentInfo@d6781bc5 {
url=file:/C:xxx.ear}
deployer: null
status: null
state: INIT_WAITING_DEPLOYER
watch: file:/C:xxx.ear
lastDeployed: 1103151946718
lastModified: 1103151948000
mbeans:

Dopo un pò di panico (era una vecchia applicazione che risiedeva su una macchina virtuale spenta da tempo).
ho trovato il problema: nella cartella default/deploy per motivi a me ignoti era stato cancellato il file ear-deployer.xml, un file di 1KB del quale ignoravo addirittura l'esistenza (ignoranza mia).
Praticamente me ne sono accorto soltanto una volta scaricata la nuova versione di Jboss e facendo una diff tra i file presenti (una domanda, perchè se c'è una cartella conf non si mettono lì tutti i file di configurazione????) ho notato la mancanza di questo file, che si presenta così:

<?xml version="1.0" encoding="UTF-8"?>

<!-- The JBoss service configuration file for the EAR deployer service.
$Id: ear-deployer.xml 23463 2004-09-05 15:50:37Z starksm $
-->
<server>
   <!-- EAR deployer, remove if you are not using ear deployments -->
   <mbean code="org.jboss.deployment.EARDeployer"
      name="jboss.j2ee:service=EARDeployer">
      <!-- A flag indicating if ear deployments should have their own scoped
      class loader to isolate their classes from other deployments.
      -->
      <attribute name="Isolated">false</attribute>
      <!-- A flag indicating if the ear components should have in VM call
      optimization disabled.
      -->
      <attribute name="CallByValue">false</attribute>
   </mbean>
</server>


Note sugli attributi:
ISOLATED se true fa in modo che tutti gli ear presenti abbiano un diverso classloader.
CALLBYVALUE se true disabilita l'impostazione del call by reference degli Ejb, praticamente mettendolo a true ogni chiamata ad un Ejb viene serializzata.

Questo è quello che ho trovato in merito sul sito di una community JBOSS( qui ):

The use of call by value and marshalling is very inefficient. It typically means
method invocations take 10 times the cpu. Why? Compare Call By Value with Call By Reference

Call By Reference

  1. caller does ejb.someMethod()
  2. invocation is passed through ejb container
  3. container does bean.someMethod()
  4. result is returned to the caller

Call By Value

  1. caller does ejb.someMethod()
  2. invocation is marshalled - the parameters are turned into ObjectStream (a byte[])
  3. container with a different classloader unmarshalls - byte[] -> java Objects - including classloading
  4. invocation is passed through ejb container
  5. container does bean.someMethod()
  6. result is marshalled - the return value is turned into ObjectStream
  7. result is unmarshalled using the caller's classloader - byte[] -> java Object
  8. result is return to the caller

The marshalling and unmarshalling uses a lot of cpu.

Con JBOSS 5 l'ear-deployer ha cambiato nome, si trova nella cartella defalut/deployers e si chiama ear-deployer-jboss-beans.xml,.
 

Nessun commento:

Posta un commento