Hi Matt,

the stack trace looks like in the ITest there is no Aries JNDI provider (either 
because it is not installed or has failed to start).

In the blog tests there is:
            mavenBundle("org.apache.aries.jndi", "org.apache.aries.jndi" )

Plus at least the following dependencies I believe:

            mavenBundle("org.apache.aries.proxy", "org.apache.aries.proxy"),
            mavenBundle("org.apache.aries", "org.apache.aries.util" ),
            mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
            mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
            mavenBundle("asm", "asm-all" )

If you have those already in the setup, then I would assume that the JNDI 
bundle has not started correctly :(

Regards,

Valentin

On 18 Apr 2011, at 20:22, Matt Madhavan wrote:

> Hello,
> I have a service defined as follows:
> 
>       <bean id="persistenceImpl"
>               
> class="com.hcsc.itf.osgi.samples.bp_sdm_jpa.jpa.BlogPersistenceServiceImpl">
>               <tx:transaction method="*" value="Required" />
>               <jpa:context property="entityManager" unitname="blogExample" />
>       </bean>
> 
>       <service id="blogJPAPersistenceService" ref="persistenceImpl"
>               
> interface="com.hcsc.itf.osgi.samples.bp_sdm_jpa.api.persistence.BlogPersistenceService">
>                  <service-properties>
>                       <entry key="osgi.jndi.service.name" 
> value="persistence/bpJPAPersistenceService"/>
>               </service-properties>           
>       </service>              
> 
> When I do Integration test (I'm using PAX-Exam/Pax_runner(1.5.0) with 
> Equinox) I can look up the Service as follows with no problem.
> 
>  @Test
>       public void testPeristence() throws Exception {
>               BlogPersistenceService jpaService = getOsgiService(
>                               BlogPersistenceService.class,
>                               
> "osgi.jndi.service.name=persistence/bpJPAPersistenceService",
>                               10000); 
> 
> But I wanted to,look up the same service as a raw JNDI Look up as follows:    
> 
>       @Test
>       public void testPeristence() throws Exception {
>               InitialContext ic = new InitialContext();
> 
>               BlogPersistenceService jpaService = (BlogPersistenceService) 
> ic.lookup("osgi:service/"
>                               + 
> "com.hcsc.itf.osgi.samples.bp_sdm_jpa.api.persistence.BlogPersistenceService");
> 
> 
> 
> 
> I'm getting the following Exception. (Please note that I'm in essence doing 
> the same thing as Apache Aries Blog sample!)
> 
> 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
>       at 
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
>       at 
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>       at 
> javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
>       at javax.naming.InitialContext.lookup(InitialContext.java:392)
>       at 
> com.hcsc.itf.osgi.samples.bp_sdm_jpa.itests.jpa.BpJpaJndiLookUpITest.testPeristence(BpJpaJndiLookUpITest.java:41)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.ops4j.pax.exam.junit.extender.impl.internal.CallableTestMethodImpl.injectContextAndInvoke(CallableTestMethodImpl.java:143)
>       at 
> org.ops4j.pax.exam.junit.extender.impl.internal.CallableTestMethodImpl.call(CallableTestMethodImpl.java:105)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at 
> org.ops4j.pax.exam.rbc.internal.RemoteBundleContextImpl.remoteCall(RemoteBundleContextImpl.java:80)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
>       at sun.rmi.transport.Transport$1.run(Transport.java:159)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
>       at 
> sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
>       at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
>       at 
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>       at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>       at java.lang.Thread.run(Thread.java:662)
> 
> I'm kind of lost! I'm doing the exact thing as done in the Aries Blog sample! 
> Any ideas please?
> 
> Thanks
> Matt
> 
> 
> 

Reply via email to