tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rupp, Hans" <H.R...@dzbw.de>
Subject AW: NoInitialContextException
Date Tue, 22 Nov 2011 08:03:43 GMT
Hallo Romain
Thanks for your answer.

Like this?
Properties p = new Properties();
p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
    		 "org.apache.openejb.client.LocalInitialContextFactory");
Context initialContext = new InitialContext(p);
			
this.propertyAdapter = (PropertyAdapter) initialContext.lookup("PropertyAdapterBean/local");

Yes that works. But it does not really solve my problem. I would have to modify my code so
that it works with OpenEJB in a way which is incompatible with the target platform (this won't
work on JBoss).

Greetings,

Hans

-----Ursprüngliche Nachricht-----
Von: Romain Manni-Bucau [mailto:rmannibucau@gmail.com] 
Gesendet: Dienstag, 22. November 2011 08:25
An: users@openejb.apache.org
Betreff: Re: NoInitialContextException

Hi,

try to pass this properties as your initial context parameter:

 p.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");

- Romain


2011/11/22 Rupp, Hans <H.Rupp@dzbw.de>

> Hallo I have a legacy application which I want to make testable with 
> OpenEJB (JEE5, target platform is JBoss 4.3). Most things work so far.
>
> However I need to access EJBs from simple classes (Pojos WITHOUT any
> annotations) like
>
> private void inject() {
>
>      try {
>
>                  Context initialContext = new InitialContext();
>
>
>
>                  this.propertyAdapter = (PropertyAdapter) 
> initialContext.lookup("propertyAdapter/local");
>
>            } catch (NamingException e) {
>
>                  log.error(e);
>
>            }
>
>   }
>
> (Yeah I know this is not nice and would have constitently used EJBs, 
> but there are classes with complicated constructors and many 
> parameters which I have so far not refactored to EJBs and the whole 
> architecture is a complete mess ... At the moment I have something 
> like EJBs -> POJOs -> EJBs ->
> Entities)
>
> When this code runs within OpenEJB
>
>
>
> javax.naming.NoInitialContextException: Need to specify class name in 
> environment or system property, or as an applet parameter, or in an 
> application resource file:  java.naming.factory.initial
>
>
>
> the façade EJBs are accessed by my tests, so I think I have at least 
> the basics right. Is there a way to avoid this Exception without 
> converting all classes to EJBs.
>
>
>
> Thanks for any hints,
>
>
>
> Hans
>
>
>
>
>
> 40 Jahre DZBW
> Herzlichen Dank unseren Kunden und Partnern. Wir freuen uns auf die 
> gemeinsame Fortsetzung der konstruktiven, vertrauensvollen Zusammenarbeit.
> Ihre Datenzentrale Baden-Württemberg
>
> ______________________________________________________________________
> _________
>
> Abonnieren Sie unseren Infobrief und erfahren Sie regelmäßig die 
> neuesten Nachrichten über unsere Lösungen, aktuellen Projekte und Entwicklungen.
> Melden sie sich an mit diesem Link 
> http://www.datenzentrale.de/Info-Brief
>
> ______________________________________________________________________
> _________
>
> Datenzentrale Baden-Württemberg, Anstalt des öffentlichen Rechts 
> Krailenshaldenstr. 44, 70469 Stuttgart Telefon (0711) 8108-20, Telefax 
> (0711) 8108-21350 E-Mail info@dzbw.de, Internet www.datenzentrale.de
> Vorstand: Karl Tramer (Vors.) und Joachim Kischlat, Vorsitzender des
> Verwaltungsrats: Gunter Czisch
> USt-Id-Nr. DE147794223
>
> ______________________________________________________________________
> _________
>
>
>

Mime
View raw message