Yes the idea in converters if something is wrong and u wanna display some
info the idea is throw the converterexception.

Please do a request or send mail to tomee mailing list and i can help to
vote.

Regards.
El 13/04/2013 20:51, "Howard W. Smith, Jr." <smithh032...@gmail.com>
escribió:

> On Sat, Apr 13, 2013 at 9:41 PM, José Luis Cetina <maxtorz...@gmail.com
> >wrote:
>
> > Maybe could be a request for Rommain, i remember that tomee logs some
> info
> > about ejb but im not sure what exactly.
> >
> >
> Agreed, or even better, i'm sure Romain and TomEE committers will
> appreciate me opening a JIRA for it.  :)
>
> Below, is how TomEE logs the @Stateless EJBs. Do you see JNDI lookup path?
> :)
>
> Apr 13, 2013 8:36:09 PM org.apache.openejb.config.InitEjbDeployments deploy
> INFO: Auto-deploying ejb CustomerFacade:
> EjbDeployment(deployment-id=CustomerFacade)
>
>
> By the way i saw that you return null in your converters catch "statement".
> > Why dont throw a converterexception?
> >
>
> Hmmm, good question. Will the JNDI lookup path 'ever' be 'null'? i'm sure
> if I change the name of any of the Stateless @EJBs, then it may return
> 'null'. Right? :)
>
> Okay, I will throw the exception. of course, omnifaces will catch the error
> and display it via error page. :)
>
> Thank you and Mike for your responses and recommendations!!!
>
>
>
> > El 13/04/2013 20:37, "Howard W. Smith, Jr." <smithh032...@gmail.com>
> > escribió:
> >
> > > It would be nice if TomEE 'logs' the JNDI lookup path as the Reference
> > > Implementation (Glassfish) does! I had to say that. :)
> > >
> > >
> > > On Sat, Apr 13, 2013 at 9:34 PM, José Luis Cetina <
> maxtorz...@gmail.com
> > > >wrote:
> > >
> > > > Congrats. Howard. Just FYI tomee logs the ejb "path" of all yours
> ejbs
> > > > deployed and is not necesary to implement an interface for use jndi.
> > > >
> > > > Good to see that you got a solution.
> > > >
> > > > Regards.
> > > > El 13/04/2013 19:58, "Howard W. Smith, Jr." <smithh032...@gmail.com>
> > > > escribió:
> > > >
> > > > > On Sat, Apr 13, 2013 at 1:00 PM, José Luis Cetina <
> > > maxtorz...@gmail.com
> > > > > >wrote:
> > > > >
> > > > > > When i dont want to use codi I use jndi lookup, it is to easy to
> > use
> > > > and
> > > > > > portable. I create a simple method for retrive my ejbs without
> > using
> > > > codi
> > > > > > instead i use jndi using only the name of the ejb class.
> > > > > > El 13/04/2013 11:45, "Howard W. Smith, Jr." <
> > smithh032...@gmail.com>
> > > > > > escribió:
> > > > > >
> > > > > >
> > > > > José,
> > > > >
> > > > > JNDI works, thank you!  This was the first time I 'ever' had to use
> > > JNDI
> > > > > lookup. I had to research it (search google, look at TomEE
> examples -
> > > ejb
> > > > > reference[1][2][3], surely did not want to create an 'interface',
> > kept
> > > > > looking, looked at tomee log, as i know it lists all @EJBs at
> startup
> > > in
> > > > > the log, didn't see what i was looking for, so i looked at
> > RI/Glassfish
> > > > > log, since i 'remembered' that RI/Glassfish mentions the JNDI
> lookup
> > > path
> > > > > for all my @EJB's in the glassfish log at 'startup' of my app)...
> > > > >
> > > > > So, per an oracle blog[4][5] about JNDI lookup and what i saw in
> > > > glassfish
> > > > > log (12/9/2012 was last time i used glassfish to start my
> > > app...smile), I
> > > > > modified the @Singleton @Lock(READ) bean, accordingly (see code
> > below),
> > > > > tested it, and voila, it works!!!! :)
> > > > >
> > > > >
> > > > > /*
> > > > >  * To change this template, choose Tools | Templates
> > > > >  * and open the template in the editor.
> > > > >  */
> > > > > package converter;
> > > > >
> > > > > import java.util.concurrent.TimeUnit;
> > > > >
> > > > > import javax.ejb.AccessTimeout;
> > > > > import javax.ejb.Lock;
> > > > > import javax.ejb.LockType;
> > > > > import javax.ejb.Singleton;
> > > > >
> > > > > import javax.faces.component.UIComponent;
> > > > > import javax.faces.context.FacesContext;
> > > > > import javax.faces.convert.Converter;
> > > > > import javax.faces.convert.FacesConverter;
> > > > >
> > > > > import javax.naming.InitialContext;
> > > > >
> > > > > import jpa.entities.Customer;
> > > > > import jpa.session.CustomerFacade;
> > > > >
> > > > >
> > > > > @Singleton
> > > > > @Lock(LockType.READ)
> > > > > @AccessTimeout(value = 1, unit = TimeUnit.MINUTES)
> > > > > @FacesConverter(forClass = Customer.class)
> > > > > public class CustomerConverter implements Converter {
> > > > >
> > > > >     public CustomerConverter() {
> > > > >
> > > > >     }
> > > > >
> > > > >     public Object getAsObject(FacesContext facesContext,
> UIComponent
> > > > > component, String value) {
> > > > >         if (value == null || value.length() == 0) {
> > > > >             return null;
> > > > >         }
> > > > >         /*
> > > > >          * 2012-07-10 when user enters invalid/incomplete value
> (e.g.
> > > > > "irene", see below) in AutoComplete
> > > > >          *
> > > > >         WARNING: For input string: "irene"
> > > > >         java.lang.NumberFormatException: For input string: "irene"
> > > > >                 at
> > > > >
> > > > >
> > > >
> > >
> >
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> > > > >                 at java.lang.Integer.parseInt(Integer.java:492)
> > > > >                 at java.lang.Integer.valueOf(Integer.java:582)
> > > > >                 ...
> > > > >                 ...
> > > > >                 at
> > > > >
> > > > >
> > > >
> > >
> >
> org.primefaces.component.autocomplete.AutoCompleteRenderer.getConvertedValue(AutoCompleteRenderer.java:529)
> > > > >                 at
> > > > > javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
> > > > >                 at
> > > > javax.faces.component.UIInput.validate(UIInput.java:960)
> > > > >          *
> > > > >          */
> > > > >         try {
> > > > >             Integer test = getKey(value);
> > > > >         } catch (java.lang.NumberFormatException e) {
> > > > >             return null;
> > > > >         }
> > > > >         Object object = null;
> > > > >         CustomerFacade ejbFacade;
> > > > >         try {
> > > > >             InitialContext ic = new InitialContext();
> > > > >             ejbFacade = (CustomerFacade)
> > > > > ic.lookup("java:global/mcmsweb/CustomerFacade");
> > > > >             if (ejbFacade == null) {
> > > > >
> System.err.println("CustomerConverter.getAsObject():
> > > > > ejbFacade = null)");
> > > > >                 return null;
> > > > >             }
> > > > >         } catch (Exception e) {
> > > > >             System.err.println("CustomerConverter.getAsObject():
> > error
> > > on
> > > > > JNDI lookup of CustomerFacade");
> > > > >             e.printStackTrace();
> > > > >             return null;
> > > > >         }
> > > > >         try {
> > > > >             object = ejbFacade.find(getKey(value));
> > > > >         } catch (Exception e) {
> > > > >             System.err.println("CustomerConverter.getAsObject():
> > error
> > > on
> > > > > ejbFacade.find(getKey(value))");
> > > > >             e.printStackTrace();
> > > > >             return null;
> > > > >         }
> > > > >         return object;
> > > > >     }
> > > > >
> > > > >     java.lang.Integer getKey(String value) {
> > > > >         java.lang.Integer key;
> > > > >         key = Integer.valueOf(value);
> > > > >         return key;
> > > > >     }
> > > > >
> > > > >     String getStringKey(java.lang.Integer value) {
> > > > >         StringBuffer sb = new StringBuffer();
> > > > >         sb.append(value);
> > > > >         return sb.toString();
> > > > >     }
> > > > >
> > > > >     public String getAsString(FacesContext facesContext,
> UIComponent
> > > > > component, Object object) {
> > > > >         if (object == null) {
> > > > >             return null;
> > > > >         }
> > > > >         if (object instanceof Customer) {
> > > > >             Customer o = (Customer) object;
> > > > >             return getStringKey(o.getCustomerId());
> > > > >         } else {
> > > > >             throw new IllegalArgumentException("object " + object
> + "
> > > is
> > > > of
> > > > > type " + object.getClass().getName() + "; expected type: " +
> > > > > Customer.class.getName());
> > > > >         }
> > > > >     }
> > > > > }
> > > > >
> > > > >
> > > > > tomee examples - ejb reference
> > > > > [1]
> > > http://tomee.apache.org/examples-trunk/injection-of-ejbs/README.html
> > > > > [2]
> > > > >
> > > > >
> > > >
> > >
> >
> http://tomee.apache.org/examples-trunk/lookup-of-ejbs-with-descriptor/README.html
> > > > > [3]
> > http://tomee.apache.org/examples-trunk/lookup-of-ejbs/README.html
> > > > >
> > > > > oracle blogs
> > > > > [4]
> > > > >
> > > > >
> > > >
> > >
> >
> https://blogs.oracle.com/kensaks/entry/application_specified_portable_jndi_names
> > > > >
> > > > > which references the following, but needed to replace 'sun' with
> > > 'oracle'
> > > > > in the URL
> > > > >
> > > > > [5]
> > https://blogs.oracle.com/kensaks/entry/portable_global_jndi_names
> > > > >
> > > >
> > >
> >
>

Reply via email to