@ServiceName not injected

8 views
Skip to first unread message

Charles Moulliard

unread,
Oct 15, 2016, 4:49:52 AM10/15/16
to fabric8
Hi,


@Path("/say")
@ApplicationScoped
public class HelloClientEndpoint {

    private final static String USER = "user";
    private final static String PWD = "password";

    @Inject
    @Protocol("http") @ServiceName("swarm-rest")
    private String helloService;

to resolve the issue as I get a null object for helloService when Swarm is deployed on OpenShift ?

The service is well published

oc get services
NAME              CLUSTER-IP       EXTERNAL-IP                     PORT(S)                   AGE
docker-registry   172.30.165.13    <nodes>                         5000/TCP                  2h
kubernetes        172.30.0.1       <none>                          443/TCP,53/UDP,53/TCP     2h
swarm-rest        172.30.175.186   172.46.234.198,172.46.234.198   80/TCP                    2h

Many thanks in advance for your help

Charles

Roland Huss

unread,
Oct 15, 2016, 5:22:28 AM10/15/16
to fab...@googlegroups.com
Simply use "swarm-rest" as your service name as it gets resolved via DNS:

private String helloService = "swarm-rest";


regards ...
... roland
> <https://github.com/cmoulliard/swarm-openshift/blob/security-new/swarm-client/src/main/java/io/swarm/demo/HelloClientEndpoint.java#L26>)
>
> @Path("/say")
> @ApplicationScoped
> public class HelloClientEndpoint {
>
> private final static String USER = "user";
> private final static String PWD = "password";
>
> @Inject
> @Protocol("http") @ServiceName("swarm-rest")
> private String helloService;
>
> to resolve the issue as I get a null object for helloService when Swarm
> is deployed on OpenShift ?
>
> - deps defined are
> : https://github.com/cmoulliard/swarm-openshift/blob/security-new/swarm-client/pom.xml#L17-L38
> - The service is well published
>
> oc get services
> NAME CLUSTER-IP EXTERNAL-IP
> PORT(S) AGE
> docker-registry 172.30.165.13 <nodes>
> 5000/TCP 2h
> kubernetes 172.30.0.1 <none>
> 443/TCP,53/UDP,53/TCP 2h
> swarm-rest 172.30.175.186 172.46.234.198,172.46.234.198
> 80/TCP 2h
>
> Many thanks in advance for your help
>
> Charles
>
> --
> You received this message because you are subscribed to the Google
> Groups "fabric8" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to fabric8+u...@googlegroups.com
> <mailto:fabric8+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Charles Moulliard

unread,
Oct 15, 2016, 5:32:29 AM10/15/16
to Roland Huss, fab...@googlegroups.com
Many thanks Roland. You saved my last demo ;-)
See you Monday at JavaSi.


> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Charles Moulliard
Apache Committer & PMC / Architect @RedHat
Twitter : @cmoulliard | Blog :  http://cmoulliard.github.io

James Strachan

unread,
Oct 15, 2016, 8:06:40 AM10/15/16
to Charles Moulliard, fabric8


On Saturday, 15 October 2016, Charles Moulliard <ch0...@gmail.com> wrote:
Hi,


@Path("/say")
@ApplicationScoped
public class HelloClientEndpoint {

    private final static String USER = "user";
    private final static String PWD = "password";

    @Inject
    @Protocol("http") @ServiceName("swarm-rest")
    private String helloService;

Try replace those 3 lines with:

   private String helloService = "http://swarm-rest";

which is much simpler code & works with any DI framework and without one too

 

to resolve the issue as I get a null object for helloService when Swarm is deployed on OpenShift ?

The service is well published

oc get services
NAME              CLUSTER-IP       EXTERNAL-IP                     PORT(S)                   AGE
docker-registry   172.30.165.13    <nodes>                         5000/TCP                  2h
kubernetes        172.30.0.1       <none>                          443/TCP,53/UDP,53/TCP     2h
swarm-rest        172.30.175.186   172.46.234.198,172.46.234.198   80/TCP                    2h

Many thanks in advance for your help

Charles

--
You received this message because you are subscribed to the Google Groups "fabric8" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fabric8+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
James
-------
Red Hat

Twitter: @jstrachan
Email: james.s...@gmail.com
Blog: https://medium.com/@jstrachan/

open source microservices platform

Reply all
Reply to author
Forward
0 new messages