Thanks for your reply, you put me on the right track: I solved it by putting jndi.properties with
java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory in the classpath of my test. Greetings, Hans -----Ursprüngliche Nachricht----- Von: Romain Manni-Bucau [mailto:[email protected]] Gesendet: Dienstag, 22. November 2011 09:05 An: [email protected] Betreff: Re: NoInitialContextException i think you can add a conf/system.properties file with this value. Otherwise add a real system property. - Romain 2011/11/22 Rupp, Hans <[email protected]> > 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:[email protected]] > Gesendet: Dienstag, 22. November 2011 08:25 > An: [email protected] > 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 <[email protected]> > > > 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 [email protected], Internet www.datenzentrale.de > > Vorstand: Karl Tramer (Vors.) und Joachim Kischlat, Vorsitzender des > > Verwaltungsrats: Gunter Czisch > > USt-Id-Nr. DE147794223 > > > > ____________________________________________________________________ > > __ > > _________ > > > > > > >
