NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
dpwrussell
Joined: 21 Nov 2008 Posts: 6
|
Posted: Thu Jun 16, 2011 10:47 pm Post subject: Maven OSGi Declarative Services failure |
|
|
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
|
Posted: Sun Aug 14, 2011 5:49 am Post subject: |
|
|
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: 31
|
Posted: Tue Aug 16, 2011 2:47 pm Post subject: Re: Maven OSGi Declarative Services failure |
|
|
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.
|
Posted: Tue Aug 16, 2011 8:36 pm Post subject: Re: Maven OSGi Declarative Services failure |
|
|
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: 31
|
Posted: Wed Aug 17, 2011 4:28 pm Post subject: Re: Maven OSGi Declarative Services failure |
|
|
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.
|
Posted: Wed Aug 17, 2011 5:26 pm Post subject: Re: Maven OSGi Declarative Services failure |
|
|
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 |
|
 |
|
|
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
|
|