Skip to main content

Can a web service deployed in Grizzly access Felix

23 replies [Last post]
Anonymous

I don't know if this is a silly question, but I am having some fundamental
issues understanding the Glassfish v3 architecture and could use a pointer.

I have created a bundle and added an entry in the glassfish/felix.conf e.g.

file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar

I see this bundle starting and all is well. It opens a socket to which I can
connect and exchange data, which is nice. The reason I created a bundle and
not a H2K module is that I want it to be activated at server start-up time.
I could not see a way of doing this with H2K. Maybe I missed something.

Now I want to reference this service from a web service that I have deployed
in Grizzly. I simply cannot figure out how to do this. The docs do not
really cover this, which leads me to believe I am doing something
fundamentally wrong.

Do Felix and Grizzly share any kind of context or is there a static way to
access the Felix services from a web application deployed in Grizzly?

I have tried this....

wsContext.getMessageContext();
ServletContext sCtx = (ServletContext)
mc.get(MessageContext.SERVLET_CONTEXT);
Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");

This, I believe, gets me a reference to the H2K habitat, but my bundle is an
OSGi bundle deployed in Felix, not an H2K service. Can I navigate to my
bundle through this habitat? Is it right to try? If so is there a maven
dependency I need to pick up the Habitat class as I cannot seem to find it
anywhere.

I would appreciate any pointers. TIA.
Paul B.

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Bhakti Mehta

Paul,
This ClassCastException seems to be a bug in webservices code. I have
fixed similar issue some time ago. If you are still running into this
with the latest v3 build please file a bug under v3 webservices and
atach your war
Thanks,
Bhakti

paulbrickell wrote:
> Sahoo,
>
> Just want to check I am doing the right thing here.
>
> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
> this bundle annotated with Contract.
>
> I have taken the latest nightly build and put my bundle in the
> autodeploy-bundles directory. When I start Glassfish I see logging from
> bundle. So that's good.
>
> I am having problems deploying my web application into this server. When I
> deploy It I get an error...
>
> cannot Deploy testservice
> Deployment Error for module: test-service: Exception while loading the app
> : java.lang.Exception: java.lang.IllegalStateException:
> ContainerBase.addChild: start: LifecycleException:
> java.lang.ClassCastException:
> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
> javax.servlet.Servlet
>
> Not sure what this all about. Will continue investigating.
>
> Regards,
> Paul B.
>
>
> Sahoo wrote:
>
>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>> Habitat.getByContract(). If at all you have to iterate over all the
>> implementations of a contract, you should use
>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>> getAllByType() is not so user friendly. In HK2, type means
>> implementation type!
>>
>> Sahoo
>>
>> paulbrickell wrote:
>>
>>> Sahoo,
>>>
>>> You right of course.
>>>
>>> Anyhoo, using that repository and building my war gives me no compilation
>>> problems.
>>>
>>> My code is now doing this...
>>>
>>> MessageContext mc = _wsContext.getMessageContext();
>>> ServletContext sCtx = (ServletContext)
>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>> Habitat habitat = (Habitat)
>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>
>>> This works OK, but I get a zero length collection. I will get the latest
>>> build and try dropping my bundle jar in the autodeploy dir as you
>>> suggested.
>>>
>>> I will let you know how I get on.
>>>
>>> Thanks again,
>>> Paul B.
>>>
>>>
>>>
>>> Sahoo wrote:
>>>
>>>
>>>> May be my understanding of our maven repositories are wrong, but AFAIK,
>>>> only artifacts produced by GlassFish build should go to
>>>>
>>>> http://download.java.net/maven/glassfish/,
>>>>
>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>> Anyway, this is not the core of the problems being discussed here.
>>>>
>>>> Thanks,
>>>> Sahoo
>>>> paulbrickell wrote:
>>>>
>>>>
>>>>> but, did find it in...
>>>>>
>>>>> http://download.java.net/maven/glassfish/
>>>>>
>>>>>
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Sahoo,
>>>>>>
>>>>>> Really appreciate your help.
>>>>>>
>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>> repositories you listed.
>>>>>>
>>>>>> Thanks,
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sahoo wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>
>>>>>>> You should be able to do this in your code:
>>>>>>>
>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>
>>>>>>>
>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>> set
>>>>>>> up your maven dependency like this:
>>>>>>>
>>>>>>>
>>>>>>> com.sun.enterprise
>>>>>>> hk2
>>>>>>> RELEASE
>>>>>>> provided
>>>>>>>
>>>>>>>
>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sahoo
>>>>>>>
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Sahoo,
>>>>>>>>
>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>> It's
>>>>>>>> just a
>>>>>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>>>>>
>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>> but
>>>>>>>> it
>>>>>>>> did
>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>> BundleActivator.start
>>>>>>>> method) . I suspect I might be behind on the build. I will pick up
>>>>>>>> the
>>>>>>>> latest nightly today.
>>>>>>>>
>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>> from
>>>>>>>> the
>>>>>>>> app context. But I cannot cast it to the right type. I still do not
>>>>>>>> know
>>>>>>>> an
>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>
>>>>>>>> Thanks for your help.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Sahoo wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Paul,
>>>>>>>>>
>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>> OSGi
>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>> automatically
>>>>>>>>> started when server starts. Please use the latest nightly build as
>>>>>>>>> I
>>>>>>>>> fixed an important bug around this.
>>>>>>>>>
>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you
>>>>>>>>> tell
>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>> thing?
>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>
>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>> object.
>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>> Habitat.
>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and
>>>>>>>>> I2,
>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Sahoo
>>>>>>>>>
>>>>>>>>> paulbrickell wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>> fundamental
>>>>>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>>>>>> pointer.
>>>>>>>>>>
>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>> e.g.
>>>>>>>>>>
>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>
>>>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>>>> which
>>>>>>>>>> I
>>>>>>>>>> can
>>>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>>>> bundle
>>>>>>>>>> and
>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>> start-up
>>>>>>>>>> time.
>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>> something.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>> have
>>>>>>>>>> deployed
>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do
>>>>>>>>>> not
>>>>>>>>>> really cover this, which leads me to believe I am doing something
>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>
>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>> static
>>>>>>>>>> way
>>>>>>>>>> to
>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>> Grizzly?
>>>>>>>>>>
>>>>>>>>>> I have tried this....
>>>>>>>>>>
>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>> Object habitat =
>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>
>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>> bundle
>>>>>>>>>> is
>>>>>>>>>> an
>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate
>>>>>>>>>> to
>>>>>>>>>> my
>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>>>>>> maven
>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>>>>>> find
>>>>>>>>>> it
>>>>>>>>>> anywhere.
>>>>>>>>>>
>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>> Paul B.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Bhakti,

This problem is occurring with the nightly build from the 20th May.

It's a bit late here now, so I will try again tomorrow and if the problem
persists I will do as you suggest. Thanks for the hint.

Any chance you could add a link to the issue log so I can do some
comparisons?

Thanks,
Paul B.

Bhakti Mehta wrote:
>
> Paul,
> This ClassCastException seems to be a bug in webservices code. I have
> fixed similar issue some time ago. If you are still running into this
> with the latest v3 build please file a bug under v3 webservices and
> atach your war
> Thanks,
> Bhakti
>
> paulbrickell wrote:
>> Sahoo,
>>
>> Just want to check I am doing the right thing here.
>>
>> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
>> this bundle annotated with Contract.
>>
>> I have taken the latest nightly build and put my bundle in the
>> autodeploy-bundles directory. When I start Glassfish I see logging from
>> bundle. So that's good.
>>
>> I am having problems deploying my web application into this server. When
>> I
>> deploy It I get an error...
>>
>> cannot Deploy testservice
>> Deployment Error for module: test-service: Exception while loading the
>> app
>> : java.lang.Exception: java.lang.IllegalStateException:
>> ContainerBase.addChild: start: LifecycleException:
>> java.lang.ClassCastException:
>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>> javax.servlet.Servlet
>>
>> Not sure what this all about. Will continue investigating.
>>
>> Regards,
>> Paul B.
>>
>>
>> Sahoo wrote:
>>
>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>> Habitat.getByContract(). If at all you have to iterate over all the
>>> implementations of a contract, you should use
>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>> getAllByType() is not so user friendly. In HK2, type means
>>> implementation type!
>>>
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> Sahoo,
>>>>
>>>> You right of course.
>>>>
>>>> Anyhoo, using that repository and building my war gives me no
>>>> compilation
>>>> problems.
>>>>
>>>> My code is now doing this...
>>>>
>>>> MessageContext mc = _wsContext.getMessageContext();
>>>> ServletContext sCtx = (ServletContext)
>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>> Habitat habitat = (Habitat)
>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>
>>>> This works OK, but I get a zero length collection. I will get the
>>>> latest
>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>> suggested.
>>>>
>>>> I will let you know how I get on.
>>>>
>>>> Thanks again,
>>>> Paul B.
>>>>
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> May be my understanding of our maven repositories are wrong, but
>>>>> AFAIK,
>>>>> only artifacts produced by GlassFish build should go to
>>>>>
>>>>> http://download.java.net/maven/glassfish/,
>>>>>
>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> but, did find it in...
>>>>>>
>>>>>> http://download.java.net/maven/glassfish/
>>>>>>
>>>>>>
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Sahoo,
>>>>>>>
>>>>>>> Really appreciate your help.
>>>>>>>
>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>> repositories you listed.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Paul B.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Sahoo wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>
>>>>>>>> You should be able to do this in your code:
>>>>>>>>
>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>
>>>>>>>>
>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>>> set
>>>>>>>> up your maven dependency like this:
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.enterprise
>>>>>>>> hk2
>>>>>>>> RELEASE
>>>>>>>> provided
>>>>>>>>
>>>>>>>>
>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sahoo
>>>>>>>>
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Sahoo,
>>>>>>>>>
>>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>>> It's
>>>>>>>>> just a
>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>> Eclipse).
>>>>>>>>>
>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>>> but
>>>>>>>>> it
>>>>>>>>> did
>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>> BundleActivator.start
>>>>>>>>> method) . I suspect I might be behind on the build. I will pick up
>>>>>>>>> the
>>>>>>>>> latest nightly today.
>>>>>>>>>
>>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>>> from
>>>>>>>>> the
>>>>>>>>> app context. But I cannot cast it to the right type. I still do
>>>>>>>>> not
>>>>>>>>> know
>>>>>>>>> an
>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>
>>>>>>>>> Thanks for your help.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sahoo wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Paul,
>>>>>>>>>>
>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>>> OSGi
>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>> automatically
>>>>>>>>>> started when server starts. Please use the latest nightly build
>>>>>>>>>> as
>>>>>>>>>> I
>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>
>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can
>>>>>>>>>> you
>>>>>>>>>> tell
>>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>>> thing?
>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>
>>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>>> object.
>>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>>> Habitat.
>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1
>>>>>>>>>> and
>>>>>>>>>> I2,
>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Sahoo
>>>>>>>>>>
>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>>> fundamental
>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could use
>>>>>>>>>>> a
>>>>>>>>>>> pointer.
>>>>>>>>>>>
>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>> e.g.
>>>>>>>>>>>
>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>
>>>>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>>>>> which
>>>>>>>>>>> I
>>>>>>>>>>> can
>>>>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>>>>> bundle
>>>>>>>>>>> and
>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>> start-up
>>>>>>>>>>> time.
>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>> something.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>>> have
>>>>>>>>>>> deployed
>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs
>>>>>>>>>>> do
>>>>>>>>>>> not
>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>> something
>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>
>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>> static
>>>>>>>>>>> way
>>>>>>>>>>> to
>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>> Grizzly?
>>>>>>>>>>>
>>>>>>>>>>> I have tried this....
>>>>>>>>>>>
>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>> Object habitat =
>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>
>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>>> bundle
>>>>>>>>>>> is
>>>>>>>>>>> an
>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>> navigate
>>>>>>>>>>> to
>>>>>>>>>>> my
>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there
>>>>>>>>>>> a
>>>>>>>>>>> maven
>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem
>>>>>>>>>>> to
>>>>>>>>>>> find
>>>>>>>>>>> it
>>>>>>>>>>> anywhere.
>>>>>>>>>>>
>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>> Paul B.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Jane Young

BTW: you can also use GlassFish Nexus Server URL:
http://maven.glassfish.org/content/groups/glassfish

paulbrickell wrote:
> but, did find it in...
>
> http://download.java.net/maven/glassfish/
>
>
>
> paulbrickell wrote:
>
>> Sahoo,
>>
>> Really appreciate your help.
>>
>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>> repositories you listed.
>>
>> Thanks,
>> Paul B.
>>
>>
>>
>> Sahoo wrote:
>>
>>> OK, thanks for clarifying about the deployment part.
>>>
>>> You should be able to do this in your code:
>>>
>>> org.jvnet.hk2.component.Habitat =
>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>
>>>
>>> org.jvnet.hk2.component package is part of HK2 project, so you can set
>>> up your maven dependency like this:
>>>
>>>
>>> com.sun.enterprise
>>> hk2
>>> RELEASE
>>> provided
>>>
>>>
>>> Ensure that you have added http://download.java.net/maven/2 and
>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>> repositories either in your pom.xml or in your maven settings.xml.
>>>
>>> Thanks,
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> Sahoo,
>>>>
>>>> Sorry. You are of course right about the web service deployment. It's
>>>> just a
>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>
>>>> I did try just dropping the bundle in the autodeploy-bundles dir, but it
>>>> did
>>>> not seem to start (I saw none of the logging from my
>>>> BundleActivator.start
>>>> method) . I suspect I might be behind on the build. I will pick up the
>>>> latest nightly today.
>>>>
>>>> As described in my original post I have pulled the Habitat object from
>>>> the
>>>> app context. But I cannot cast it to the right type. I still do not know
>>>> an
>>>> appropriate maven dependency I can add to get it.
>>>>
>>>> Thanks for your help.
>>>>
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> Paul,
>>>>>
>>>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>>>> started when server starts. Please use the latest nightly build as I
>>>>> fixed an important bug around this.
>>>>>
>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you tell
>>>>> us how you packaged your web service and how you deployed such a thing?
>>>>> Did you really mean GlassFish or Grizzly?
>>>>>
>>>>> 3. All the registered OSGi services can be accessed via Habitat object.
>>>>> The OSGi service interface names are mapped to contract names in
>>>>> Habitat.
>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> I don't know if this is a silly question, but I am having some
>>>>>> fundamental
>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>> pointer.
>>>>>>
>>>>>> I have created a bundle and added an entry in the glassfish/felix.conf
>>>>>> e.g.
>>>>>>
>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>
>>>>>> I see this bundle starting and all is well. It opens a socket to which
>>>>>> I
>>>>>> can
>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>> bundle
>>>>>> and
>>>>>> not a H2K module is that I want it to be activated at server start-up
>>>>>> time.
>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>> something.
>>>>>>
>>>>>>
>>>>>> Now I want to reference this service from a web service that I have
>>>>>> deployed
>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>>>>>> really cover this, which leads me to believe I am doing something
>>>>>> fundamentally wrong.
>>>>>>
>>>>>> Do Felix and Grizzly share any kind of context or is there a static
>>>>>> way
>>>>>> to
>>>>>> access the Felix services from a web application deployed in Grizzly?
>>>>>>
>>>>>> I have tried this....
>>>>>>
>>>>>> wsContext.getMessageContext();
>>>>>> ServletContext sCtx = (ServletContext)
>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>
>>>>>> This, I believe, gets me a reference to the H2K habitat, but my bundle
>>>>>> is
>>>>>> an
>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>>>>>> my
>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>> maven
>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>> find
>>>>>> it
>>>>>> anywhere.
>>>>>>
>>>>>> I would appreciate any pointers. TIA.
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>
>

[att1.html]

Jerome Dochez

On May 20, 2009, at 5:38 AM, paulbrickell wrote:

>
> I don't know if this is a silly question, but I am having some
> fundamental
> issues understanding the Glassfish v3 architecture and could use a
> pointer.
>
> I have created a bundle and added an entry in the glassfish/
> felix.conf e.g.
>
> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-
> SNAPSHOT.jar
>
> I see this bundle starting and all is well. It opens a socket to
> which I can
> connect and exchange data, which is nice. The reason I created a
> bundle and
> not a H2K module is that I want it to be activated at server start-
> up time.
> I could not see a way of doing this with H2K. Maybe I missed
> something.
the easiest would be to add a startup service :

@Service
public class MyStartup implements Startup {

...
}

now if you don't need any GlassFish services, OSGi route is fine.
>
>
> Now I want to reference this service from a web service that I have
> deployed
> in Grizzly.
which service ? this service was added to OSGi service registry ?
> I simply cannot figure out how to do this. The docs do not
> really cover this, which leads me to believe I am doing something
> fundamentally wrong.
>
> Do Felix and Grizzly share any kind of context or is there a static
> way to
> access the Felix services from a web application deployed in Grizzly?
>
> I have tried this....
>
> wsContext.getMessageContext();
> ServletContext sCtx = (ServletContext)
> mc.get(MessageContext.SERVLET_CONTEXT);
> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>
> This, I believe, gets me a reference to the H2K habitat, but my
> bundle is an
> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
> my
> bundle through this habitat? Is it right to try? If so is there a
> maven
> dependency I need to pick up the Habitat class as I cannot seem to
> find it
> anywhere.

I can see Sahoo helped you getting to the habitat, I believe you can
also try normal Java EE injection,

@Resource
Habitat habitat;

or even better, if your service was added to the habitat or as an OSGi
service then you do not need to depend on hk2 at all, you can just do

@Resource(mappedName="osgiName")
SomeService myService

look at my latest blog entry http://blogs.sun.com/dochez/

it might help.

Jerome

>
> I would appreciate any pointers. TIA.
> Paul B.
>
>
>
> --
> View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
> Sent from the java.net - glassfish users mailing list archive at
> Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Jerome,

I had not seen that blog before. This
http://blogs.sun.com/dochez/entry/glassfish_v3_extensions_part_2 looks
fantastically simple. I did try this approach but on the v3 prelude build I
could never get this to work.

Frankly, I am quite happy to recast my OSGi bundle as a H2K module and use
the admin tools you detail in the blog. The simplicity appeals enormously. I
also want to try the Resource annotation for my service. I will spend a
little time an try that approach again.

I will let you know how it goes.

Thanks both of you. It's a big help.

Jerome Dochez wrote:
>
>
> On May 20, 2009, at 5:38 AM, paulbrickell wrote:
>
>>
>> I don't know if this is a silly question, but I am having some
>> fundamental
>> issues understanding the Glassfish v3 architecture and could use a
>> pointer.
>>
>> I have created a bundle and added an entry in the glassfish/
>> felix.conf e.g.
>>
>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-
>> SNAPSHOT.jar
>>
>> I see this bundle starting and all is well. It opens a socket to
>> which I can
>> connect and exchange data, which is nice. The reason I created a
>> bundle and
>> not a H2K module is that I want it to be activated at server start-
>> up time.
>> I could not see a way of doing this with H2K. Maybe I missed
>> something.
> the easiest would be to add a startup service :
>
> @Service
> public class MyStartup implements Startup {
>
> ...
> }
>
> now if you don't need any GlassFish services, OSGi route is fine.
>>
>>
>> Now I want to reference this service from a web service that I have
>> deployed
>> in Grizzly.
> which service ? this service was added to OSGi service registry ?
>> I simply cannot figure out how to do this. The docs do not
>> really cover this, which leads me to believe I am doing something
>> fundamentally wrong.
>>
>> Do Felix and Grizzly share any kind of context or is there a static
>> way to
>> access the Felix services from a web application deployed in Grizzly?
>>
>> I have tried this....
>>
>> wsContext.getMessageContext();
>> ServletContext sCtx = (ServletContext)
>> mc.get(MessageContext.SERVLET_CONTEXT);
>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>
>> This, I believe, gets me a reference to the H2K habitat, but my
>> bundle is an
>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>> my
>> bundle through this habitat? Is it right to try? If so is there a
>> maven
>> dependency I need to pick up the Habitat class as I cannot seem to
>> find it
>> anywhere.
>
> I can see Sahoo helped you getting to the habitat, I believe you can
> also try normal Java EE injection,
>
> @Resource
> Habitat habitat;
>
> or even better, if your service was added to the habitat or as an OSGi
> service then you do not need to depend on hk2 at all, you can just do
>
> @Resource(mappedName="osgiName")
> SomeService myService
>
> look at my latest blog entry http://blogs.sun.com/dochez/
>
> it might help.
>
> Jerome
>
>>
>> I would appreciate any pointers. TIA.
>> Paul B.
>>
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
>> Sent from the java.net - glassfish users mailing list archive at
>> Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

Paul,

1. You don't have to modify Felix config file. You can drop your OSGi
bundle in domain1/autodeploy-bundles dir and it will be automatically
started when server starts. Please use the latest nightly build as I
fixed an important bug around this.

2. What do you mean by deploying a web service in Grizzly? Can you tell
us how you packaged your web service and how you deployed such a thing?
Did you really mean GlassFish or Grizzly?

3. All the registered OSGi services can be accessed via Habitat object.
The OSGi service interface names are mapped to contract names in Habitat.
e.g., if you have an OSGi service Foo.class which implements I1 and I2,
then you can access it via Habitat.getByContract(I1 or I2.class)

Thanks,
Sahoo

paulbrickell wrote:
> I don't know if this is a silly question, but I am having some fundamental
> issues understanding the Glassfish v3 architecture and could use a pointer.
>
> I have created a bundle and added an entry in the glassfish/felix.conf e.g.
>
> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>
> I see this bundle starting and all is well. It opens a socket to which I can
> connect and exchange data, which is nice. The reason I created a bundle and
> not a H2K module is that I want it to be activated at server start-up time.
> I could not see a way of doing this with H2K. Maybe I missed something.
>
>
> Now I want to reference this service from a web service that I have deployed
> in Grizzly. I simply cannot figure out how to do this. The docs do not
> really cover this, which leads me to believe I am doing something
> fundamentally wrong.
>
> Do Felix and Grizzly share any kind of context or is there a static way to
> access the Felix services from a web application deployed in Grizzly?
>
> I have tried this....
>
> wsContext.getMessageContext();
> ServletContext sCtx = (ServletContext)
> mc.get(MessageContext.SERVLET_CONTEXT);
> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>
> This, I believe, gets me a reference to the H2K habitat, but my bundle is an
> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to my
> bundle through this habitat? Is it right to try? If so is there a maven
> dependency I need to pick up the Habitat class as I cannot seem to find it
> anywhere.
>
> I would appreciate any pointers. TIA.
> Paul B.
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Sahoo,

Sorry. You are of course right about the web service deployment. It's just a
war file deployed in glassfish (atually I am debugging in Eclipse).

I did try just dropping the bundle in the autodeploy-bundles dir, but it did
not seem to start (I saw none of the logging from my BundleActivator.start
method) . I suspect I might be behind on the build. I will pick up the
latest nightly today.

As described in my original post I have pulled the Habitat object from the
app context. But I cannot cast it to the right type. I still do not know an
appropriate maven dependency I can add to get it.

Thanks for your help.

Sahoo wrote:
>
> Paul,
>
> 1. You don't have to modify Felix config file. You can drop your OSGi
> bundle in domain1/autodeploy-bundles dir and it will be automatically
> started when server starts. Please use the latest nightly build as I
> fixed an important bug around this.
>
> 2. What do you mean by deploying a web service in Grizzly? Can you tell
> us how you packaged your web service and how you deployed such a thing?
> Did you really mean GlassFish or Grizzly?
>
> 3. All the registered OSGi services can be accessed via Habitat object.
> The OSGi service interface names are mapped to contract names in Habitat.
> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
> then you can access it via Habitat.getByContract(I1 or I2.class)
>
> Thanks,
> Sahoo
>
> paulbrickell wrote:
>> I don't know if this is a silly question, but I am having some
>> fundamental
>> issues understanding the Glassfish v3 architecture and could use a
>> pointer.
>>
>> I have created a bundle and added an entry in the glassfish/felix.conf
>> e.g.
>>
>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>
>> I see this bundle starting and all is well. It opens a socket to which I
>> can
>> connect and exchange data, which is nice. The reason I created a bundle
>> and
>> not a H2K module is that I want it to be activated at server start-up
>> time.
>> I could not see a way of doing this with H2K. Maybe I missed something.
>>
>>
>> Now I want to reference this service from a web service that I have
>> deployed
>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>> really cover this, which leads me to believe I am doing something
>> fundamentally wrong.
>>
>> Do Felix and Grizzly share any kind of context or is there a static way
>> to
>> access the Felix services from a web application deployed in Grizzly?
>>
>> I have tried this....
>>
>> wsContext.getMessageContext();
>> ServletContext sCtx = (ServletContext)
>> mc.get(MessageContext.SERVLET_CONTEXT);
>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>
>> This, I believe, gets me a reference to the H2K habitat, but my bundle is
>> an
>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to my
>> bundle through this habitat? Is it right to try? If so is there a maven
>> dependency I need to pick up the Habitat class as I cannot seem to find
>> it
>> anywhere.
>>
>> I would appreciate any pointers. TIA.
>> Paul B.
>>
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

OK, thanks for clarifying about the deployment part.

You should be able to do this in your code:

org.jvnet.hk2.component.Habitat = org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));

org.jvnet.hk2.component package is part of HK2 project, so you can set
up your maven dependency like this:


com.sun.enterprise
hk2
RELEASE
provided

Ensure that you have added http://download.java.net/maven/2 and
http://download.java.net/maven/1 as additional maven 2 and maven 1
repositories either in your pom.xml or in your maven settings.xml.

Thanks,
Sahoo

paulbrickell wrote:
> Sahoo,
>
> Sorry. You are of course right about the web service deployment. It's just a
> war file deployed in glassfish (atually I am debugging in Eclipse).
>
> I did try just dropping the bundle in the autodeploy-bundles dir, but it did
> not seem to start (I saw none of the logging from my BundleActivator.start
> method) . I suspect I might be behind on the build. I will pick up the
> latest nightly today.
>
> As described in my original post I have pulled the Habitat object from the
> app context. But I cannot cast it to the right type. I still do not know an
> appropriate maven dependency I can add to get it.
>
> Thanks for your help.
>
>
>
> Sahoo wrote:
>
>> Paul,
>>
>> 1. You don't have to modify Felix config file. You can drop your OSGi
>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>> started when server starts. Please use the latest nightly build as I
>> fixed an important bug around this.
>>
>> 2. What do you mean by deploying a web service in Grizzly? Can you tell
>> us how you packaged your web service and how you deployed such a thing?
>> Did you really mean GlassFish or Grizzly?
>>
>> 3. All the registered OSGi services can be accessed via Habitat object.
>> The OSGi service interface names are mapped to contract names in Habitat.
>> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>
>> Thanks,
>> Sahoo
>>
>> paulbrickell wrote:
>>
>>> I don't know if this is a silly question, but I am having some
>>> fundamental
>>> issues understanding the Glassfish v3 architecture and could use a
>>> pointer.
>>>
>>> I have created a bundle and added an entry in the glassfish/felix.conf
>>> e.g.
>>>
>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>
>>> I see this bundle starting and all is well. It opens a socket to which I
>>> can
>>> connect and exchange data, which is nice. The reason I created a bundle
>>> and
>>> not a H2K module is that I want it to be activated at server start-up
>>> time.
>>> I could not see a way of doing this with H2K. Maybe I missed something.
>>>
>>>
>>> Now I want to reference this service from a web service that I have
>>> deployed
>>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>>> really cover this, which leads me to believe I am doing something
>>> fundamentally wrong.
>>>
>>> Do Felix and Grizzly share any kind of context or is there a static way
>>> to
>>> access the Felix services from a web application deployed in Grizzly?
>>>
>>> I have tried this....
>>>
>>> wsContext.getMessageContext();
>>> ServletContext sCtx = (ServletContext)
>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>
>>> This, I believe, gets me a reference to the H2K habitat, but my bundle is
>>> an
>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to my
>>> bundle through this habitat? Is it right to try? If so is there a maven
>>> dependency I need to pick up the Habitat class as I cannot seem to find
>>> it
>>> anywhere.
>>>
>>> I would appreciate any pointers. TIA.
>>> Paul B.
>>>
>>>
>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Sahoo,

Really appreciate your help.

I'm afraid I do not find com.sun.enterprise.hk2 in either of the
repositories you listed.

Thanks,
Paul B.

Sahoo wrote:
>
> OK, thanks for clarifying about the deployment part.
>
> You should be able to do this in your code:
>
> org.jvnet.hk2.component.Habitat =
> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>
>
> org.jvnet.hk2.component package is part of HK2 project, so you can set
> up your maven dependency like this:
>
>
> com.sun.enterprise
> hk2
> RELEASE
> provided
>
>
> Ensure that you have added http://download.java.net/maven/2 and
> http://download.java.net/maven/1 as additional maven 2 and maven 1
> repositories either in your pom.xml or in your maven settings.xml.
>
> Thanks,
> Sahoo
>
> paulbrickell wrote:
>> Sahoo,
>>
>> Sorry. You are of course right about the web service deployment. It's
>> just a
>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>
>> I did try just dropping the bundle in the autodeploy-bundles dir, but it
>> did
>> not seem to start (I saw none of the logging from my
>> BundleActivator.start
>> method) . I suspect I might be behind on the build. I will pick up the
>> latest nightly today.
>>
>> As described in my original post I have pulled the Habitat object from
>> the
>> app context. But I cannot cast it to the right type. I still do not know
>> an
>> appropriate maven dependency I can add to get it.
>>
>> Thanks for your help.
>>
>>
>>
>> Sahoo wrote:
>>
>>> Paul,
>>>
>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>> started when server starts. Please use the latest nightly build as I
>>> fixed an important bug around this.
>>>
>>> 2. What do you mean by deploying a web service in Grizzly? Can you tell
>>> us how you packaged your web service and how you deployed such a thing?
>>> Did you really mean GlassFish or Grizzly?
>>>
>>> 3. All the registered OSGi services can be accessed via Habitat object.
>>> The OSGi service interface names are mapped to contract names in
>>> Habitat.
>>> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>
>>> Thanks,
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> I don't know if this is a silly question, but I am having some
>>>> fundamental
>>>> issues understanding the Glassfish v3 architecture and could use a
>>>> pointer.
>>>>
>>>> I have created a bundle and added an entry in the glassfish/felix.conf
>>>> e.g.
>>>>
>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>
>>>> I see this bundle starting and all is well. It opens a socket to which
>>>> I
>>>> can
>>>> connect and exchange data, which is nice. The reason I created a bundle
>>>> and
>>>> not a H2K module is that I want it to be activated at server start-up
>>>> time.
>>>> I could not see a way of doing this with H2K. Maybe I missed something.
>>>>
>>>>
>>>> Now I want to reference this service from a web service that I have
>>>> deployed
>>>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>>>> really cover this, which leads me to believe I am doing something
>>>> fundamentally wrong.
>>>>
>>>> Do Felix and Grizzly share any kind of context or is there a static way
>>>> to
>>>> access the Felix services from a web application deployed in Grizzly?
>>>>
>>>> I have tried this....
>>>>
>>>> wsContext.getMessageContext();
>>>> ServletContext sCtx = (ServletContext)
>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>
>>>> This, I believe, gets me a reference to the H2K habitat, but my bundle
>>>> is
>>>> an
>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to my
>>>> bundle through this habitat? Is it right to try? If so is there a maven
>>>> dependency I need to pick up the Habitat class as I cannot seem to find
>>>> it
>>>> anywhere.
>>>>
>>>> I would appreciate any pointers. TIA.
>>>> Paul B.
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

but, did find it in...

http://download.java.net/maven/glassfish/

paulbrickell wrote:
>
> Sahoo,
>
> Really appreciate your help.
>
> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
> repositories you listed.
>
> Thanks,
> Paul B.
>
>
>
> Sahoo wrote:
>>
>> OK, thanks for clarifying about the deployment part.
>>
>> You should be able to do this in your code:
>>
>> org.jvnet.hk2.component.Habitat =
>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>
>>
>> org.jvnet.hk2.component package is part of HK2 project, so you can set
>> up your maven dependency like this:
>>
>>
>> com.sun.enterprise
>> hk2
>> RELEASE
>> provided
>>
>>
>> Ensure that you have added http://download.java.net/maven/2 and
>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>> repositories either in your pom.xml or in your maven settings.xml.
>>
>> Thanks,
>> Sahoo
>>
>> paulbrickell wrote:
>>> Sahoo,
>>>
>>> Sorry. You are of course right about the web service deployment. It's
>>> just a
>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>
>>> I did try just dropping the bundle in the autodeploy-bundles dir, but it
>>> did
>>> not seem to start (I saw none of the logging from my
>>> BundleActivator.start
>>> method) . I suspect I might be behind on the build. I will pick up the
>>> latest nightly today.
>>>
>>> As described in my original post I have pulled the Habitat object from
>>> the
>>> app context. But I cannot cast it to the right type. I still do not know
>>> an
>>> appropriate maven dependency I can add to get it.
>>>
>>> Thanks for your help.
>>>
>>>
>>>
>>> Sahoo wrote:
>>>
>>>> Paul,
>>>>
>>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>>> started when server starts. Please use the latest nightly build as I
>>>> fixed an important bug around this.
>>>>
>>>> 2. What do you mean by deploying a web service in Grizzly? Can you tell
>>>> us how you packaged your web service and how you deployed such a thing?
>>>> Did you really mean GlassFish or Grizzly?
>>>>
>>>> 3. All the registered OSGi services can be accessed via Habitat object.
>>>> The OSGi service interface names are mapped to contract names in
>>>> Habitat.
>>>> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>
>>>> Thanks,
>>>> Sahoo
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>> I don't know if this is a silly question, but I am having some
>>>>> fundamental
>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>> pointer.
>>>>>
>>>>> I have created a bundle and added an entry in the glassfish/felix.conf
>>>>> e.g.
>>>>>
>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>
>>>>> I see this bundle starting and all is well. It opens a socket to which
>>>>> I
>>>>> can
>>>>> connect and exchange data, which is nice. The reason I created a
>>>>> bundle
>>>>> and
>>>>> not a H2K module is that I want it to be activated at server start-up
>>>>> time.
>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>> something.
>>>>>
>>>>>
>>>>> Now I want to reference this service from a web service that I have
>>>>> deployed
>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>>>>> really cover this, which leads me to believe I am doing something
>>>>> fundamentally wrong.
>>>>>
>>>>> Do Felix and Grizzly share any kind of context or is there a static
>>>>> way
>>>>> to
>>>>> access the Felix services from a web application deployed in Grizzly?
>>>>>
>>>>> I have tried this....
>>>>>
>>>>> wsContext.getMessageContext();
>>>>> ServletContext sCtx = (ServletContext)
>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>
>>>>> This, I believe, gets me a reference to the H2K habitat, but my bundle
>>>>> is
>>>>> an
>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>>>>> my
>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>> maven
>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>> find
>>>>> it
>>>>> anywhere.
>>>>>
>>>>> I would appreciate any pointers. TIA.
>>>>> Paul B.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

May be my understanding of our maven repositories are wrong, but AFAIK,
only artifacts produced by GlassFish build should go to

http://download.java.net/maven/glassfish/,

but, that appears not to be true. So, go ahead and use that repo.
Anyway, this is not the core of the problems being discussed here.

Thanks,
Sahoo
paulbrickell wrote:
> but, did find it in...
>
> http://download.java.net/maven/glassfish/
>
>
>
> paulbrickell wrote:
>
>> Sahoo,
>>
>> Really appreciate your help.
>>
>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>> repositories you listed.
>>
>> Thanks,
>> Paul B.
>>
>>
>>
>> Sahoo wrote:
>>
>>> OK, thanks for clarifying about the deployment part.
>>>
>>> You should be able to do this in your code:
>>>
>>> org.jvnet.hk2.component.Habitat =
>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>
>>>
>>> org.jvnet.hk2.component package is part of HK2 project, so you can set
>>> up your maven dependency like this:
>>>
>>>
>>> com.sun.enterprise
>>> hk2
>>> RELEASE
>>> provided
>>>
>>>
>>> Ensure that you have added http://download.java.net/maven/2 and
>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>> repositories either in your pom.xml or in your maven settings.xml.
>>>
>>> Thanks,
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> Sahoo,
>>>>
>>>> Sorry. You are of course right about the web service deployment. It's
>>>> just a
>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>
>>>> I did try just dropping the bundle in the autodeploy-bundles dir, but it
>>>> did
>>>> not seem to start (I saw none of the logging from my
>>>> BundleActivator.start
>>>> method) . I suspect I might be behind on the build. I will pick up the
>>>> latest nightly today.
>>>>
>>>> As described in my original post I have pulled the Habitat object from
>>>> the
>>>> app context. But I cannot cast it to the right type. I still do not know
>>>> an
>>>> appropriate maven dependency I can add to get it.
>>>>
>>>> Thanks for your help.
>>>>
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> Paul,
>>>>>
>>>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>>>> started when server starts. Please use the latest nightly build as I
>>>>> fixed an important bug around this.
>>>>>
>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you tell
>>>>> us how you packaged your web service and how you deployed such a thing?
>>>>> Did you really mean GlassFish or Grizzly?
>>>>>
>>>>> 3. All the registered OSGi services can be accessed via Habitat object.
>>>>> The OSGi service interface names are mapped to contract names in
>>>>> Habitat.
>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and I2,
>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> I don't know if this is a silly question, but I am having some
>>>>>> fundamental
>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>> pointer.
>>>>>>
>>>>>> I have created a bundle and added an entry in the glassfish/felix.conf
>>>>>> e.g.
>>>>>>
>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>
>>>>>> I see this bundle starting and all is well. It opens a socket to which
>>>>>> I
>>>>>> can
>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>> bundle
>>>>>> and
>>>>>> not a H2K module is that I want it to be activated at server start-up
>>>>>> time.
>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>> something.
>>>>>>
>>>>>>
>>>>>> Now I want to reference this service from a web service that I have
>>>>>> deployed
>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do not
>>>>>> really cover this, which leads me to believe I am doing something
>>>>>> fundamentally wrong.
>>>>>>
>>>>>> Do Felix and Grizzly share any kind of context or is there a static
>>>>>> way
>>>>>> to
>>>>>> access the Felix services from a web application deployed in Grizzly?
>>>>>>
>>>>>> I have tried this....
>>>>>>
>>>>>> wsContext.getMessageContext();
>>>>>> ServletContext sCtx = (ServletContext)
>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>
>>>>>> This, I believe, gets me a reference to the H2K habitat, but my bundle
>>>>>> is
>>>>>> an
>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>>>>>> my
>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>> maven
>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>> find
>>>>>> it
>>>>>> anywhere.
>>>>>>
>>>>>> I would appreciate any pointers. TIA.
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Sahoo,

You right of course.

Anyhoo, using that repository and building my war gives me no compilation
problems.

My code is now doing this...

MessageContext mc = _wsContext.getMessageContext();
ServletContext sCtx = (ServletContext)
mc.get(MessageContext.SERVLET_CONTEXT);
Habitat habitat = (Habitat)
sCtx.getAttribute("org.glassfish.servlet.habitat");
Collection apis = habitat.getAllByType(MyAPI.class);

This works OK, but I get a zero length collection. I will get the latest
build and try dropping my bundle jar in the autodeploy dir as you suggested.

I will let you know how I get on.

Thanks again,
Paul B.

Sahoo wrote:
>
> May be my understanding of our maven repositories are wrong, but AFAIK,
> only artifacts produced by GlassFish build should go to
>
> http://download.java.net/maven/glassfish/,
>
> but, that appears not to be true. So, go ahead and use that repo.
> Anyway, this is not the core of the problems being discussed here.
>
> Thanks,
> Sahoo
> paulbrickell wrote:
>> but, did find it in...
>>
>> http://download.java.net/maven/glassfish/
>>
>>
>>
>> paulbrickell wrote:
>>
>>> Sahoo,
>>>
>>> Really appreciate your help.
>>>
>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>> repositories you listed.
>>>
>>> Thanks,
>>> Paul B.
>>>
>>>
>>>
>>> Sahoo wrote:
>>>
>>>> OK, thanks for clarifying about the deployment part.
>>>>
>>>> You should be able to do this in your code:
>>>>
>>>> org.jvnet.hk2.component.Habitat =
>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>
>>>>
>>>> org.jvnet.hk2.component package is part of HK2 project, so you can set
>>>> up your maven dependency like this:
>>>>
>>>>
>>>> com.sun.enterprise
>>>> hk2
>>>> RELEASE
>>>> provided
>>>>
>>>>
>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>
>>>> Thanks,
>>>> Sahoo
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>> Sahoo,
>>>>>
>>>>> Sorry. You are of course right about the web service deployment. It's
>>>>> just a
>>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>>
>>>>> I did try just dropping the bundle in the autodeploy-bundles dir, but
>>>>> it
>>>>> did
>>>>> not seem to start (I saw none of the logging from my
>>>>> BundleActivator.start
>>>>> method) . I suspect I might be behind on the build. I will pick up the
>>>>> latest nightly today.
>>>>>
>>>>> As described in my original post I have pulled the Habitat object from
>>>>> the
>>>>> app context. But I cannot cast it to the right type. I still do not
>>>>> know
>>>>> an
>>>>> appropriate maven dependency I can add to get it.
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>>
>>>>>
>>>>> Sahoo wrote:
>>>>>
>>>>>
>>>>>> Paul,
>>>>>>
>>>>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>>>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>>>>> started when server starts. Please use the latest nightly build as I
>>>>>> fixed an important bug around this.
>>>>>>
>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you
>>>>>> tell
>>>>>> us how you packaged your web service and how you deployed such a
>>>>>> thing?
>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>
>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>> object.
>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>> Habitat.
>>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and
>>>>>> I2,
>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>
>>>>>> Thanks,
>>>>>> Sahoo
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>> fundamental
>>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>>> pointer.
>>>>>>>
>>>>>>> I have created a bundle and added an entry in the
>>>>>>> glassfish/felix.conf
>>>>>>> e.g.
>>>>>>>
>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>
>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>> which
>>>>>>> I
>>>>>>> can
>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>> bundle
>>>>>>> and
>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>> start-up
>>>>>>> time.
>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>> something.
>>>>>>>
>>>>>>>
>>>>>>> Now I want to reference this service from a web service that I have
>>>>>>> deployed
>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do
>>>>>>> not
>>>>>>> really cover this, which leads me to believe I am doing something
>>>>>>> fundamentally wrong.
>>>>>>>
>>>>>>> Do Felix and Grizzly share any kind of context or is there a static
>>>>>>> way
>>>>>>> to
>>>>>>> access the Felix services from a web application deployed in
>>>>>>> Grizzly?
>>>>>>>
>>>>>>> I have tried this....
>>>>>>>
>>>>>>> wsContext.getMessageContext();
>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>
>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>> bundle
>>>>>>> is
>>>>>>> an
>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>>>>>>> my
>>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>>> maven
>>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>>> find
>>>>>>> it
>>>>>>> anywhere.
>>>>>>>
>>>>>>> I would appreciate any pointers. TIA.
>>>>>>> Paul B.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

Hold on. You are using Habitat.getAllByType(). I asked you to use
Habitat.getByContract(). If at all you have to iterate over all the
implementations of a contract, you should use
Habitat.getAllByContracts(). Oh yes, I understand the method name
getAllByType() is not so user friendly. In HK2, type means
implementation type!

Sahoo

paulbrickell wrote:
> Sahoo,
>
> You right of course.
>
> Anyhoo, using that repository and building my war gives me no compilation
> problems.
>
> My code is now doing this...
>
> MessageContext mc = _wsContext.getMessageContext();
> ServletContext sCtx = (ServletContext)
> mc.get(MessageContext.SERVLET_CONTEXT);
> Habitat habitat = (Habitat)
> sCtx.getAttribute("org.glassfish.servlet.habitat");
> Collection apis = habitat.getAllByType(MyAPI.class);
>
> This works OK, but I get a zero length collection. I will get the latest
> build and try dropping my bundle jar in the autodeploy dir as you suggested.
>
> I will let you know how I get on.
>
> Thanks again,
> Paul B.
>
>
>
> Sahoo wrote:
>
>> May be my understanding of our maven repositories are wrong, but AFAIK,
>> only artifacts produced by GlassFish build should go to
>>
>> http://download.java.net/maven/glassfish/,
>>
>> but, that appears not to be true. So, go ahead and use that repo.
>> Anyway, this is not the core of the problems being discussed here.
>>
>> Thanks,
>> Sahoo
>> paulbrickell wrote:
>>
>>> but, did find it in...
>>>
>>> http://download.java.net/maven/glassfish/
>>>
>>>
>>>
>>> paulbrickell wrote:
>>>
>>>
>>>> Sahoo,
>>>>
>>>> Really appreciate your help.
>>>>
>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>> repositories you listed.
>>>>
>>>> Thanks,
>>>> Paul B.
>>>>
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> OK, thanks for clarifying about the deployment part.
>>>>>
>>>>> You should be able to do this in your code:
>>>>>
>>>>> org.jvnet.hk2.component.Habitat =
>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>
>>>>>
>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can set
>>>>> up your maven dependency like this:
>>>>>
>>>>>
>>>>> com.sun.enterprise
>>>>> hk2
>>>>> RELEASE
>>>>> provided
>>>>>
>>>>>
>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> Sahoo,
>>>>>>
>>>>>> Sorry. You are of course right about the web service deployment. It's
>>>>>> just a
>>>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>>>
>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir, but
>>>>>> it
>>>>>> did
>>>>>> not seem to start (I saw none of the logging from my
>>>>>> BundleActivator.start
>>>>>> method) . I suspect I might be behind on the build. I will pick up the
>>>>>> latest nightly today.
>>>>>>
>>>>>> As described in my original post I have pulled the Habitat object from
>>>>>> the
>>>>>> app context. But I cannot cast it to the right type. I still do not
>>>>>> know
>>>>>> an
>>>>>> appropriate maven dependency I can add to get it.
>>>>>>
>>>>>> Thanks for your help.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sahoo wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Paul,
>>>>>>>
>>>>>>> 1. You don't have to modify Felix config file. You can drop your OSGi
>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be automatically
>>>>>>> started when server starts. Please use the latest nightly build as I
>>>>>>> fixed an important bug around this.
>>>>>>>
>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you
>>>>>>> tell
>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>> thing?
>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>
>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>> object.
>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>> Habitat.
>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and
>>>>>>> I2,
>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sahoo
>>>>>>>
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>> fundamental
>>>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>>>> pointer.
>>>>>>>>
>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>> glassfish/felix.conf
>>>>>>>> e.g.
>>>>>>>>
>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>
>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>> which
>>>>>>>> I
>>>>>>>> can
>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>> bundle
>>>>>>>> and
>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>> start-up
>>>>>>>> time.
>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>> something.
>>>>>>>>
>>>>>>>>
>>>>>>>> Now I want to reference this service from a web service that I have
>>>>>>>> deployed
>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do
>>>>>>>> not
>>>>>>>> really cover this, which leads me to believe I am doing something
>>>>>>>> fundamentally wrong.
>>>>>>>>
>>>>>>>> Do Felix and Grizzly share any kind of context or is there a static
>>>>>>>> way
>>>>>>>> to
>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>> Grizzly?
>>>>>>>>
>>>>>>>> I have tried this....
>>>>>>>>
>>>>>>>> wsContext.getMessageContext();
>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>> Object habitat = sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>
>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>> bundle
>>>>>>>> is
>>>>>>>> an
>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate to
>>>>>>>> my
>>>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>>>> maven
>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>>>> find
>>>>>>>> it
>>>>>>>> anywhere.
>>>>>>>>
>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>> Paul B.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Sahoo,

Just want to check I am doing the right thing here.

I am creating an OSGi bundle, not an H2K module. I have no interfaces in
this bundle annotated with Contract.

I have taken the latest nightly build and put my bundle in the
autodeploy-bundles directory. When I start Glassfish I see logging from
bundle. So that's good.

I am having problems deploying my web application into this server. When I
deploy It I get an error...

cannot Deploy testservice
Deployment Error for module: test-service: Exception while loading the app
: java.lang.Exception: java.lang.IllegalStateException:
ContainerBase.addChild: start: LifecycleException:
java.lang.ClassCastException:
com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
javax.servlet.Servlet

Not sure what this all about. Will continue investigating.

Regards,
Paul B.

Sahoo wrote:
>
> Hold on. You are using Habitat.getAllByType(). I asked you to use
> Habitat.getByContract(). If at all you have to iterate over all the
> implementations of a contract, you should use
> Habitat.getAllByContracts(). Oh yes, I understand the method name
> getAllByType() is not so user friendly. In HK2, type means
> implementation type!
>
> Sahoo
>
> paulbrickell wrote:
>> Sahoo,
>>
>> You right of course.
>>
>> Anyhoo, using that repository and building my war gives me no compilation
>> problems.
>>
>> My code is now doing this...
>>
>> MessageContext mc = _wsContext.getMessageContext();
>> ServletContext sCtx = (ServletContext)
>> mc.get(MessageContext.SERVLET_CONTEXT);
>> Habitat habitat = (Habitat)
>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>> Collection apis = habitat.getAllByType(MyAPI.class);
>>
>> This works OK, but I get a zero length collection. I will get the latest
>> build and try dropping my bundle jar in the autodeploy dir as you
>> suggested.
>>
>> I will let you know how I get on.
>>
>> Thanks again,
>> Paul B.
>>
>>
>>
>> Sahoo wrote:
>>
>>> May be my understanding of our maven repositories are wrong, but AFAIK,
>>> only artifacts produced by GlassFish build should go to
>>>
>>> http://download.java.net/maven/glassfish/,
>>>
>>> but, that appears not to be true. So, go ahead and use that repo.
>>> Anyway, this is not the core of the problems being discussed here.
>>>
>>> Thanks,
>>> Sahoo
>>> paulbrickell wrote:
>>>
>>>> but, did find it in...
>>>>
>>>> http://download.java.net/maven/glassfish/
>>>>
>>>>
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>
>>>>> Sahoo,
>>>>>
>>>>> Really appreciate your help.
>>>>>
>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>> repositories you listed.
>>>>>
>>>>> Thanks,
>>>>> Paul B.
>>>>>
>>>>>
>>>>>
>>>>> Sahoo wrote:
>>>>>
>>>>>
>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>
>>>>>> You should be able to do this in your code:
>>>>>>
>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>
>>>>>>
>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>> set
>>>>>> up your maven dependency like this:
>>>>>>
>>>>>>
>>>>>> com.sun.enterprise
>>>>>> hk2
>>>>>> RELEASE
>>>>>> provided
>>>>>>
>>>>>>
>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>
>>>>>> Thanks,
>>>>>> Sahoo
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>> Sahoo,
>>>>>>>
>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>> It's
>>>>>>> just a
>>>>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>>>>
>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>> but
>>>>>>> it
>>>>>>> did
>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>> BundleActivator.start
>>>>>>> method) . I suspect I might be behind on the build. I will pick up
>>>>>>> the
>>>>>>> latest nightly today.
>>>>>>>
>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>> from
>>>>>>> the
>>>>>>> app context. But I cannot cast it to the right type. I still do not
>>>>>>> know
>>>>>>> an
>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>
>>>>>>> Thanks for your help.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Sahoo wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Paul,
>>>>>>>>
>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>> OSGi
>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>> automatically
>>>>>>>> started when server starts. Please use the latest nightly build as
>>>>>>>> I
>>>>>>>> fixed an important bug around this.
>>>>>>>>
>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you
>>>>>>>> tell
>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>> thing?
>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>
>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>> object.
>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>> Habitat.
>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and
>>>>>>>> I2,
>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sahoo
>>>>>>>>
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>> fundamental
>>>>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>>>>> pointer.
>>>>>>>>>
>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>> glassfish/felix.conf
>>>>>>>>> e.g.
>>>>>>>>>
>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>
>>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>>> which
>>>>>>>>> I
>>>>>>>>> can
>>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>>> bundle
>>>>>>>>> and
>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>> start-up
>>>>>>>>> time.
>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>> something.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>> have
>>>>>>>>> deployed
>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do
>>>>>>>>> not
>>>>>>>>> really cover this, which leads me to believe I am doing something
>>>>>>>>> fundamentally wrong.
>>>>>>>>>
>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>> static
>>>>>>>>> way
>>>>>>>>> to
>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>> Grizzly?
>>>>>>>>>
>>>>>>>>> I have tried this....
>>>>>>>>>
>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>> Object habitat =
>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>
>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>> bundle
>>>>>>>>> is
>>>>>>>>> an
>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate
>>>>>>>>> to
>>>>>>>>> my
>>>>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>>>>> maven
>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>>>>> find
>>>>>>>>> it
>>>>>>>>> anywhere.
>>>>>>>>>
>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>> Paul B.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

I understand very well you are not developing a HK2 bundle. You don't
have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
understanding is you are registering some service with interface
MyAPI.class in the OSGi service registry. as I told you, we
automatically register it with Habitat under contract called
MyAPI.class. Hope this is clear. Since you have access to Habitat from
your web app, you can access the service by using Habitat.getByContract().

About your deployment failure, that seems unrelated. Looks like some
broken web service functionality.

Thanks,
Sahoo

paulbrickell wrote:
> Sahoo,
>
> Just want to check I am doing the right thing here.
>
> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
> this bundle annotated with Contract.
>
> I have taken the latest nightly build and put my bundle in the
> autodeploy-bundles directory. When I start Glassfish I see logging from
> bundle. So that's good.
>
> I am having problems deploying my web application into this server. When I
> deploy It I get an error...
>
> cannot Deploy testservice
> Deployment Error for module: test-service: Exception while loading the app
> : java.lang.Exception: java.lang.IllegalStateException:
> ContainerBase.addChild: start: LifecycleException:
> java.lang.ClassCastException:
> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
> javax.servlet.Servlet
>
> Not sure what this all about. Will continue investigating.
>
> Regards,
> Paul B.
>
>
> Sahoo wrote:
>
>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>> Habitat.getByContract(). If at all you have to iterate over all the
>> implementations of a contract, you should use
>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>> getAllByType() is not so user friendly. In HK2, type means
>> implementation type!
>>
>> Sahoo
>>
>> paulbrickell wrote:
>>
>>> Sahoo,
>>>
>>> You right of course.
>>>
>>> Anyhoo, using that repository and building my war gives me no compilation
>>> problems.
>>>
>>> My code is now doing this...
>>>
>>> MessageContext mc = _wsContext.getMessageContext();
>>> ServletContext sCtx = (ServletContext)
>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>> Habitat habitat = (Habitat)
>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>
>>> This works OK, but I get a zero length collection. I will get the latest
>>> build and try dropping my bundle jar in the autodeploy dir as you
>>> suggested.
>>>
>>> I will let you know how I get on.
>>>
>>> Thanks again,
>>> Paul B.
>>>
>>>
>>>
>>> Sahoo wrote:
>>>
>>>
>>>> May be my understanding of our maven repositories are wrong, but AFAIK,
>>>> only artifacts produced by GlassFish build should go to
>>>>
>>>> http://download.java.net/maven/glassfish/,
>>>>
>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>> Anyway, this is not the core of the problems being discussed here.
>>>>
>>>> Thanks,
>>>> Sahoo
>>>> paulbrickell wrote:
>>>>
>>>>
>>>>> but, did find it in...
>>>>>
>>>>> http://download.java.net/maven/glassfish/
>>>>>
>>>>>
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Sahoo,
>>>>>>
>>>>>> Really appreciate your help.
>>>>>>
>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>> repositories you listed.
>>>>>>
>>>>>> Thanks,
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sahoo wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>
>>>>>>> You should be able to do this in your code:
>>>>>>>
>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>
>>>>>>>
>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>> set
>>>>>>> up your maven dependency like this:
>>>>>>>
>>>>>>>
>>>>>>> com.sun.enterprise
>>>>>>> hk2
>>>>>>> RELEASE
>>>>>>> provided
>>>>>>>
>>>>>>>
>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sahoo
>>>>>>>
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Sahoo,
>>>>>>>>
>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>> It's
>>>>>>>> just a
>>>>>>>> war file deployed in glassfish (atually I am debugging in Eclipse).
>>>>>>>>
>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>> but
>>>>>>>> it
>>>>>>>> did
>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>> BundleActivator.start
>>>>>>>> method) . I suspect I might be behind on the build. I will pick up
>>>>>>>> the
>>>>>>>> latest nightly today.
>>>>>>>>
>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>> from
>>>>>>>> the
>>>>>>>> app context. But I cannot cast it to the right type. I still do not
>>>>>>>> know
>>>>>>>> an
>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>
>>>>>>>> Thanks for your help.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Sahoo wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Paul,
>>>>>>>>>
>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>> OSGi
>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>> automatically
>>>>>>>>> started when server starts. Please use the latest nightly build as
>>>>>>>>> I
>>>>>>>>> fixed an important bug around this.
>>>>>>>>>
>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can you
>>>>>>>>> tell
>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>> thing?
>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>
>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>> object.
>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>> Habitat.
>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1 and
>>>>>>>>> I2,
>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Sahoo
>>>>>>>>>
>>>>>>>>> paulbrickell wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>> fundamental
>>>>>>>>>> issues understanding the Glassfish v3 architecture and could use a
>>>>>>>>>> pointer.
>>>>>>>>>>
>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>> e.g.
>>>>>>>>>>
>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>
>>>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>>>> which
>>>>>>>>>> I
>>>>>>>>>> can
>>>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>>>> bundle
>>>>>>>>>> and
>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>> start-up
>>>>>>>>>> time.
>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>> something.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>> have
>>>>>>>>>> deployed
>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs do
>>>>>>>>>> not
>>>>>>>>>> really cover this, which leads me to believe I am doing something
>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>
>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>> static
>>>>>>>>>> way
>>>>>>>>>> to
>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>> Grizzly?
>>>>>>>>>>
>>>>>>>>>> I have tried this....
>>>>>>>>>>
>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>> Object habitat =
>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>
>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>> bundle
>>>>>>>>>> is
>>>>>>>>>> an
>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I navigate
>>>>>>>>>> to
>>>>>>>>>> my
>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there a
>>>>>>>>>> maven
>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem to
>>>>>>>>>> find
>>>>>>>>>> it
>>>>>>>>>> anywhere.
>>>>>>>>>>
>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>> Paul B.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Thats great I love choices.=)

I will have another look at this tomorrow. Given the web service issue I
will hack together a simple servlet app to try it out.

I really would like to use the resource injection approach. very elegant.

Thanks again for your help with this. Great community support, very much
appreciated.
Paul B.

Sahoo wrote:
>
> I understand very well you are not developing a HK2 bundle. You don't
> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
> understanding is you are registering some service with interface
> MyAPI.class in the OSGi service registry. as I told you, we
> automatically register it with Habitat under contract called
> MyAPI.class. Hope this is clear. Since you have access to Habitat from
> your web app, you can access the service by using Habitat.getByContract().
>
> About your deployment failure, that seems unrelated. Looks like some
> broken web service functionality.
>
> Thanks,
> Sahoo
>
> paulbrickell wrote:
>> Sahoo,
>>
>> Just want to check I am doing the right thing here.
>>
>> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
>> this bundle annotated with Contract.
>>
>> I have taken the latest nightly build and put my bundle in the
>> autodeploy-bundles directory. When I start Glassfish I see logging from
>> bundle. So that's good.
>>
>> I am having problems deploying my web application into this server. When
>> I
>> deploy It I get an error...
>>
>> cannot Deploy testservice
>> Deployment Error for module: test-service: Exception while loading the
>> app
>> : java.lang.Exception: java.lang.IllegalStateException:
>> ContainerBase.addChild: start: LifecycleException:
>> java.lang.ClassCastException:
>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>> javax.servlet.Servlet
>>
>> Not sure what this all about. Will continue investigating.
>>
>> Regards,
>> Paul B.
>>
>>
>> Sahoo wrote:
>>
>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>> Habitat.getByContract(). If at all you have to iterate over all the
>>> implementations of a contract, you should use
>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>> getAllByType() is not so user friendly. In HK2, type means
>>> implementation type!
>>>
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> Sahoo,
>>>>
>>>> You right of course.
>>>>
>>>> Anyhoo, using that repository and building my war gives me no
>>>> compilation
>>>> problems.
>>>>
>>>> My code is now doing this...
>>>>
>>>> MessageContext mc = _wsContext.getMessageContext();
>>>> ServletContext sCtx = (ServletContext)
>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>> Habitat habitat = (Habitat)
>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>
>>>> This works OK, but I get a zero length collection. I will get the
>>>> latest
>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>> suggested.
>>>>
>>>> I will let you know how I get on.
>>>>
>>>> Thanks again,
>>>> Paul B.
>>>>
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> May be my understanding of our maven repositories are wrong, but
>>>>> AFAIK,
>>>>> only artifacts produced by GlassFish build should go to
>>>>>
>>>>> http://download.java.net/maven/glassfish/,
>>>>>
>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> but, did find it in...
>>>>>>
>>>>>> http://download.java.net/maven/glassfish/
>>>>>>
>>>>>>
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Sahoo,
>>>>>>>
>>>>>>> Really appreciate your help.
>>>>>>>
>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>> repositories you listed.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Paul B.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Sahoo wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>
>>>>>>>> You should be able to do this in your code:
>>>>>>>>
>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>
>>>>>>>>
>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>>> set
>>>>>>>> up your maven dependency like this:
>>>>>>>>
>>>>>>>>
>>>>>>>> com.sun.enterprise
>>>>>>>> hk2
>>>>>>>> RELEASE
>>>>>>>> provided
>>>>>>>>
>>>>>>>>
>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sahoo
>>>>>>>>
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Sahoo,
>>>>>>>>>
>>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>>> It's
>>>>>>>>> just a
>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>> Eclipse).
>>>>>>>>>
>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>>> but
>>>>>>>>> it
>>>>>>>>> did
>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>> BundleActivator.start
>>>>>>>>> method) . I suspect I might be behind on the build. I will pick up
>>>>>>>>> the
>>>>>>>>> latest nightly today.
>>>>>>>>>
>>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>>> from
>>>>>>>>> the
>>>>>>>>> app context. But I cannot cast it to the right type. I still do
>>>>>>>>> not
>>>>>>>>> know
>>>>>>>>> an
>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>
>>>>>>>>> Thanks for your help.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sahoo wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Paul,
>>>>>>>>>>
>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>>> OSGi
>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>> automatically
>>>>>>>>>> started when server starts. Please use the latest nightly build
>>>>>>>>>> as
>>>>>>>>>> I
>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>
>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can
>>>>>>>>>> you
>>>>>>>>>> tell
>>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>>> thing?
>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>
>>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>>> object.
>>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>>> Habitat.
>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1
>>>>>>>>>> and
>>>>>>>>>> I2,
>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Sahoo
>>>>>>>>>>
>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>>> fundamental
>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could use
>>>>>>>>>>> a
>>>>>>>>>>> pointer.
>>>>>>>>>>>
>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>> e.g.
>>>>>>>>>>>
>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>
>>>>>>>>>>> I see this bundle starting and all is well. It opens a socket to
>>>>>>>>>>> which
>>>>>>>>>>> I
>>>>>>>>>>> can
>>>>>>>>>>> connect and exchange data, which is nice. The reason I created a
>>>>>>>>>>> bundle
>>>>>>>>>>> and
>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>> start-up
>>>>>>>>>>> time.
>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>> something.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>>> have
>>>>>>>>>>> deployed
>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs
>>>>>>>>>>> do
>>>>>>>>>>> not
>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>> something
>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>
>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>> static
>>>>>>>>>>> way
>>>>>>>>>>> to
>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>> Grizzly?
>>>>>>>>>>>
>>>>>>>>>>> I have tried this....
>>>>>>>>>>>
>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>> Object habitat =
>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>
>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>>> bundle
>>>>>>>>>>> is
>>>>>>>>>>> an
>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>> navigate
>>>>>>>>>>> to
>>>>>>>>>>> my
>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there
>>>>>>>>>>> a
>>>>>>>>>>> maven
>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem
>>>>>>>>>>> to
>>>>>>>>>>> find
>>>>>>>>>>> it
>>>>>>>>>>> anywhere.
>>>>>>>>>>>
>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>> Paul B.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

A quick progress report.

I am using version 0.3.9 of HK2 maven plugin to build an HK2 module.
Once I have a bundle jar I copy it to the
glassfishv3/glassfish/domains/domain1/autodeploy directory and restart my
server.

Currently the bundle will not start, and the following stack trace is
logged...

SEVERE: Error during deployment : Not able to locate a unique module by name
com.sun.enterprise:hk2
com.sun.enterprise.module.ResolveError: Not able to locate a unique module
by name com.sun.enterprise:hk2
at
com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl.createApplicationParentCL(ClassLoaderHierarchyImpl.java:147)
at
org.glassfish.deployment.common.DeploymentContextImpl.createClassLoaders(DeploymentContextImpl.java:170)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:209)
at
com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:172)
at
org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:249)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:424)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
at
com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:154)
at
org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:121)
at
org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:529)
at
org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:415)
at
org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:347)
at
org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:332)
at
org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:200)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)

Still trying.

paulbrickell wrote:
>
> Thats great I love choices.=)
>
> I will have another look at this tomorrow. Given the web service issue I
> will hack together a simple servlet app to try it out.
>
> I really would like to use the resource injection approach. very elegant.
>
> Thanks again for your help with this. Great community support, very much
> appreciated.
> Paul B.
>
>
> Sahoo wrote:
>>
>> I understand very well you are not developing a HK2 bundle. You don't
>> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
>> understanding is you are registering some service with interface
>> MyAPI.class in the OSGi service registry. as I told you, we
>> automatically register it with Habitat under contract called
>> MyAPI.class. Hope this is clear. Since you have access to Habitat from
>> your web app, you can access the service by using
>> Habitat.getByContract().
>>
>> About your deployment failure, that seems unrelated. Looks like some
>> broken web service functionality.
>>
>> Thanks,
>> Sahoo
>>
>> paulbrickell wrote:
>>> Sahoo,
>>>
>>> Just want to check I am doing the right thing here.
>>>
>>> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
>>> this bundle annotated with Contract.
>>>
>>> I have taken the latest nightly build and put my bundle in the
>>> autodeploy-bundles directory. When I start Glassfish I see logging from
>>> bundle. So that's good.
>>>
>>> I am having problems deploying my web application into this server. When
>>> I
>>> deploy It I get an error...
>>>
>>> cannot Deploy testservice
>>> Deployment Error for module: test-service: Exception while loading the
>>> app
>>> : java.lang.Exception: java.lang.IllegalStateException:
>>> ContainerBase.addChild: start: LifecycleException:
>>> java.lang.ClassCastException:
>>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>>> javax.servlet.Servlet
>>>
>>> Not sure what this all about. Will continue investigating.
>>>
>>> Regards,
>>> Paul B.
>>>
>>>
>>> Sahoo wrote:
>>>
>>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>>> Habitat.getByContract(). If at all you have to iterate over all the
>>>> implementations of a contract, you should use
>>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>>> getAllByType() is not so user friendly. In HK2, type means
>>>> implementation type!
>>>>
>>>> Sahoo
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>> Sahoo,
>>>>>
>>>>> You right of course.
>>>>>
>>>>> Anyhoo, using that repository and building my war gives me no
>>>>> compilation
>>>>> problems.
>>>>>
>>>>> My code is now doing this...
>>>>>
>>>>> MessageContext mc = _wsContext.getMessageContext();
>>>>> ServletContext sCtx = (ServletContext)
>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>> Habitat habitat = (Habitat)
>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>>
>>>>> This works OK, but I get a zero length collection. I will get the
>>>>> latest
>>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>>> suggested.
>>>>>
>>>>> I will let you know how I get on.
>>>>>
>>>>> Thanks again,
>>>>> Paul B.
>>>>>
>>>>>
>>>>>
>>>>> Sahoo wrote:
>>>>>
>>>>>
>>>>>> May be my understanding of our maven repositories are wrong, but
>>>>>> AFAIK,
>>>>>> only artifacts produced by GlassFish build should go to
>>>>>>
>>>>>> http://download.java.net/maven/glassfish/,
>>>>>>
>>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>>
>>>>>> Thanks,
>>>>>> Sahoo
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>> but, did find it in...
>>>>>>>
>>>>>>> http://download.java.net/maven/glassfish/
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Sahoo,
>>>>>>>>
>>>>>>>> Really appreciate your help.
>>>>>>>>
>>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>>> repositories you listed.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Paul B.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Sahoo wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>>
>>>>>>>>> You should be able to do this in your code:
>>>>>>>>>
>>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>>>> set
>>>>>>>>> up your maven dependency like this:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> com.sun.enterprise
>>>>>>>>> hk2
>>>>>>>>> RELEASE
>>>>>>>>> provided
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Sahoo
>>>>>>>>>
>>>>>>>>> paulbrickell wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Sahoo,
>>>>>>>>>>
>>>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>>>> It's
>>>>>>>>>> just a
>>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>>> Eclipse).
>>>>>>>>>>
>>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>>>> but
>>>>>>>>>> it
>>>>>>>>>> did
>>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>>> BundleActivator.start
>>>>>>>>>> method) . I suspect I might be behind on the build. I will pick
>>>>>>>>>> up
>>>>>>>>>> the
>>>>>>>>>> latest nightly today.
>>>>>>>>>>
>>>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>>>> from
>>>>>>>>>> the
>>>>>>>>>> app context. But I cannot cast it to the right type. I still do
>>>>>>>>>> not
>>>>>>>>>> know
>>>>>>>>>> an
>>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>>
>>>>>>>>>> Thanks for your help.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Paul,
>>>>>>>>>>>
>>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>>>> OSGi
>>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>>> automatically
>>>>>>>>>>> started when server starts. Please use the latest nightly build
>>>>>>>>>>> as
>>>>>>>>>>> I
>>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>>
>>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can
>>>>>>>>>>> you
>>>>>>>>>>> tell
>>>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>>>> thing?
>>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>>
>>>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>>>> object.
>>>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>>>> Habitat.
>>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1
>>>>>>>>>>> and
>>>>>>>>>>> I2,
>>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Sahoo
>>>>>>>>>>>
>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>>>> fundamental
>>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could
>>>>>>>>>>>> use a
>>>>>>>>>>>> pointer.
>>>>>>>>>>>>
>>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>>> e.g.
>>>>>>>>>>>>
>>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>>
>>>>>>>>>>>> I see this bundle starting and all is well. It opens a socket
>>>>>>>>>>>> to
>>>>>>>>>>>> which
>>>>>>>>>>>> I
>>>>>>>>>>>> can
>>>>>>>>>>>> connect and exchange data, which is nice. The reason I created
>>>>>>>>>>>> a
>>>>>>>>>>>> bundle
>>>>>>>>>>>> and
>>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>>> start-up
>>>>>>>>>>>> time.
>>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>>> something.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>>>> have
>>>>>>>>>>>> deployed
>>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs
>>>>>>>>>>>> do
>>>>>>>>>>>> not
>>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>>> something
>>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>>
>>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>>> static
>>>>>>>>>>>> way
>>>>>>>>>>>> to
>>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>>> Grizzly?
>>>>>>>>>>>>
>>>>>>>>>>>> I have tried this....
>>>>>>>>>>>>
>>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>>> Object habitat =
>>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>>
>>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>>>> bundle
>>>>>>>>>>>> is
>>>>>>>>>>>> an
>>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>>> navigate
>>>>>>>>>>>> to
>>>>>>>>>>>> my
>>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there
>>>>>>>>>>>> a
>>>>>>>>>>>> maven
>>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem
>>>>>>>>>>>> to
>>>>>>>>>>>> find
>>>>>>>>>>>> it
>>>>>>>>>>>> anywhere.
>>>>>>>>>>>>
>>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

1. Why are you building a HK2 module?

2. Who told you to drop the HK2 module into autodeploy dir? autodeploy
dir is for Java EE applications only.

Sahoo

paulbrickell wrote:
> A quick progress report.
>
> I am using version 0.3.9 of HK2 maven plugin to build an HK2 module.
> Once I have a bundle jar I copy it to the
> glassfishv3/glassfish/domains/domain1/autodeploy directory and restart my
> server.
>
> Currently the bundle will not start, and the following stack trace is
> logged...
>
> SEVERE: Error during deployment : Not able to locate a unique module by name
> com.sun.enterprise:hk2
> com.sun.enterprise.module.ResolveError: Not able to locate a unique module
> by name com.sun.enterprise:hk2
> at
> com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl.createApplicationParentCL(ClassLoaderHierarchyImpl.java:147)
> at
> org.glassfish.deployment.common.DeploymentContextImpl.createClassLoaders(DeploymentContextImpl.java:170)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:209)
> at
> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:172)
> at
> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:249)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:424)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
> at
> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:154)
> at
> org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:121)
> at
> org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:529)
> at
> org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:415)
> at
> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:347)
> at
> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:332)
> at
> org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:200)
> at java.util.TimerThread.mainLoop(Timer.java:512)
> at java.util.TimerThread.run(Timer.java:462)
>
> Still trying.
>
>
>
> paulbrickell wrote:
>
>> Thats great I love choices.=)
>>
>> I will have another look at this tomorrow. Given the web service issue I
>> will hack together a simple servlet app to try it out.
>>
>> I really would like to use the resource injection approach. very elegant.
>>
>> Thanks again for your help with this. Great community support, very much
>> appreciated.
>> Paul B.
>>
>>
>> Sahoo wrote:
>>
>>> I understand very well you are not developing a HK2 bundle. You don't
>>> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
>>> understanding is you are registering some service with interface
>>> MyAPI.class in the OSGi service registry. as I told you, we
>>> automatically register it with Habitat under contract called
>>> MyAPI.class. Hope this is clear. Since you have access to Habitat from
>>> your web app, you can access the service by using
>>> Habitat.getByContract().
>>>
>>> About your deployment failure, that seems unrelated. Looks like some
>>> broken web service functionality.
>>>
>>> Thanks,
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> Sahoo,
>>>>
>>>> Just want to check I am doing the right thing here.
>>>>
>>>> I am creating an OSGi bundle, not an H2K module. I have no interfaces in
>>>> this bundle annotated with Contract.
>>>>
>>>> I have taken the latest nightly build and put my bundle in the
>>>> autodeploy-bundles directory. When I start Glassfish I see logging from
>>>> bundle. So that's good.
>>>>
>>>> I am having problems deploying my web application into this server. When
>>>> I
>>>> deploy It I get an error...
>>>>
>>>> cannot Deploy testservice
>>>> Deployment Error for module: test-service: Exception while loading the
>>>> app
>>>> : java.lang.Exception: java.lang.IllegalStateException:
>>>> ContainerBase.addChild: start: LifecycleException:
>>>> java.lang.ClassCastException:
>>>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>>>> javax.servlet.Servlet
>>>>
>>>> Not sure what this all about. Will continue investigating.
>>>>
>>>> Regards,
>>>> Paul B.
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>
>>>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>>>> Habitat.getByContract(). If at all you have to iterate over all the
>>>>> implementations of a contract, you should use
>>>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>>>> getAllByType() is not so user friendly. In HK2, type means
>>>>> implementation type!
>>>>>
>>>>> Sahoo
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>
>>>>>> Sahoo,
>>>>>>
>>>>>> You right of course.
>>>>>>
>>>>>> Anyhoo, using that repository and building my war gives me no
>>>>>> compilation
>>>>>> problems.
>>>>>>
>>>>>> My code is now doing this...
>>>>>>
>>>>>> MessageContext mc = _wsContext.getMessageContext();
>>>>>> ServletContext sCtx = (ServletContext)
>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>> Habitat habitat = (Habitat)
>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>>>
>>>>>> This works OK, but I get a zero length collection. I will get the
>>>>>> latest
>>>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>>>> suggested.
>>>>>>
>>>>>> I will let you know how I get on.
>>>>>>
>>>>>> Thanks again,
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Sahoo wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> May be my understanding of our maven repositories are wrong, but
>>>>>>> AFAIK,
>>>>>>> only artifacts produced by GlassFish build should go to
>>>>>>>
>>>>>>> http://download.java.net/maven/glassfish/,
>>>>>>>
>>>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sahoo
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> but, did find it in...
>>>>>>>>
>>>>>>>> http://download.java.net/maven/glassfish/
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Sahoo,
>>>>>>>>>
>>>>>>>>> Really appreciate your help.
>>>>>>>>>
>>>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>>>> repositories you listed.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Paul B.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sahoo wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>>>
>>>>>>>>>> You should be able to do this in your code:
>>>>>>>>>>
>>>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you can
>>>>>>>>>> set
>>>>>>>>>> up your maven dependency like this:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> com.sun.enterprise
>>>>>>>>>> hk2
>>>>>>>>>> RELEASE
>>>>>>>>>> provided
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven 1
>>>>>>>>>> repositories either in your pom.xml or in your maven settings.xml.
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Sahoo
>>>>>>>>>>
>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Sahoo,
>>>>>>>>>>>
>>>>>>>>>>> Sorry. You are of course right about the web service deployment.
>>>>>>>>>>> It's
>>>>>>>>>>> just a
>>>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>>>> Eclipse).
>>>>>>>>>>>
>>>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles dir,
>>>>>>>>>>> but
>>>>>>>>>>> it
>>>>>>>>>>> did
>>>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>>>> BundleActivator.start
>>>>>>>>>>> method) . I suspect I might be behind on the build. I will pick
>>>>>>>>>>> up
>>>>>>>>>>> the
>>>>>>>>>>> latest nightly today.
>>>>>>>>>>>
>>>>>>>>>>> As described in my original post I have pulled the Habitat object
>>>>>>>>>>> from
>>>>>>>>>>> the
>>>>>>>>>>> app context. But I cannot cast it to the right type. I still do
>>>>>>>>>>> not
>>>>>>>>>>> know
>>>>>>>>>>> an
>>>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>>>
>>>>>>>>>>> Thanks for your help.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Paul,
>>>>>>>>>>>>
>>>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop your
>>>>>>>>>>>> OSGi
>>>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>>>> automatically
>>>>>>>>>>>> started when server starts. Please use the latest nightly build
>>>>>>>>>>>> as
>>>>>>>>>>>> I
>>>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>>>
>>>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can
>>>>>>>>>>>> you
>>>>>>>>>>>> tell
>>>>>>>>>>>> us how you packaged your web service and how you deployed such a
>>>>>>>>>>>> thing?
>>>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>>>
>>>>>>>>>>>> 3. All the registered OSGi services can be accessed via Habitat
>>>>>>>>>>>> object.
>>>>>>>>>>>> The OSGi service interface names are mapped to contract names in
>>>>>>>>>>>> Habitat.
>>>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements I1
>>>>>>>>>>>> and
>>>>>>>>>>>> I2,
>>>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or I2.class)
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>
>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> I don't know if this is a silly question, but I am having some
>>>>>>>>>>>>> fundamental
>>>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could
>>>>>>>>>>>>> use a
>>>>>>>>>>>>> pointer.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>>>> e.g.
>>>>>>>>>>>>>
>>>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>>>
>>>>>>>>>>>>> I see this bundle starting and all is well. It opens a socket
>>>>>>>>>>>>> to
>>>>>>>>>>>>> which
>>>>>>>>>>>>> I
>>>>>>>>>>>>> can
>>>>>>>>>>>>> connect and exchange data, which is nice. The reason I created
>>>>>>>>>>>>> a
>>>>>>>>>>>>> bundle
>>>>>>>>>>>>> and
>>>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>>>> start-up
>>>>>>>>>>>>> time.
>>>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>>>> something.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Now I want to reference this service from a web service that I
>>>>>>>>>>>>> have
>>>>>>>>>>>>> deployed
>>>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The docs
>>>>>>>>>>>>> do
>>>>>>>>>>>>> not
>>>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>>>> something
>>>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>>>> static
>>>>>>>>>>>>> way
>>>>>>>>>>>>> to
>>>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>>>> Grizzly?
>>>>>>>>>>>>>
>>>>>>>>>>>>> I have tried this....
>>>>>>>>>>>>>
>>>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>>>> Object habitat =
>>>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>>>
>>>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but my
>>>>>>>>>>>>> bundle
>>>>>>>>>>>>> is
>>>>>>>>>>>>> an
>>>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>>>> navigate
>>>>>>>>>>>>> to
>>>>>>>>>>>>> my
>>>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is there
>>>>>>>>>>>>> a
>>>>>>>>>>>>> maven
>>>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot seem
>>>>>>>>>>>>> to
>>>>>>>>>>>>> find
>>>>>>>>>>>>> it
>>>>>>>>>>>>> anywhere.
>>>>>>>>>>>>>
>>>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

1. My preference was always to build an H2K module. I simply could not get it
to work. Given the converation in this thread it seemed it would be worth me
trying this again today. My preference here is marginal, really I am
exploring the alternatives.

2. Ah. I need to use the asadmin tool as Jerome described? I simply
misunderstood this.

Sahoo wrote:
>
> 1. Why are you building a HK2 module?
>
> 2. Who told you to drop the HK2 module into autodeploy dir? autodeploy
> dir is for Java EE applications only.
>
> Sahoo
>
> paulbrickell wrote:
>> A quick progress report.
>>
>> I am using version 0.3.9 of HK2 maven plugin to build an HK2 module.
>> Once I have a bundle jar I copy it to the
>> glassfishv3/glassfish/domains/domain1/autodeploy directory and restart my
>> server.
>>
>> Currently the bundle will not start, and the following stack trace is
>> logged...
>>
>> SEVERE: Error during deployment : Not able to locate a unique module by
>> name
>> com.sun.enterprise:hk2
>> com.sun.enterprise.module.ResolveError: Not able to locate a unique
>> module
>> by name com.sun.enterprise:hk2
>> at
>> com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl.createApplicationParentCL(ClassLoaderHierarchyImpl.java:147)
>> at
>> org.glassfish.deployment.common.DeploymentContextImpl.createClassLoaders(DeploymentContextImpl.java:170)
>> at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:209)
>> at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:172)
>> at
>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:249)
>> at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:424)
>> at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
>> at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
>> at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:154)
>> at
>> org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:121)
>> at
>> org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:529)
>> at
>> org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:415)
>> at
>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:347)
>> at
>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:332)
>> at
>> org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:200)
>> at java.util.TimerThread.mainLoop(Timer.java:512)
>> at java.util.TimerThread.run(Timer.java:462)
>>
>> Still trying.
>>
>>
>>
>> paulbrickell wrote:
>>
>>> Thats great I love choices.=)
>>>
>>> I will have another look at this tomorrow. Given the web service issue I
>>> will hack together a simple servlet app to try it out.
>>>
>>> I really would like to use the resource injection approach. very
>>> elegant.
>>>
>>> Thanks again for your help with this. Great community support, very much
>>> appreciated.
>>> Paul B.
>>>
>>>
>>> Sahoo wrote:
>>>
>>>> I understand very well you are not developing a HK2 bundle. You don't
>>>> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
>>>> understanding is you are registering some service with interface
>>>> MyAPI.class in the OSGi service registry. as I told you, we
>>>> automatically register it with Habitat under contract called
>>>> MyAPI.class. Hope this is clear. Since you have access to Habitat from
>>>> your web app, you can access the service by using
>>>> Habitat.getByContract().
>>>>
>>>> About your deployment failure, that seems unrelated. Looks like some
>>>> broken web service functionality.
>>>>
>>>> Thanks,
>>>> Sahoo
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>> Sahoo,
>>>>>
>>>>> Just want to check I am doing the right thing here.
>>>>>
>>>>> I am creating an OSGi bundle, not an H2K module. I have no interfaces
>>>>> in
>>>>> this bundle annotated with Contract.
>>>>>
>>>>> I have taken the latest nightly build and put my bundle in the
>>>>> autodeploy-bundles directory. When I start Glassfish I see logging
>>>>> from
>>>>> bundle. So that's good.
>>>>>
>>>>> I am having problems deploying my web application into this server.
>>>>> When
>>>>> I
>>>>> deploy It I get an error...
>>>>>
>>>>> cannot Deploy testservice
>>>>> Deployment Error for module: test-service: Exception while loading
>>>>> the
>>>>> app
>>>>> : java.lang.Exception: java.lang.IllegalStateException:
>>>>> ContainerBase.addChild: start: LifecycleException:
>>>>> java.lang.ClassCastException:
>>>>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>>>>> javax.servlet.Servlet
>>>>>
>>>>> Not sure what this all about. Will continue investigating.
>>>>>
>>>>> Regards,
>>>>> Paul B.
>>>>>
>>>>>
>>>>> Sahoo wrote:
>>>>>
>>>>>
>>>>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>>>>> Habitat.getByContract(). If at all you have to iterate over all the
>>>>>> implementations of a contract, you should use
>>>>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>>>>> getAllByType() is not so user friendly. In HK2, type means
>>>>>> implementation type!
>>>>>>
>>>>>> Sahoo
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>> Sahoo,
>>>>>>>
>>>>>>> You right of course.
>>>>>>>
>>>>>>> Anyhoo, using that repository and building my war gives me no
>>>>>>> compilation
>>>>>>> problems.
>>>>>>>
>>>>>>> My code is now doing this...
>>>>>>>
>>>>>>> MessageContext mc = _wsContext.getMessageContext();
>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>> Habitat habitat = (Habitat)
>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>>>>
>>>>>>> This works OK, but I get a zero length collection. I will get the
>>>>>>> latest
>>>>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>>>>> suggested.
>>>>>>>
>>>>>>> I will let you know how I get on.
>>>>>>>
>>>>>>> Thanks again,
>>>>>>> Paul B.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Sahoo wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> May be my understanding of our maven repositories are wrong, but
>>>>>>>> AFAIK,
>>>>>>>> only artifacts produced by GlassFish build should go to
>>>>>>>>
>>>>>>>> http://download.java.net/maven/glassfish/,
>>>>>>>>
>>>>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sahoo
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> but, did find it in...
>>>>>>>>>
>>>>>>>>> http://download.java.net/maven/glassfish/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> paulbrickell wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Sahoo,
>>>>>>>>>>
>>>>>>>>>> Really appreciate your help.
>>>>>>>>>>
>>>>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>>>>> repositories you listed.
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Paul B.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>>>>
>>>>>>>>>>> You should be able to do this in your code:
>>>>>>>>>>>
>>>>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you
>>>>>>>>>>> can
>>>>>>>>>>> set
>>>>>>>>>>> up your maven dependency like this:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> com.sun.enterprise
>>>>>>>>>>> hk2
>>>>>>>>>>> RELEASE
>>>>>>>>>>> provided
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and maven
>>>>>>>>>>> 1
>>>>>>>>>>> repositories either in your pom.xml or in your maven
>>>>>>>>>>> settings.xml.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Sahoo
>>>>>>>>>>>
>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Sahoo,
>>>>>>>>>>>>
>>>>>>>>>>>> Sorry. You are of course right about the web service
>>>>>>>>>>>> deployment.
>>>>>>>>>>>> It's
>>>>>>>>>>>> just a
>>>>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>>>>> Eclipse).
>>>>>>>>>>>>
>>>>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles
>>>>>>>>>>>> dir,
>>>>>>>>>>>> but
>>>>>>>>>>>> it
>>>>>>>>>>>> did
>>>>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>>>>> BundleActivator.start
>>>>>>>>>>>> method) . I suspect I might be behind on the build. I will pick
>>>>>>>>>>>> up
>>>>>>>>>>>> the
>>>>>>>>>>>> latest nightly today.
>>>>>>>>>>>>
>>>>>>>>>>>> As described in my original post I have pulled the Habitat
>>>>>>>>>>>> object
>>>>>>>>>>>> from
>>>>>>>>>>>> the
>>>>>>>>>>>> app context. But I cannot cast it to the right type. I still do
>>>>>>>>>>>> not
>>>>>>>>>>>> know
>>>>>>>>>>>> an
>>>>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks for your help.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Paul,
>>>>>>>>>>>>>
>>>>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop
>>>>>>>>>>>>> your
>>>>>>>>>>>>> OSGi
>>>>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>>>>> automatically
>>>>>>>>>>>>> started when server starts. Please use the latest nightly
>>>>>>>>>>>>> build
>>>>>>>>>>>>> as
>>>>>>>>>>>>> I
>>>>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>>>>
>>>>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly? Can
>>>>>>>>>>>>> you
>>>>>>>>>>>>> tell
>>>>>>>>>>>>> us how you packaged your web service and how you deployed such
>>>>>>>>>>>>> a
>>>>>>>>>>>>> thing?
>>>>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>>>>
>>>>>>>>>>>>> 3. All the registered OSGi services can be accessed via
>>>>>>>>>>>>> Habitat
>>>>>>>>>>>>> object.
>>>>>>>>>>>>> The OSGi service interface names are mapped to contract names
>>>>>>>>>>>>> in
>>>>>>>>>>>>> Habitat.
>>>>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements
>>>>>>>>>>>>> I1
>>>>>>>>>>>>> and
>>>>>>>>>>>>> I2,
>>>>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or
>>>>>>>>>>>>> I2.class)
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>>
>>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> I don't know if this is a silly question, but I am having
>>>>>>>>>>>>>> some
>>>>>>>>>>>>>> fundamental
>>>>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could
>>>>>>>>>>>>>> use a
>>>>>>>>>>>>>> pointer.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>>>>> e.g.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I see this bundle starting and all is well. It opens a socket
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> which
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>> can
>>>>>>>>>>>>>> connect and exchange data, which is nice. The reason I
>>>>>>>>>>>>>> created
>>>>>>>>>>>>>> a
>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>>>>> start-up
>>>>>>>>>>>>>> time.
>>>>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>>>>> something.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Now I want to reference this service from a web service that
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>> have
>>>>>>>>>>>>>> deployed
>>>>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The
>>>>>>>>>>>>>> docs
>>>>>>>>>>>>>> do
>>>>>>>>>>>>>> not
>>>>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>>>>> something
>>>>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>>>>> static
>>>>>>>>>>>>>> way
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>>>>> Grizzly?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I have tried this....
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>>>>> Object habitat =
>>>>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but
>>>>>>>>>>>>>> my
>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>> is
>>>>>>>>>>>>>> an
>>>>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>>>>> navigate
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> my
>>>>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is
>>>>>>>>>>>>>> there
>>>>>>>>>>>>>> a
>>>>>>>>>>>>>> maven
>>>>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot
>>>>>>>>>>>>>> seem
>>>>>>>>>>>>>> to
>>>>>>>>>>>>>> find
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>> anywhere.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>> users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

OK, I just don't get this.

I have a maven project. In this project I have an interface annotated as
Contract. I have a class that implements this interface annotated as
Service.

This class also implements ModuleStartup.

I use the maven-h2k plugin and create an h2k-jar.

1.What do I do with this module jar?
2. Would I expect the @Resource annotation to be able to inject an instance
of my service?

paulbrickell wrote:
>
> 1. My preference was always to build an H2K module. I simply could not get
> it to work. Given the converation in this thread it seemed it would be
> worth me trying this again today. My preference here is marginal, really I
> am exploring the alternatives.
>
> 2. Ah. I need to use the asadmin tool as Jerome described? I simply
> misunderstood this.
>
>
>
>
> Sahoo wrote:
>>
>> 1. Why are you building a HK2 module?
>>
>> 2. Who told you to drop the HK2 module into autodeploy dir? autodeploy
>> dir is for Java EE applications only.
>>
>> Sahoo
>>
>> paulbrickell wrote:
>>> A quick progress report.
>>>
>>> I am using version 0.3.9 of HK2 maven plugin to build an HK2 module.
>>> Once I have a bundle jar I copy it to the
>>> glassfishv3/glassfish/domains/domain1/autodeploy directory and restart
>>> my
>>> server.
>>>
>>> Currently the bundle will not start, and the following stack trace is
>>> logged...
>>>
>>> SEVERE: Error during deployment : Not able to locate a unique module by
>>> name
>>> com.sun.enterprise:hk2
>>> com.sun.enterprise.module.ResolveError: Not able to locate a unique
>>> module
>>> by name com.sun.enterprise:hk2
>>> at
>>> com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl.createApplicationParentCL(ClassLoaderHierarchyImpl.java:147)
>>> at
>>> org.glassfish.deployment.common.DeploymentContextImpl.createClassLoaders(DeploymentContextImpl.java:170)
>>> at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:209)
>>> at
>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:172)
>>> at
>>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:249)
>>> at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:424)
>>> at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
>>> at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
>>> at
>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:154)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:121)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:529)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:415)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:347)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:332)
>>> at
>>> org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:200)
>>> at java.util.TimerThread.mainLoop(Timer.java:512)
>>> at java.util.TimerThread.run(Timer.java:462)
>>>
>>> Still trying.
>>>
>>>
>>>
>>> paulbrickell wrote:
>>>
>>>> Thats great I love choices.=)
>>>>
>>>> I will have another look at this tomorrow. Given the web service issue
>>>> I
>>>> will hack together a simple servlet app to try it out.
>>>>
>>>> I really would like to use the resource injection approach. very
>>>> elegant.
>>>>
>>>> Thanks again for your help with this. Great community support, very
>>>> much
>>>> appreciated.
>>>> Paul B.
>>>>
>>>>
>>>> Sahoo wrote:
>>>>
>>>>> I understand very well you are not developing a HK2 bundle. You don't
>>>>> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
>>>>> understanding is you are registering some service with interface
>>>>> MyAPI.class in the OSGi service registry. as I told you, we
>>>>> automatically register it with Habitat under contract called
>>>>> MyAPI.class. Hope this is clear. Since you have access to Habitat from
>>>>> your web app, you can access the service by using
>>>>> Habitat.getByContract().
>>>>>
>>>>> About your deployment failure, that seems unrelated. Looks like some
>>>>> broken web service functionality.
>>>>>
>>>>> Thanks,
>>>>> Sahoo
>>>>>
>>>>> paulbrickell wrote:
>>>>>
>>>>>> Sahoo,
>>>>>>
>>>>>> Just want to check I am doing the right thing here.
>>>>>>
>>>>>> I am creating an OSGi bundle, not an H2K module. I have no interfaces
>>>>>> in
>>>>>> this bundle annotated with Contract.
>>>>>>
>>>>>> I have taken the latest nightly build and put my bundle in the
>>>>>> autodeploy-bundles directory. When I start Glassfish I see logging
>>>>>> from
>>>>>> bundle. So that's good.
>>>>>>
>>>>>> I am having problems deploying my web application into this server.
>>>>>> When
>>>>>> I
>>>>>> deploy It I get an error...
>>>>>>
>>>>>> cannot Deploy testservice
>>>>>> Deployment Error for module: test-service: Exception while loading
>>>>>> the
>>>>>> app
>>>>>> : java.lang.Exception: java.lang.IllegalStateException:
>>>>>> ContainerBase.addChild: start: LifecycleException:
>>>>>> java.lang.ClassCastException:
>>>>>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>>>>>> javax.servlet.Servlet
>>>>>>
>>>>>> Not sure what this all about. Will continue investigating.
>>>>>>
>>>>>> Regards,
>>>>>> Paul B.
>>>>>>
>>>>>>
>>>>>> Sahoo wrote:
>>>>>>
>>>>>>
>>>>>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>>>>>> Habitat.getByContract(). If at all you have to iterate over all the
>>>>>>> implementations of a contract, you should use
>>>>>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>>>>>> getAllByType() is not so user friendly. In HK2, type means
>>>>>>> implementation type!
>>>>>>>
>>>>>>> Sahoo
>>>>>>>
>>>>>>> paulbrickell wrote:
>>>>>>>
>>>>>>>
>>>>>>>> Sahoo,
>>>>>>>>
>>>>>>>> You right of course.
>>>>>>>>
>>>>>>>> Anyhoo, using that repository and building my war gives me no
>>>>>>>> compilation
>>>>>>>> problems.
>>>>>>>>
>>>>>>>> My code is now doing this...
>>>>>>>>
>>>>>>>> MessageContext mc = _wsContext.getMessageContext();
>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>> Habitat habitat = (Habitat)
>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>>>>>
>>>>>>>> This works OK, but I get a zero length collection. I will get the
>>>>>>>> latest
>>>>>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>>>>>> suggested.
>>>>>>>>
>>>>>>>> I will let you know how I get on.
>>>>>>>>
>>>>>>>> Thanks again,
>>>>>>>> Paul B.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Sahoo wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> May be my understanding of our maven repositories are wrong, but
>>>>>>>>> AFAIK,
>>>>>>>>> only artifacts produced by GlassFish build should go to
>>>>>>>>>
>>>>>>>>> http://download.java.net/maven/glassfish/,
>>>>>>>>>
>>>>>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Sahoo
>>>>>>>>> paulbrickell wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> but, did find it in...
>>>>>>>>>>
>>>>>>>>>> http://download.java.net/maven/glassfish/
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Sahoo,
>>>>>>>>>>>
>>>>>>>>>>> Really appreciate your help.
>>>>>>>>>>>
>>>>>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>>>>>> repositories you listed.
>>>>>>>>>>>
>>>>>>>>>>> Thanks,
>>>>>>>>>>> Paul B.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>>>>>
>>>>>>>>>>>> You should be able to do this in your code:
>>>>>>>>>>>>
>>>>>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you
>>>>>>>>>>>> can
>>>>>>>>>>>> set
>>>>>>>>>>>> up your maven dependency like this:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> com.sun.enterprise
>>>>>>>>>>>> hk2
>>>>>>>>>>>> RELEASE
>>>>>>>>>>>> provided
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and
>>>>>>>>>>>> maven 1
>>>>>>>>>>>> repositories either in your pom.xml or in your maven
>>>>>>>>>>>> settings.xml.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>
>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Sahoo,
>>>>>>>>>>>>>
>>>>>>>>>>>>> Sorry. You are of course right about the web service
>>>>>>>>>>>>> deployment.
>>>>>>>>>>>>> It's
>>>>>>>>>>>>> just a
>>>>>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>>>>>> Eclipse).
>>>>>>>>>>>>>
>>>>>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles
>>>>>>>>>>>>> dir,
>>>>>>>>>>>>> but
>>>>>>>>>>>>> it
>>>>>>>>>>>>> did
>>>>>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>>>>>> BundleActivator.start
>>>>>>>>>>>>> method) . I suspect I might be behind on the build. I will
>>>>>>>>>>>>> pick
>>>>>>>>>>>>> up
>>>>>>>>>>>>> the
>>>>>>>>>>>>> latest nightly today.
>>>>>>>>>>>>>
>>>>>>>>>>>>> As described in my original post I have pulled the Habitat
>>>>>>>>>>>>> object
>>>>>>>>>>>>> from
>>>>>>>>>>>>> the
>>>>>>>>>>>>> app context. But I cannot cast it to the right type. I still
>>>>>>>>>>>>> do
>>>>>>>>>>>>> not
>>>>>>>>>>>>> know
>>>>>>>>>>>>> an
>>>>>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks for your help.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Paul,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop
>>>>>>>>>>>>>> your
>>>>>>>>>>>>>> OSGi
>>>>>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>>>>>> automatically
>>>>>>>>>>>>>> started when server starts. Please use the latest nightly
>>>>>>>>>>>>>> build
>>>>>>>>>>>>>> as
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly?
>>>>>>>>>>>>>> Can
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>> tell
>>>>>>>>>>>>>> us how you packaged your web service and how you deployed
>>>>>>>>>>>>>> such a
>>>>>>>>>>>>>> thing?
>>>>>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> 3. All the registered OSGi services can be accessed via
>>>>>>>>>>>>>> Habitat
>>>>>>>>>>>>>> object.
>>>>>>>>>>>>>> The OSGi service interface names are mapped to contract names
>>>>>>>>>>>>>> in
>>>>>>>>>>>>>> Habitat.
>>>>>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements
>>>>>>>>>>>>>> I1
>>>>>>>>>>>>>> and
>>>>>>>>>>>>>> I2,
>>>>>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or
>>>>>>>>>>>>>> I2.class)
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I don't know if this is a silly question, but I am having
>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>> fundamental
>>>>>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could
>>>>>>>>>>>>>>> use a
>>>>>>>>>>>>>>> pointer.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>>>>>> e.g.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I see this bundle starting and all is well. It opens a
>>>>>>>>>>>>>>> socket
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> which
>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>> connect and exchange data, which is nice. The reason I
>>>>>>>>>>>>>>> created
>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>>>>>> start-up
>>>>>>>>>>>>>>> time.
>>>>>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>>>>>> something.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Now I want to reference this service from a web service that
>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>> have
>>>>>>>>>>>>>>> deployed
>>>>>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The
>>>>>>>>>>>>>>> docs
>>>>>>>>>>>>>>> do
>>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>>>>>> something
>>>>>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>>>>>> static
>>>>>>>>>>>>>>> way
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>>>>>> Grizzly?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I have tried this....
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>>>>>> Object habitat =
>>>>>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but
>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>> an
>>>>>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>>>>>> navigate
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is
>>>>>>>>>>>>>>> there
>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>> maven
>>>>>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot
>>>>>>>>>>>>>>> seem
>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>> find
>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>> anywhere.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>>> users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>> users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

Yes, I expected something like that. You have been trying far too many
things. I didn't understand why you switched to developing a HK2 module.
Secondly @Resource is not expected to work in a HK2 module either.

IIUC, you have an OSGi bundle that exports a service MyAPI.class that
you want to access from another Java EE application. You have been
successful in deployin the OSGi bundle in the autodeploy-bundles dir.
Now, you have to write the following code to access the service from
Java EE app:
/MyAPI myAPI = Habitat.getByContract(MyAPI.class);/

Jerome suggested you to use @Resource instead of looking up the service
using Habitat, but I don't actually know how a pure OSGi service is
mapped to JNDI. So, I can't comment on that.

Sahoo
paulbrickell wrote:
> OK, I just don't get this.
>
> I have a maven project. In this project I have an interface annotated as
> Contract. I have a class that implements this interface annotated as
> Service.
>
> This class also implements ModuleStartup.
>
> I use the maven-h2k plugin and create an h2k-jar.
>
> 1.What do I do with this module jar?
> 2. Would I expect the @Resource annotation to be able to inject an instance
> of my service?
>
>
>
> paulbrickell wrote:
>
>> 1. My preference was always to build an H2K module. I simply could not get
>> it to work. Given the converation in this thread it seemed it would be
>> worth me trying this again today. My preference here is marginal, really I
>> am exploring the alternatives.
>>
>> 2. Ah. I need to use the asadmin tool as Jerome described? I simply
>> misunderstood this.
>>
>>
>>
>>
>> Sahoo wrote:
>>
>>> 1. Why are you building a HK2 module?
>>>
>>> 2. Who told you to drop the HK2 module into autodeploy dir? autodeploy
>>> dir is for Java EE applications only.
>>>
>>> Sahoo
>>>
>>> paulbrickell wrote:
>>>
>>>> A quick progress report.
>>>>
>>>> I am using version 0.3.9 of HK2 maven plugin to build an HK2 module.
>>>> Once I have a bundle jar I copy it to the
>>>> glassfishv3/glassfish/domains/domain1/autodeploy directory and restart
>>>> my
>>>> server.
>>>>
>>>> Currently the bundle will not start, and the following stack trace is
>>>> logged...
>>>>
>>>> SEVERE: Error during deployment : Not able to locate a unique module by
>>>> name
>>>> com.sun.enterprise:hk2
>>>> com.sun.enterprise.module.ResolveError: Not able to locate a unique
>>>> module
>>>> by name com.sun.enterprise:hk2
>>>> at
>>>> com.sun.enterprise.v3.server.ClassLoaderHierarchyImpl.createApplicationParentCL(ClassLoaderHierarchyImpl.java:147)
>>>> at
>>>> org.glassfish.deployment.common.DeploymentContextImpl.createClassLoaders(DeploymentContextImpl.java:170)
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:209)
>>>> at
>>>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:172)
>>>> at
>>>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:249)
>>>> at
>>>> com.sun.enterprise.v3.admin.CommandRunnerImpl$4.execute(CommandRunnerImpl.java:424)
>>>> at
>>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:434)
>>>> at
>>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:521)
>>>> at
>>>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:154)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:121)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:529)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:415)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:347)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:332)
>>>> at
>>>> org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:200)
>>>> at java.util.TimerThread.mainLoop(Timer.java:512)
>>>> at java.util.TimerThread.run(Timer.java:462)
>>>>
>>>> Still trying.
>>>>
>>>>
>>>>
>>>> paulbrickell wrote:
>>>>
>>>>
>>>>> Thats great I love choices.=)
>>>>>
>>>>> I will have another look at this tomorrow. Given the web service issue
>>>>> I
>>>>> will hack together a simple servlet app to try it out.
>>>>>
>>>>> I really would like to use the resource injection approach. very
>>>>> elegant.
>>>>>
>>>>> Thanks again for your help with this. Great community support, very
>>>>> much
>>>>> appreciated.
>>>>> Paul B.
>>>>>
>>>>>
>>>>> Sahoo wrote:
>>>>>
>>>>>
>>>>>> I understand very well you are not developing a HK2 bundle. You don't
>>>>>> have to develop a HK2 bundle - a simple OSGi bundle is good enough. My
>>>>>> understanding is you are registering some service with interface
>>>>>> MyAPI.class in the OSGi service registry. as I told you, we
>>>>>> automatically register it with Habitat under contract called
>>>>>> MyAPI.class. Hope this is clear. Since you have access to Habitat from
>>>>>> your web app, you can access the service by using
>>>>>> Habitat.getByContract().
>>>>>>
>>>>>> About your deployment failure, that seems unrelated. Looks like some
>>>>>> broken web service functionality.
>>>>>>
>>>>>> Thanks,
>>>>>> Sahoo
>>>>>>
>>>>>> paulbrickell wrote:
>>>>>>
>>>>>>
>>>>>>> Sahoo,
>>>>>>>
>>>>>>> Just want to check I am doing the right thing here.
>>>>>>>
>>>>>>> I am creating an OSGi bundle, not an H2K module. I have no interfaces
>>>>>>> in
>>>>>>> this bundle annotated with Contract.
>>>>>>>
>>>>>>> I have taken the latest nightly build and put my bundle in the
>>>>>>> autodeploy-bundles directory. When I start Glassfish I see logging
>>>>>>> from
>>>>>>> bundle. So that's good.
>>>>>>>
>>>>>>> I am having problems deploying my web application into this server.
>>>>>>> When
>>>>>>> I
>>>>>>> deploy It I get an error...
>>>>>>>
>>>>>>> cannot Deploy testservice
>>>>>>> Deployment Error for module: test-service: Exception while loading
>>>>>>> the
>>>>>>> app
>>>>>>> : java.lang.Exception: java.lang.IllegalStateException:
>>>>>>> ContainerBase.addChild: start: LifecycleException:
>>>>>>> java.lang.ClassCastException:
>>>>>>> com.sun.xml.ws.transport.http.servlet.WSServlet cannot be cast to
>>>>>>> javax.servlet.Servlet
>>>>>>>
>>>>>>> Not sure what this all about. Will continue investigating.
>>>>>>>
>>>>>>> Regards,
>>>>>>> Paul B.
>>>>>>>
>>>>>>>
>>>>>>> Sahoo wrote:
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>> Hold on. You are using Habitat.getAllByType(). I asked you to use
>>>>>>>> Habitat.getByContract(). If at all you have to iterate over all the
>>>>>>>> implementations of a contract, you should use
>>>>>>>> Habitat.getAllByContracts(). Oh yes, I understand the method name
>>>>>>>> getAllByType() is not so user friendly. In HK2, type means
>>>>>>>> implementation type!
>>>>>>>>
>>>>>>>> Sahoo
>>>>>>>>
>>>>>>>> paulbrickell wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> Sahoo,
>>>>>>>>>
>>>>>>>>> You right of course.
>>>>>>>>>
>>>>>>>>> Anyhoo, using that repository and building my war gives me no
>>>>>>>>> compilation
>>>>>>>>> problems.
>>>>>>>>>
>>>>>>>>> My code is now doing this...
>>>>>>>>>
>>>>>>>>> MessageContext mc = _wsContext.getMessageContext();
>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>> Habitat habitat = (Habitat)
>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>> Collection apis = habitat.getAllByType(MyAPI.class);
>>>>>>>>>
>>>>>>>>> This works OK, but I get a zero length collection. I will get the
>>>>>>>>> latest
>>>>>>>>> build and try dropping my bundle jar in the autodeploy dir as you
>>>>>>>>> suggested.
>>>>>>>>>
>>>>>>>>> I will let you know how I get on.
>>>>>>>>>
>>>>>>>>> Thanks again,
>>>>>>>>> Paul B.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Sahoo wrote:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> May be my understanding of our maven repositories are wrong, but
>>>>>>>>>> AFAIK,
>>>>>>>>>> only artifacts produced by GlassFish build should go to
>>>>>>>>>>
>>>>>>>>>> http://download.java.net/maven/glassfish/,
>>>>>>>>>>
>>>>>>>>>> but, that appears not to be true. So, go ahead and use that repo.
>>>>>>>>>> Anyway, this is not the core of the problems being discussed here.
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> Sahoo
>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> but, did find it in...
>>>>>>>>>>>
>>>>>>>>>>> http://download.java.net/maven/glassfish/
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Sahoo,
>>>>>>>>>>>>
>>>>>>>>>>>> Really appreciate your help.
>>>>>>>>>>>>
>>>>>>>>>>>> I'm afraid I do not find com.sun.enterprise.hk2 in either of the
>>>>>>>>>>>> repositories you listed.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks,
>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> OK, thanks for clarifying about the deployment part.
>>>>>>>>>>>>>
>>>>>>>>>>>>> You should be able to do this in your code:
>>>>>>>>>>>>>
>>>>>>>>>>>>> org.jvnet.hk2.component.Habitat =
>>>>>>>>>>>>> org.jvnet.hk2.component.Habitat.class.cast(sCtx.getAttribute("org.glassfish.servlet.habitat"));
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> org.jvnet.hk2.component package is part of HK2 project, so you
>>>>>>>>>>>>> can
>>>>>>>>>>>>> set
>>>>>>>>>>>>> up your maven dependency like this:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> com.sun.enterprise
>>>>>>>>>>>>> hk2
>>>>>>>>>>>>> RELEASE
>>>>>>>>>>>>> provided
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> Ensure that you have added http://download.java.net/maven/2 and
>>>>>>>>>>>>> http://download.java.net/maven/1 as additional maven 2 and
>>>>>>>>>>>>> maven 1
>>>>>>>>>>>>> repositories either in your pom.xml or in your maven
>>>>>>>>>>>>> settings.xml.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>>
>>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Sahoo,
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Sorry. You are of course right about the web service
>>>>>>>>>>>>>> deployment.
>>>>>>>>>>>>>> It's
>>>>>>>>>>>>>> just a
>>>>>>>>>>>>>> war file deployed in glassfish (atually I am debugging in
>>>>>>>>>>>>>> Eclipse).
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I did try just dropping the bundle in the autodeploy-bundles
>>>>>>>>>>>>>> dir,
>>>>>>>>>>>>>> but
>>>>>>>>>>>>>> it
>>>>>>>>>>>>>> did
>>>>>>>>>>>>>> not seem to start (I saw none of the logging from my
>>>>>>>>>>>>>> BundleActivator.start
>>>>>>>>>>>>>> method) . I suspect I might be behind on the build. I will
>>>>>>>>>>>>>> pick
>>>>>>>>>>>>>> up
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>> latest nightly today.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> As described in my original post I have pulled the Habitat
>>>>>>>>>>>>>> object
>>>>>>>>>>>>>> from
>>>>>>>>>>>>>> the
>>>>>>>>>>>>>> app context. But I cannot cast it to the right type. I still
>>>>>>>>>>>>>> do
>>>>>>>>>>>>>> not
>>>>>>>>>>>>>> know
>>>>>>>>>>>>>> an
>>>>>>>>>>>>>> appropriate maven dependency I can add to get it.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Thanks for your help.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Sahoo wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Paul,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1. You don't have to modify Felix config file. You can drop
>>>>>>>>>>>>>>> your
>>>>>>>>>>>>>>> OSGi
>>>>>>>>>>>>>>> bundle in domain1/autodeploy-bundles dir and it will be
>>>>>>>>>>>>>>> automatically
>>>>>>>>>>>>>>> started when server starts. Please use the latest nightly
>>>>>>>>>>>>>>> build
>>>>>>>>>>>>>>> as
>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>> fixed an important bug around this.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2. What do you mean by deploying a web service in Grizzly?
>>>>>>>>>>>>>>> Can
>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>> tell
>>>>>>>>>>>>>>> us how you packaged your web service and how you deployed
>>>>>>>>>>>>>>> such a
>>>>>>>>>>>>>>> thing?
>>>>>>>>>>>>>>> Did you really mean GlassFish or Grizzly?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 3. All the registered OSGi services can be accessed via
>>>>>>>>>>>>>>> Habitat
>>>>>>>>>>>>>>> object.
>>>>>>>>>>>>>>> The OSGi service interface names are mapped to contract names
>>>>>>>>>>>>>>> in
>>>>>>>>>>>>>>> Habitat.
>>>>>>>>>>>>>>> e.g., if you have an OSGi service Foo.class which implements
>>>>>>>>>>>>>>> I1
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>> I2,
>>>>>>>>>>>>>>> then you can access it via Habitat.getByContract(I1 or
>>>>>>>>>>>>>>> I2.class)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks,
>>>>>>>>>>>>>>> Sahoo
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> paulbrickell wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I don't know if this is a silly question, but I am having
>>>>>>>>>>>>>>>> some
>>>>>>>>>>>>>>>> fundamental
>>>>>>>>>>>>>>>> issues understanding the Glassfish v3 architecture and could
>>>>>>>>>>>>>>>> use a
>>>>>>>>>>>>>>>> pointer.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I have created a bundle and added an entry in the
>>>>>>>>>>>>>>>> glassfish/felix.conf
>>>>>>>>>>>>>>>> e.g.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> file:///home/me/myworkspace/my-bundle/target/my-bundle-1.0-SNAPSHOT.jar
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I see this bundle starting and all is well. It opens a
>>>>>>>>>>>>>>>> socket
>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> which
>>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>>> can
>>>>>>>>>>>>>>>> connect and exchange data, which is nice. The reason I
>>>>>>>>>>>>>>>> created
>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>> not a H2K module is that I want it to be activated at server
>>>>>>>>>>>>>>>> start-up
>>>>>>>>>>>>>>>> time.
>>>>>>>>>>>>>>>> I could not see a way of doing this with H2K. Maybe I missed
>>>>>>>>>>>>>>>> something.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Now I want to reference this service from a web service that
>>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>>> have
>>>>>>>>>>>>>>>> deployed
>>>>>>>>>>>>>>>> in Grizzly. I simply cannot figure out how to do this. The
>>>>>>>>>>>>>>>> docs
>>>>>>>>>>>>>>>> do
>>>>>>>>>>>>>>>> not
>>>>>>>>>>>>>>>> really cover this, which leads me to believe I am doing
>>>>>>>>>>>>>>>> something
>>>>>>>>>>>>>>>> fundamentally wrong.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Do Felix and Grizzly share any kind of context or is there a
>>>>>>>>>>>>>>>> static
>>>>>>>>>>>>>>>> way
>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> access the Felix services from a web application deployed in
>>>>>>>>>>>>>>>> Grizzly?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I have tried this....
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> wsContext.getMessageContext();
>>>>>>>>>>>>>>>> ServletContext sCtx = (ServletContext)
>>>>>>>>>>>>>>>> mc.get(MessageContext.SERVLET_CONTEXT);
>>>>>>>>>>>>>>>> Object habitat =
>>>>>>>>>>>>>>>> sCtx.getAttribute("org.glassfish.servlet.habitat");
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> This, I believe, gets me a reference to the H2K habitat, but
>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>> bundle
>>>>>>>>>>>>>>>> is
>>>>>>>>>>>>>>>> an
>>>>>>>>>>>>>>>> OSGi bundle deployed in Felix, not an H2K service. Can I
>>>>>>>>>>>>>>>> navigate
>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> my
>>>>>>>>>>>>>>>> bundle through this habitat? Is it right to try? If so is
>>>>>>>>>>>>>>>> there
>>>>>>>>>>>>>>>> a
>>>>>>>>>>>>>>>> maven
>>>>>>>>>>>>>>>> dependency I need to pick up the Habitat class as I cannot
>>>>>>>>>>>>>>>> seem
>>>>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> find
>>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>>> anywhere.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I would appreciate any pointers. TIA.
>>>>>>>>>>>>>>>> Paul B.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>>>> users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>> users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>> users-help@glassfish.dev.java.net
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> ---------------------------------------------------------------------
>>>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>>>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>>> For additional commands, e-mail: users-help@glassfish.dev.java.net
>>>
>>>
>>>
>>>
>>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

paulbrickell

Sahoo,

I thought about this and you are dead right.

I stopped the thrash and worked to a solution. It wasn't quite the way I
intended but I did get there. I am pretty certain that all the problems I
have encountered were of my own making and I really want to thank you,
Jerome and bhakti for your patience.

So, as payback and for the benefit of future generations here is what I did.

1. I created a maven project for an OSGi bundle which I package using the
org.apache.felix/maven-bundle-plugin.
2. I played around with the various configuration elements in this plugin
(in my pom) to import and export the various packages of my bundle and it's
dependencies.
3. I create a BundleActivator class and configured this in the bundle plugin
configuration as well.
4. I put this in the autodeploy-bundle directory of a nightly build
glassfish v3 deployment and started the server.

This all works exactly how I would expect.

5. Create a simple web application with a servlet.
6. Look up the habitat like this..
Habitat habitat = (Habitat)
getServletContext().getAttribute("org.glassfish.servlet.habitat");
7. Lookup my service like this...
MyAPI api = habitat.getByContract(MyAPI.class);

This returned a null reference, so I did this...

8. I register my service in my bundle activator's start method thus...
ctx.registerService(MyAPI.class.getName(), new MyImpl(), new
Properties());
9. Unpacked a clean glass v3 nightly, put my updated bundle in the
autodeploy-bundles directory and redeployed my web application.

Now it all works.

The @Resource injection works for the habitat, I have not tried for MyAPI
just yet. I did not pesue this course because I am still interested in using
v3 prelude and @Resource doesn't seem to work in v3 prelude (I will get to
this in a bit).

Things I am still not sure I have right...

1. The configuration for the maven-bundle-plugin. I have looked at the
generated manifest, but I cannot be sure it is exactly right. There is an
entry which looks like it should export MyAPI, but given my experimentation
I do not believe it gets exported.

2. I do not know how to deploy a new version of bundle into Glassfish. Just
dropping a new jar in the autodeploy-bundles directory? Do I need to use the
asadmin tool to undeploy/deploy? I have tried the first approach (didn't
seem to work), but not the second. I wouldn't be sure how undeploy.

3. I still cannot deploy a web service application to a nightly V3 but that
problem is for another day.

OK taking a step back, I was also interested in how I might make this work
in v3 prelude. I have a project I want to deploy soon and the v3 prelude is
the only v3 that has support available should my client need it (not decided
yet). The timescale for this deployment does not lend itself to a wait for
another supported release.

I did manage to get this working as well, only slightly differently.

1. I placed my bundle jar in the glassfish/modules directory (could be
anywhere I suppose)
2. I edited the felix/conf/config.properties file. In this file there is a
section commented with...

# Auto-start osgi-adapter module, which is our management bundle.
# Also start all its dependencies.

I added the path to my bundle to the bottom of this section. I have not yet
found another way that activates my bundle at server startup in v3 prelude.

3. Deployed both a service and servlet based web application and, using the
web context's looked up the service successfully.

OK, thats me. I hope my experience helps somebody else. If I find solutions
to the outstanding issues I will certainly document them here.

Thanks,
Paul B.
--
View this message in context: http://www.nabble.com/Can-a-web-service-deployed-in-Grizzly-access-Felix...
Sent from the java.net - glassfish users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

Sahoo

See reply inline...
paulbrickell wrote:
> Sahoo,
>
> I thought about this and you are dead right.
>
> I stopped the thrash and worked to a solution. It wasn't quite the way I
> intended but I did get there. I am pretty certain that all the problems I
> have encountered were of my own making and I really want to thank you,
> Jerome and bhakti for your patience.
>
> So, as payback and for the benefit of future generations here is what I did.
>
> 1. I created a maven project for an OSGi bundle which I package using the
> org.apache.felix/maven-bundle-plugin.
> 2. I played around with the various configuration elements in this plugin
> (in my pom) to import and export the various packages of my bundle and it's
> dependencies.
> 3. I create a BundleActivator class and configured this in the bundle plugin
> configuration as well.
> 4. I put this in the autodeploy-bundle directory of a nightly build
> glassfish v3 deployment and started the server.
>
> This all works exactly how I would expect.
>
> 5. Create a simple web application with a servlet.
> 6. Look up the habitat like this..
> Habitat habitat = (Habitat)
> getServletContext().getAttribute("org.glassfish.servlet.habitat");
> 7. Lookup my service like this...
> MyAPI api = habitat.getByContract(MyAPI.class);
>
> This returned a null reference,
This is expected as per on your explanation below. If you didn't
register the service in OSGi, it wasn't available in Habitat.
> so I did this...
>
> 8. I register my service in my bundle activator's start method thus...
> ctx.registerService(MyAPI.class.getName(), new MyImpl(), new
> Properties());
> 9. Unpacked a clean glass v3 nightly, put my updated bundle in the
> autodeploy-bundles directory and redeployed my web application.
>
> Now it all works.
>
>
> The @Resource injection works for the habitat, I have not tried for MyAPI
> just yet. I did not pesue this course because I am still interested in using
> v3 prelude and @Resource doesn't seem to work in v3 prelude (I will get to
> this in a bit).
>
>
> Things I am still not sure I have right...
>
> 1. The configuration for the maven-bundle-plugin. I have looked at the
> generated manifest, but I cannot be sure it is exactly right. There is an
> entry which looks like it should export MyAPI, but given my experimentation
> I do not believe it gets exported.
>
This should be straight forward. Look at
http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html
> 2. I do not know how to deploy a new version of bundle into Glassfish. Just
> dropping a new jar in the autodeploy-bundles directory? Do I need to use the
> asadmin tool to undeploy/deploy? I have tried the first approach (didn't
> seem to work), but not the second. I wouldn't be sure how undeploy.
>
Yes, you can just use cp and rm command to deploy/update and undeploy.
If you overwrite the jar in autodeploy-bundles, it gets updated
immediately. Take a look at
http://weblogs.java.net/blog/ss141213/archive/2009/05/using_filesyste.html.
> 3. I still cannot deploy a web service application to a nightly V3 but that
> problem is for another day.
>
>
>
> OK taking a step back, I was also interested in how I might make this work
> in v3 prelude. I have a project I want to deploy soon and the v3 prelude is
> the only v3 that has support available should my client need it (not decided
> yet). The timescale for this deployment does not lend itself to a wait for
> another supported release.
>
>
I have started to forget what works and what does not work in Prelude. I
am glad you got it working and your approach seems good enough. We have
another release (3.0-Preview) coming up very soon, but I am not sure
about support status of the same. You can ask in a separate thread about it.

Good Luck,
Sahoo
> I did manage to get this working as well, only slightly differently.
>
> 1. I placed my bundle jar in the glassfish/modules directory (could be
> anywhere I suppose)
> 2. I edited the felix/conf/config.properties file. In this file there is a
> section commented with...
>
> # Auto-start osgi-adapter module, which is our management bundle.
> # Also start all its dependencies.
>
> I added the path to my bundle to the bottom of this section. I have not yet
> found another way that activates my bundle at server startup in v3 prelude.
>
> 3. Deployed both a service and servlet based web application and, using the
> web context's looked up the service successfully.
>
>
>
> OK, thats me. I hope my experience helps somebody else. If I find solutions
> to the outstanding issues I will certainly document them here.
>
> Thanks,
> Paul B.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net