EBProxy not generated

814 views
Skip to first unread message

József Pollák

unread,
Feb 14, 2016, 6:38:10 AM2/14/16
to vert.x
Hello everyone,

I am trying to implement service proxies in a project, though the additional proxy classes are not generated. Also, I am not getting any error/feedback during compile time about what I'm doing wrong.

When I start the application, this is the error I get:
java.lang.IllegalStateException: Cannot find proxyClass: com.github.inventorywatcher.service.ItemServiceVertxEBProxy


My Service interface and the implementation are located here.

My custom POJO used as parameter is here.

This is the verticle I deploy and register my service.

This is the verticle that tries to use the service via the proxy.

Based on the proxy service documentation here I did the following steps:
  • declare vertx-service-proxy as a dependency in my pom (note: I do not want to generate clients in other languages)
  • annotate my service interface with @ProxyGen
  • I register my sevice with ProxyHelper.registerService(...)
  • I get a reference to my proxy in another verticle with ProxyHelper.createProxy(...) (note: the exception occours here)
  • also, I am passing around a custom POJO annotated with @DataObject. This pojo has a no arg constructor, a copyconstructor and a constructor with a single JsonObject as parameter
Could you please point out what I am missing from the picture?
Also, is there any way to enable logging in maven what is happening (or what is _not_ happening) during the proxy generation step?

I am running  vertx from a fat jar, which starts my DeployVerticle. (The main method is only used from the IDE.)

Thanks in advance,
Joci

Julien Viet

unread,
Feb 14, 2016, 7:39:34 AM2/14/16
to ve...@googlegroups.com
Hi,

I think you are missing the annotation processor in the compiler configuration that is necessary to perform generation, look here:


--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/cd6e768d-e464-4082-b7aa-69911ad0970f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

József Pollák

unread,
Feb 14, 2016, 12:23:25 PM2/14/16
to vert.x
Thank you Julien!
I was definitely missing it from my pom. Unfortunately it was not in the documentation, but now it is working!

Julien Viet

unread,
Feb 14, 2016, 12:26:11 PM2/14/16
to ve...@googlegroups.com
you are right it’s an important point, I will add it

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.

Julien Viet

unread,
Feb 15, 2016, 3:44:44 AM2/15/16
to ve...@googlegroups.com
Hi it has been added and Clement has been super reactive to update the website docs : http://vertx.io/docs/vertx-service-proxy/java/#_proxy_creation

pjozsef

unread,
Feb 15, 2016, 10:24:50 AM2/15/16
to vert.x
Awesome! 
Thank you guys a lot for all the help and effort you put into Vert.x. :)

Robin Coe

unread,
Mar 10, 2018, 4:57:31 PM3/10/18
to vert.x
I'm guessing the page was edited and this addition was removed, because it's not there now and I've been banging my head trying to understand why.

Also, the documentation is inconsistent with the naming of the proxy:

Code generation

"Generated proxies and handlers are named after the service class, for example if the service is named MyService the handler is called MyServiceProxyHandler and the proxy is called MyServiceEBProxy."

Proxy creation

"Alternatively, you can use the generated proxy class. The proxy class name is the service interface class name followed by VertxEBProxy. For instance, if your service interface is named SomeDatabaseService, the proxy class is named SomeDatabaseServiceVertxEBProxy."

Also, there's no information about the order of operations to write the proxies.  You can't write the interface with the static helper that creates the EBProxy without first having the source file present.  So, I'm guessing the order of operations is to create the annotated interface without the static helpers, then compile, then return to implement the static methods?  A little more help here would be beneficial to newcomers.

Thanks.

Jez P

unread,
Mar 11, 2018, 9:01:09 AM3/11/18
to vert.x
I see text about annotation processors on that page:-

The codegen annotation processor generates these classes at compilation time. It is a feature of the Java compiler so no extra step is required, it is just a matter of configuring correctly your build:

Just add the io.vertx:vertx-service-proxy:processor dependency to your build.

and

If you want you can use it too with the regular jar but you need then to declare the annotation processor explicitly, for instance in Maven:

along with fragments for relevant dependencies in Gradle/Maven. 

Robin Coe

unread,
Mar 11, 2018, 10:57:39 AM3/11/18
to ve...@googlegroups.com
Yes, the maven dependency is specified but there is no additional information provided about adding the code generator hook into the maven compiler plugin.  The only reference I've seen to that is in the
​ pdf available here,​
http://vertx.io/docs/guide-for-java-devs/
​,​
 and this forum
​ post​
​And without the forum post, I would have missed the reference in book.  ​
It would be more clear if the vertx service proxy documentation,
​because it shouldn't be necessary to read the book to find this very important tidbit.  Beyond this item, my post also referred to the inconsistency in the documentation about the naming of the generated proxy class.  It is, in fact, <Servicename>VertxEBProxy.java and not just <Servicename>EBProxy.  So the documentation in the "Code Generation" section of the guide is incorrect.  An experienced dev can get around these issues but some might give up before finding the answers.

​Also, what ​
I
​learned is that 
once the maven plugin was configured
​​
, the build will compile correctly.  There is no problem referring to the missing proxy before the code is generated. It's a nuance, but knowing that will help new adopters.  

​Something else that I would like to add is that the documentation and github examples haven't been updated to use the ServiceBinder:

ProxyHelper.class
/**
 * @author <a href="http://tfox.org">Tim Fox</a>
 *
 * @deprecated for a more robust proxy creation see: {@link ServiceBinder}
 */

However, the examples and documentation still refer to the deprecated ProxyHelper:
ProxyHelper.registerService(WikiDatabaseService.class, vertx, ready.result(), CONFIG_WIKIDB_QUEUE); (1) startFuture.complete(); 

If the documentation starts getting too far behind the code, adoption will suffer.


​Thanks,
Robin​



--
You received this message because you are subscribed to a topic in the Google Groups "vert.x" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vertx/FISjZagaEsI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vertx+unsubscribe@googlegroups.com.

Jez P

unread,
Mar 11, 2018, 1:31:19 PM3/11/18
to vert.x
I'm sorry, I see this on the page - isn't this the plugin configuration you're talking about?

Anyway, maybe you could submit a PR to the docs to help the guys out, since you presumably know exactly what would have helped you as a new adopter :)

<plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessors> <annotationProcessor>io.vertx.serviceproxy.ServiceProxyProcessor</annotationProcessor> </annotationProcessors> </configuration> </plugin>
To unsubscribe from this group and all its topics, send an email to vertx+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages