users@glassfish.java.net

RE: EJB, WAR and List as a method argument

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Tue, 17 Mar 2009 19:37:20 -0400

Here is a working jndiLookup example:

the resouce configuration file ra.xml defines 'connectionFactory' as
<connection-definition>
       <connectionfactory-interface>javax.sql.DataSource</connectionfactory-interface>
                <!-- Since AS 9.1 supports both JDBC 3.0 and JDBC 4.0,
                ConnectionFactory will be
                com.sun.gjc.spi.jdbc30.DataSource (JDK 1.5) or
                com.sun.gjc.spi.jdbc40.DataSource (JDK 1.6)
                -->
<connectionfactory-impl-class>com.sun.gjc.spi.DataSource</connectionfactory-impl-class>
       <connection-interface>java.sql.Connection</connection-interface>
                <!-- Since AS 9.1 supports both JDBC 3.0 and JDBC 4.0,
                Connection will be
                com.sun.gjc.spi.jdbc30.ConnectionHolder30 (JDK 1.5) or
                com.sun.gjc.spi.jdbc40.ConnectionHolder40 (JDK 1.6)
                -->
      <connection-impl-class>com.sun.gjc.spi.ConnectionHolder</connection-impl-class>
.........
</connection-definition>

  public static javax.jms.ConnectionFactory getConnectionFactory() throws Exception
  {
        if (USE_JNDI)
        {
            return (javax.jms.ConnectionFactory) jndiLookup("ConnectionFactory");
        }
        else
       {
            // return new provider-specific ConnectionFactory
            return new com.sun.messaging.ConnectionFactory();
        }
    }

    public static Object jndiLookup(String name) throws NamingException {
        Object obj = null;
        if (jndiContext == null)
        {
            try
            {
                jndiContext = new InitialContext();
            }
            catch (NamingException e)
            {
                System.out.println("Could not create JNDI context: " + e.toString());
                throw e;
            }
        }
        try
        {
           obj = jndiContext.lookup("cn=" + name);
        }
        catch (NamingException e)
        {
            System.out.println("JNDI lookup failed for:" + name + ": " + e.toString());
            throw e;
        }
        return obj;
    }

HTH
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung / Disclaimer and confidentiality note
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
This message is confidential and may be privileged. If you are not the intended recipient, we kindly ask you to please inform the sender. Any unauthorised dissemination or copying hereof is prohibited. This message serves for information purposes only and shall not have any legally binding effect. Given that e-mails can easily be subject to manipulation, we can not accept any liability for the content provided.






> Date: Tue, 17 Mar 2009 15:27:54 -0700
> From: mr_at_zoznam.sk
> To: users_at_glassfish.dev.java.net
> Subject: EJB, WAR and List as a method argument
>
>
> Hi everybody,
>
> I'm developing a simple j2ee application, that consists of one EJB and one
> webapplication. Both of these are deployed on the glassfish application
> server. For several reasons I cannot put both modules into the EAR
> application, but I have to deploy them as individual modules.
>
> For this reason I have put the EJB jar file also into the WEB-INF/lib of the
> web application. Everything works fine in this scenario apart from one case.
> I will illustrate this rather on an example.
>
> I have defined a simple method in my EJB (OrderDAOImpl that implemets
> OrderRemote and OrderLocal interfaces):
> void doSomething(List<Product> list){
> ....do something
> }
> where Product is a class defined in the EJB jar archive
>
> when I try to call this method in the webapplication:
> orderDAO = (OrderRemote) ic.lookup("orderDAO");
> List<Product> list = new ArrayList<Product>();
> list.add(new Product());
> orderDAO.doSomething(list);
>
> i get an exception:
> WARNING: "IOP00810257: (MARSHAL) Could not load class
> sk.miroz.ejb.model.Product"
> org.omg.CORBA.MARSHAL: vmcid: SUN minor code: 257 completed: Maybe
> at
> com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:9679)
> at
> com.sun.corba.ee.impl.logging.ORBUtilSystemException.couldNotFindClass(ORBUtilSystemException.java:9694)
> ... stacktrace continues...
>
> exception is thrown before the implementation of doSomething methos is
> entered. It seem like the there is a problem with
> serialization/deserialization/classloading of the ArrayList. Cannot it be
> caused because webapplication and EJB use different classloaders
> (WebappClassLoader and EJBClassLoader)? Is it possible to set, that both -
> the web application and also ejb use the same classloader?
>
> when I modified the function:
> void doSomething(Product product){
> ....do something
> }
> everything worked.
>
> Thanks in advance,
> Marian
> --
> View this message in context: http://www.nabble.com/EJB%2C-WAR-and-List-as-a-method-argument-tp22569216p22569216.html
> Sent from the java.net - glassfish users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Express your personality in color! Preview and select themes for HotmailŪ.
http://www.windowslive-hotmail.com/LearnMore/personalize.aspx?ocid=TXT_MSGTX_WL_HM_express_032009#colortheme