Injecting the service itself is of cause a shortcut. I was unsure what you
wanted to test.
I understand you are just getting into it, its possibly best to go step by
step:
- my test uses the native container rather than paxrunner container (you
can switch back to paxrunner if desired but its not recommended as this
will go away in Pax Exam 3)
- I upgraded to Pax Exam 2.5
- Used Felix instead of Eclipse

Thats roughly about it. So you should just look at the consumer pom.xml and
understand the dependencies.
Native Container (pax-exam-container-native) needs a concrete OSGi
framework, so i added felix. You can also use equinox if wanted. Just look
it up on search.maven.org.


Toni Menzel | Founder | Rebaze GmbH
toni.men...@rebaze.com | www.rebaze.com
Access To Alien Technology: Great software needs a great foundation. We
help unlocking the next level in technology.
Rebaze Pass for Maven <http://goo.gl/1YLlt>, Rebaze Pass for
OSGi<http://goo.gl/WP8XT>
, Rebaze Pass for Neo4j <http://www.rebaze.com/services/>, Rebaze Pass for
Jenkins <http://www.rebaze.com/services/>



On Thu, Sep 6, 2012 at 11:48 AM, neeraj bhusare <neerajbhus...@gmail.com>wrote:

> Thank you very much. In addition to your changes, I have injected the
> service (@Inject HelloWorldService service) and it worked fine. I
> understand the changes you have made, but I still don't understand what was
> wrong in my code. Do  you have any pointers that might help me understand
> what was the issue. From my side I am also going through the PAX EXAM
> documentation.
>
> NOTE: I had made the changes you had recommended in your previous reply
> and tested the same, which for some reason didn't work.
> ---
> Best regards, Neeraj
>
>
>
> On Thu, Sep 6, 2012 at 2:24 PM, Toni Menzel <toni.men...@rebaze.com>wrote:
>
>> Here are my changes. You can also download as ZIP if you don't like Git:
>> https://github.com/tonit/temp-paxexam-neeraj
>>
>> --
>> Toni Menzel | Founder | Rebaze GmbH
>> toni.men...@rebaze.com | www.rebaze.com
>> Access To Alien Technology: Great software needs a great foundation. We
>> help unlocking the next level in technology.
>> Rebaze Pass for Maven <http://goo.gl/1YLlt>, Rebaze Pass for 
>> OSGi<http://goo.gl/WP8XT>
>> , Rebaze Pass for Neo4j <http://www.rebaze.com/services/>, Rebaze Pass
>> for Jenkins <http://www.rebaze.com/services/>
>>
>>
>>
>> On Thu, Sep 6, 2012 at 10:38 AM, Toni Menzel <toni.men...@rebaze.com>wrote:
>>
>>> I will push my changes to your code later and let you know. There you
>>> can review.
>>>
>>>
>>>
>>> On Thu, Sep 6, 2012 at 10:34 AM, neeraj bhusare <neerajbhus...@gmail.com
>>> > wrote:
>>>
>>>> Thanks for the review. I made the changes to the publisher pom, and the
>>>> generated manifest now has the metadata about the bundle activator. In
>>>> addition, I also added "org.neclipse.helloworld.service" in the imported
>>>> packages, which was missing. But still the publish bundle stays in the
>>>> Installed (ID=2) state and the service is not registered.
>>>>
>>>> >Also be aware that the service might not have been published already
>>>> when the test is called. At best consume with a >service tracker or 
>>>> similar.
>>>>
>>>> Assuming that the service is not published, the test will fail and I am
>>>> ok with that for now. What I don't understand is that the publish bundle
>>>> doesn't go into the starting/active state. I had read that the bundle might
>>>> stay in the Installed state if its dependencies are not resolved. But that
>>>> doesn't seem to be the case. Could there be anything else causing the 
>>>> issue.
>>>>
>>>> For now, I plan to use the simple BundleContext#registerService() and
>>>> BundleContext#getServiceReference api. I'll use the DS approach sometime
>>>> later. I assume this has nothing to do with the bundle remaining in
>>>> installed state.
>>>>
>>>> Thanks again for the review and posting your findings. I'll make the
>>>> changes you suggested.
>>>> ---
>>>> Best regards, Neeraj
>>>>
>>>>
>>>>
>>>> On Thu, Sep 6, 2012 at 12:53 PM, Toni Menzel <toni.men...@rebaze.com>wrote:
>>>>
>>>>> Also be aware that the service might not have been published already
>>>>> when the test is called. At best consume with a service tracker or 
>>>>> similar.
>>>>>
>>>>> Please note: this message sent from a Mobile device.
>>>>> On Sep 6, 2012 9:04 AM, "Toni Menzel" <toni.men...@rebaze.com> wrote:
>>>>>
>>>>>> Hi Neeraj,
>>>>>>
>>>>>> You are never publishing the service because the activator is not
>>>>>> called.
>>>>>> Add
>>>>>>
>>>>>>  
>>>>>> <Bundle-Activator>org.neclipse.helloworld.publish.HelloWorldActivator</Bundle-Activator>
>>>>>> to the manifest of your publisher or use some other meaning of
>>>>>> automatically publish the service (DS,Blueprint etc).
>>>>>>
>>>>>> Other than the problem itself, here are some more findings after
>>>>>> reviewing your example code:
>>>>>> - Upgrade to Pax Exam 2.5
>>>>>> - Is there a particular reason you are using paxrunner container ?
>>>>>> Try the Native Container. Much faster. Gives you more options choosing 
>>>>>> the
>>>>>> framework.
>>>>>> - Never(!) use artifact.version=0.0.1 in development iteration.
>>>>>> Instead, you are always using -SNAPSHOT versions (e.g. 0.0.1-SNAPSHOT).  
>>>>>> A
>>>>>> released version (everything non snapshot) is assumed to never change. 
>>>>>> Just
>>>>>> leads you into trouble.
>>>>>>
>>>>>> Let me know if this works for you.
>>>>>> Toni
>>>>>>
>>>>>> Toni Menzel | Founder | Rebaze GmbH
>>>>>> toni.men...@rebaze.com | www.rebaze.com
>>>>>> Access To Alien Technology: Great software needs a great foundation.
>>>>>> We help unlocking the next level in technology.
>>>>>> Rebaze Pass for Maven <http://goo.gl/1YLlt>, Rebaze Pass for 
>>>>>> OSGi<http://goo.gl/WP8XT>
>>>>>> , Rebaze Pass for Neo4j <http://www.rebaze.com/services/>, Rebaze
>>>>>> Pass for Jenkins <http://www.rebaze.com/services/>
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Sep 6, 2012 at 12:32 AM, neeraj bhusare <
>>>>>> neerajbhus...@gmail.com> wrote:
>>>>>>
>>>>>>> I have some problems sharing the project via Github. Could you
>>>>>>> please take a look at the attached project zip. Also, please ignore
>>>>>>> the typos in my previous post. I meant, I had tried using #start(),
>>>>>>> #start(true)...
>>>>>>>
>>>>>>>
>>>>>>> Thanks in advance.
>>>>>>> ---
>>>>>>> Best regards, Neeraj
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Sep 6, 2012 at 1:46 AM, Toni Menzel 
>>>>>>> <toni.men...@rebaze.com>wrote:
>>>>>>>
>>>>>>>> Can you share example code ? Best via Github?
>>>>>>>>
>>>>>>>> --
>>>>>>>> Toni Menzel | Founder | Rebaze GmbH
>>>>>>>> toni.men...@rebaze.com | www.rebaze.com
>>>>>>>> Access To Alien Technology: Great software needs a great
>>>>>>>> foundation. We help unlocking the next level in technology.
>>>>>>>> Rebaze Pass for Maven <http://goo.gl/1YLlt>, Rebaze Pass for 
>>>>>>>> OSGi<http://goo.gl/WP8XT>
>>>>>>>> , Rebaze Pass for Neo4j <http://www.rebaze.com/services/>, Rebaze
>>>>>>>> Pass for Jenkins <http://www.rebaze.com/services/>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, Sep 5, 2012 at 9:59 PM, neeraj bhusare <
>>>>>>>> neerajbhus...@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> I am working on a small example project that has two bundles. The
>>>>>>>>> first bundle publishes a service and the second contains the test that
>>>>>>>>> tries to read/test the presence of the service in one of its @Test 
>>>>>>>>> methods.
>>>>>>>>> I also iterate through the list of installed bundles and print their 
>>>>>>>>> state.
>>>>>>>>> All the bundles, except the first bundle (that exposes the service) 
>>>>>>>>> are in
>>>>>>>>> the Active state. I have tried using #state(), #state(true) but the 
>>>>>>>>> state
>>>>>>>>> of the bundle remains the same (Installed). Unless the bundle goes 
>>>>>>>>> into
>>>>>>>>> Starting/Active state, the services won't get registered and I can't 
>>>>>>>>> test
>>>>>>>>> it.
>>>>>>>>> I have tried installing the first bundle separately using the OSGi
>>>>>>>>> console and it works fine. The services are registered properly. But 
>>>>>>>>> the
>>>>>>>>> same doesn't work when the bundle is provisioned in the test. Am I 
>>>>>>>>> missing
>>>>>>>>> something here?
>>>>>>>>>
>>>>>>>>> Thanks in advance.
>>>>>>>>> ---
>>>>>>>>> Best regards, Neeraj
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> general mailing list
>>>>>>>>> general@lists.ops4j.org
>>>>>>>>> http://lists.ops4j.org/mailman/listinfo/general
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> general mailing list
>>>>>>>> general@lists.ops4j.org
>>>>>>>> http://lists.ops4j.org/mailman/listinfo/general
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> general mailing list
>>>>>>> general@lists.ops4j.org
>>>>>>> http://lists.ops4j.org/mailman/listinfo/general
>>>>>>>
>>>>>>>
>>>>>>
>>>>> _______________________________________________
>>>>> general mailing list
>>>>> general@lists.ops4j.org
>>>>> http://lists.ops4j.org/mailman/listinfo/general
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> general mailing list
>>>> general@lists.ops4j.org
>>>> http://lists.ops4j.org/mailman/listinfo/general
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> general mailing list
>> general@lists.ops4j.org
>> http://lists.ops4j.org/mailman/listinfo/general
>>
>>
>
> _______________________________________________
> general mailing list
> general@lists.ops4j.org
> http://lists.ops4j.org/mailman/listinfo/general
>
>
_______________________________________________
general mailing list
general@lists.ops4j.org
http://lists.ops4j.org/mailman/listinfo/general

Reply via email to