Hi all:

Trying to deploy a bean without (and even with) jboss.xml in
jBoss 2 is hard, you get a lot of NullPointerExceptions. I
have been looking in the code this morning and after a few
changes I have been able to deploy my beans.

Here are the diffs

File AutoDeployer.java
-------------------------------------------------------------
diff -r1.1.1.1 AutoDeployer.java
21d20
< import org.jboss.cluster.*;
-------------------------------------------------------------
This import has to be removed.

File Container.java
-------------------------------------------------------------
diff -r1.3 Container.java
365,372c365,374
<             if (rm.getType().equals("javax.sql.DataSource"))
<             {
<                JDBCResource res = (JDBCResource)rm;
<                bind(ctx, res.getName(), new 
LinkRef(res.getJndiName()));
<             } else if (rm.getType().equals("java.net.URL"))
<             {
<                try
<                {
---
>             if (rm != null)
>               if (rm.getType().equals("javax.sql.DataSource"))
>               {
>                 JDBCResource res = (JDBCResource)rm;
>                 bind(ctx, res.getName(), new 
LinkRef(res.getJndiName()));
>               } 
>               else if (rm.getType().equals("java.net.URL"))
>               {
>                 try
>                 {
375,379c377,381
<                } catch (MalformedURLException e)
<                {
<                   throw new NamingException("Malformed 
URL:"+e.getMessage());
<                }
<             }
---
>                  } catch (MalformedURLException e)
>                  {
>                    throw new NamingException("Malformed 
URL:"+e.getMessage());
>                  }  
>               }
-------------------------------------------------------------
Sorry, I have been moving the indentation of lines and this
diff is very large. Just added the line ("if (rm != null)").

File ContainerFactory.java
-------------------------------------------------------------
diff -r1.2 ContainerFactory.java
161,162c161,169
<                   
con.setContainerInvoker((ContainerInvoker)cl.loadClass(conf.getContainer
Invoker()).newInstance());
<                   
con.setInstancePool((InstancePool)cl.loadClass(conf.getInstancePool()).n
ewInstance());
---
>                   if (conf != null) {
>                     
con.setContainerInvoker((ContainerInvoker)cl.loadClass(conf.getContainer
Invoker()).newInstance());
>                     
con.setInstancePool((InstancePool)cl.loadClass(conf.getInstancePool()).n
ewInstance());
>                   }
>                   else {
>                     con.setContainerInvoker(new 
org.jboss.ejb.plugins.jrmp13.server.JRMPContainerInvoker());
>                     con.setInstancePool(new 
org.jboss.ejb.plugins.StatelessSessionInstancePool());
>                   }
>                   
185,188c192,207
<                   
con.setContainerInvoker((ContainerInvoker)cl.loadClass(conf.getContainer
Invoker()).newInstance());
<                   
((EntityContainer)con).setInstanceCache((InstanceCache)cl.loadClass(conf
.getInstanceCache()).newInstance());
<                   
con.setInstancePool((InstancePool)cl.loadClass(conf.getInstancePool()).n
ewInstance());
<                   
((EntityContainer)con).setPersistenceManager((EntityPersistenceManager)c
l.loadClass(conf.getPersistenceManager()).newInstance());
---
>                   if (conf != null) {
>                     // If exists information (jBoss.xml)
>                     
con.setContainerInvoker((ContainerInvoker)cl.loadClass(conf.getContainer
Invoker()).newInstance());
>                     ((EntityContainer) 
con).setInstanceCache((InstanceCache)cl.loadClass(conf.getInstanceCache(
)).newInstance());
>                     
con.setInstancePool((InstancePool)cl.loadClass(conf.getInstancePool()).n
ewInstance());
>                     ((EntityContainer) 
con).setPersistenceManager((EntityPersistenceManager)cl.loadClass(conf.g
etPersistenceManager()).newInstance());
>                   }
>                   else {
>                     // Default values for container configuration (JDK 
1.3)
>                     con.setContainerInvoker(new 
org.jboss.ejb.plugins.jrmp13.server.JRMPContainerInvoker());
>                     ((EntityContainer) con).setInstanceCache(new 
org.jboss.ejb.plugins.NoPassivationEntityInstanceCache());
>                     con.setInstancePool(new 
org.jboss.ejb.plugins.EntityInstancePool());
>                     
>                     // Rickard, I don't know where is the information 
if the entity is BMP or CMP
>                     ((EntityContainer) con).setPersistenceManager(new 
org.jboss.ejb.plugins.BMPPersistenceManager());
>                   }
-------------------------------------------------------------
if conf is null then you get a lot of NullPointerExceptions.
I have tried to provide a default value when this information
is not present (missing jboss.xml in jar).

But providing this default information you will get another
NullPointerException. The reason is in EntityInstancePool and
StatelessInstancePool. I have changed method start() with
this...

-------------------------------------------------------------
try {
  EntityInstancePoolConfiguration conf = 
(EntityInstancePoolConfiguration)getContainer().getMetaData().getContain
erConfiguration().getInstancePoolConfiguration();
  maxSize = conf.getMaximumSize();
}
catch(NullPointerException npe) {
  maxSize = 100;
}
-------------------------------------------------------------

I don't like it, but it works. Rickard, you can do it better,
sure !  ;-)  All I want is a default maxSize when this
information is not present.

Hope this helps
Pedro Mota


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to