NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Maven OSGi Declarative Services failure

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
dpwrussell



Joined: 21 Nov 2008
Posts: 6

PostPosted: Thu Jun 16, 2011 10:47 pm    Post subject: Maven OSGi Declarative Services failure Reply with quote

Hi,

I'm trying to get to grips with OSGi with Maven. I've been following: http://netbeans.org/kb/docs/javaee/maven-osgi-declarativeservices.html

All seems to go according to plan until the very end. I deploy the Web Client Application, but:

Code:
HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: PWC1392: Error instantiating servlet class com.mycompany.mavenhellowebclient.HelloClient
root cause

com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class com.mycompany.mavenhellowebclient.HelloClient
root cause

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Env-Prop: com.mycompany.mavenhellowebclient.HelloClient/helloService@Field-Injectable Resource. Class name = com.mycompany.mavenhellowebclient.HelloClient Field name=helloService@java.lang.String@@@ into class com.mycompany.mavenhellowebclient.HelloClient
root cause

javax.naming.NamingException: Lookup failed for 'java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Lookup failed for 'hello-service' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [Root exception is javax.naming.NameNotFoundException: hello-service not found]]
root cause

javax.naming.NamingException: Lookup failed for 'hello-service' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming, com.sun.enterprise.naming.logicalName=java:comp/env/com.mycompany.mavenhellowebclient.HelloClient/helloService} [Root exception is javax.naming.NameNotFoundException: hello-service not found]
root cause

javax.naming.NameNotFoundException: hello-service not found


I've tried going through the procedure twice, on two different computers, on two different platforms. So I'm pretty certain I didn't make a mistake to cause this.

As I'm new to this I'm having a hard time figuring out what's wrong as there are so many unknowns (to me) involved. Maybe it's a Maven problem or an injection problem, I'm really not sure.

Any help would be much appreciated!

As a side note - which if it is a maven problem could be related: In NetBeans when I try an add a dependency, the search feature doesn't seem to work at all. Whatever I type in, it finds no results.

I've uploaded the 3 NetBeans projects in a zip file here.



Cheers
Back to top
aromanelli



Joined: 14 Aug 2011
Posts: 1

PostPosted: Sun Aug 14, 2011 5:49 am    Post subject: Reply with quote

Didn't want to download the zip file because of certificate issues on the link, but I just did the same tutorial, and had the same problem, so I think I know how to solve it for you. Or at least I can describe how I solved it for myself.

Check the HelloImpl.java source file, and see if you have any errors for the annotations @Component and/or @Service, or if you are just missing them completely.

If you have errors, and you are missing the annotation lines, add them, as the tutorial instructs.

If you have errors, but you have the annotation lines, then you need to fix them, so the class will compile correctly. Right-click on the project that HelloImpl is in (mine was called 'MavenHelloService'), select 'Properties', then when a dialog comes up, select the 'Sources' category/option on the left. Then, look towards the bottom-right of the dialog for the 'Source/Binary Format:" drop down, and if the number it is displaying is less than 1.5, change it to 1.5 or 1.6 (I changed it to 1.6).

In a nutshell, annotations did not exist in the earlier version of java, and the NetBeans 7.0.1 IDE creates the project with a default source/binary format level of 1.3, so the class will not compile correctly, with the service name injection/identification, which is done by having the annotations.

Hope this helps.
Back to top
ken.ganfield



Joined: 18 Aug 2008
Posts: 35

PostPosted: Tue Aug 16, 2011 2:47 pm    Post subject: Re: Maven OSGi Declarative Services failure Reply with quote

Yes, definitely confirm that the source level for the projects are set
for 1.5 or better.

Going forward, if you are using GlassFish 3.1 or newer, I would
recommend looking at using CDI and @OSGiService to inject a service as a
much simpler and safer way.

You can take a look at the following draft for steps on how to do this
in NetBeans IDE
http://wiki.netbeans.org/DocsSimpleMavenOsgiCdi

And there are additional links to pages with more information

k

On 1408//11 07:50 , aromanelli wrote:
Quote:
Didn't want to download the zip file because of certificate issues on the link, but I just did the same tutorial, and had the same problem, so I think I know how to solve it for you. Or at least I can describe how I solved it for myself.

Check the HelloImpl.java source file, and see if you have any errors for the annotations @Component and/or @Service, or if you are just missing them completely.

If you have errors, and you are missing the annotation lines, add them, as the tutorial instructs.

If you have errors, but you have the annotation lines, then you need to fix them, so the class will compile correctly. Right-click on the project that HelloImpl is in (mine was called 'MavenHelloService'), select 'Properties', then when a dialog comes up, select the 'Sources' category/option on the left. Then, look towards the bottom-right of the dialog for the 'Source/Binary Format:" drop down, and if the number it is displaying is less than 1.5, change it to 1.5 or 1.6 (I changed it to 1.6).

In a nutshell, annotations did not exist in the earlier version of java, and the NetBeans 7.0.1 IDE creates the project with a default source/binary format level of 1.3, so the class will not compile correctly, with the service name injection/identification, which is done by having the annotations.

Hope this helps.



Back to top
Brad Cox
Posted via mailing list.





PostPosted: Tue Aug 16, 2011 8:36 pm    Post subject: Re: Maven OSGi Declarative Services failure Reply with quote

Ken, will that approach support jaxws servers and clients?

On Tue, Aug 16, 2011 at 10:00 AM, Ken Ganfield <address-removed ([email]address-removed[/email])> wrote:
Quote:
Yes, definitely confirm that the source level for the projects are set for 1.5 or better.

Going forward, if you are using GlassFish 3.1 or newer, I would recommend looking at using CDI and @OSGiService to inject a service as a much simpler and safer way.

You can take a look at the following draft for steps on how to do this in NetBeans IDE
http://wiki.netbeans.org/DocsSimpleMavenOsgiCdi

And there are additional links to pages with more information

k


On 1408//11 07:50 , aromanelli wrote:
Quote:
Didn't want to download the zip file because of certificate issues on the link, but I just did the same tutorial, and had the same problem, so I think I know how to solve it for you.  Or at least I can describe how I solved it for myself.

Check the HelloImpl.java source file, and see if you have any errors for the annotations @Component and/or @Service, or if you are just missing them completely.

If you have errors, and you are missing the annotation lines, add them, as the tutorial instructs.

If you have errors, but you have the annotation lines, then you need to fix them, so the class will compile correctly.  Right-click on the project that HelloImpl is in (mine was called 'MavenHelloService'), select 'Properties', then when a dialog comes up, select the 'Sources' category/option on the left.  Then, look towards the bottom-right of the dialog for the 'Source/Binary Format:" drop down, and if the number it is displaying is less than 1.5, change it to 1.5 or 1.6 (I changed it to 1.6).

In a nutshell, annotations did not exist in the earlier version of java, and the NetBeans 7.0.1 IDE creates the project with a default source/binary format level of 1.3, so the class will not compile correctly, with the service name injection/identification, which is done by having the annotations.

Hope this helps.











--
Cell: 703-594-1883
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111
Back to top
ken.ganfield



Joined: 18 Aug 2008
Posts: 35

PostPosted: Wed Aug 17, 2011 4:28 pm    Post subject: Re: Maven OSGi Declarative Services failure Reply with quote

Assuming that the server supports OSGi, then you should be able to use JAX-WS + CDI + OSGi

Here is an example, but I have not tried it.
http://weblogs.java.net/blog/ss141213/archive/2010/04/08/jax-ws-web-service-osgi-bundle

Would like to know if you do and how it works for you

ken

On 1608//11 21:48 , Brad Cox wrote:
Quote:
Ken, will that approach support jaxws servers and clients?

On Tue, Aug 16, 2011 at 10:00 AM, Ken Ganfield <address-removed ([email]address-removed[/email])> wrote:
Quote:
Yes, definitely confirm that the source level for the projects are set for 1.5 or better.

Going forward, if you are using GlassFish 3.1 or newer, I would recommend looking at using CDI and @OSGiService to inject a service as a much simpler and safer way.

You can take a look at the following draft for steps on how to do this in NetBeans IDE
http://wiki.netbeans.org/DocsSimpleMavenOsgiCdi

And there are additional links to pages with more information

k

On 1408//11 07:50 , aromanelli wrote:
Quote:
Didn't want to download the zip file because of certificate issues on the link, but I just did the same tutorial, and had the same problem, so I think I know how to solve it for you.  Or at least I can describe how I solved it for myself.

Check the HelloImpl.java source file, and see if you have any errors for the annotations @Component and/or @Service, or if you are just missing them completely.

If you have errors, and you are missing the annotation lines, add them, as the tutorial instructs.

If you have errors, but you have the annotation lines, then you need to fix them, so the class will compile correctly.  Right-click on the project that HelloImpl is in (mine was called 'MavenHelloService'), select 'Properties', then when a dialog comes up, select the 'Sources' category/option on the left.  Then, look towards the bottom-right of the dialog for the 'Source/Binary Format:" drop down, and if the number it is displaying is less than 1.5, change it to 1.5 or 1.6 (I changed it to 1.6).

In a nutshell, annotations did not exist in the earlier version of java, and the NetBeans 7.0.1 IDE creates the project with a default source/binary format level of 1.3, so the class will not compile correctly, with the service name injection/identification, which is done by having the annotations.

Hope this helps.











--
Cell: 703-594-1883
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111

Back to top
Brad Cox
Posted via mailing list.





PostPosted: Wed Aug 17, 2011 5:26 pm    Post subject: Re: Maven OSGi Declarative Services failure Reply with quote

Will do. Might be awhile tho; in the middle of something else. But Thanks!!

On Wed, Aug 17, 2011 at 11:41 AM, Ken Ganfield <address-removed ([email]address-removed[/email])> wrote:
Quote:
Assuming that the server supports OSGi, then you should be able to use JAX-WS + CDI + OSGi

Here is an example, but I have not tried it.
http://weblogs.java.net/blog/ss141213/archive/2010/04/08/jax-ws-web-service-osgi-bundle

Would like to know if you do and how it works for you

ken


On 1608//11 21:48 , Brad Cox wrote:
Quote:
Ken, will that approach support jaxws servers and clients?

On Tue, Aug 16, 2011 at 10:00 AM, Ken Ganfield <address-removed ([email]address-removed[/email])> wrote:
Quote:
Yes, definitely confirm that the source level for the projects are set for 1.5 or better.

Going forward, if you are using GlassFish 3.1 or newer, I would recommend looking at using CDI and @OSGiService to inject a service as a much simpler and safer way.

You can take a look at the following draft for steps on how to do this in NetBeans IDE
http://wiki.netbeans.org/DocsSimpleMavenOsgiCdi

And there are additional links to pages with more information

k

On 1408//11 07:50 , aromanelli wrote:
Quote:
Didn't want to download the zip file because of certificate issues on the link, but I just did the same tutorial, and had the same problem, so I think I know how to solve it for you.  Or at least I can describe how I solved it for myself.

Check the HelloImpl.java source file, and see if you have any errors for the annotations @Component and/or @Service, or if you are just missing them completely.

If you have errors, and you are missing the annotation lines, add them, as the tutorial instructs.

If you have errors, but you have the annotation lines, then you need to fix them, so the class will compile correctly.  Right-click on the project that HelloImpl is in (mine was called 'MavenHelloService'), select 'Properties', then when a dialog comes up, select the 'Sources' category/option on the left.  Then, look towards the bottom-right of the dialog for the 'Source/Binary Format:" drop down, and if the number it is displaying is less than 1.5, change it to 1.5 or 1.6 (I changed it to 1.6).

In a nutshell, annotations did not exist in the earlier version of java, and the NetBeans 7.0.1 IDE creates the project with a default source/binary format level of 1.3, so the class will not compile correctly, with the service name injection/identification, which is done by having the annotations.

Hope this helps.











--
Cell: [url=tel:703-594-1883]703-594-1883[/url]
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111









--
Cell: 703-594-1883
Blog: http://bradjcox.blogspot.com
Web: http://virtualschool.edu
Manassas VA 20111
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo