vert-x3 / vertx-service-proxy

EventBus Proxy generation
Apache License 2.0
67 stars 58 forks source link

On generated service proxy, Error - unreported exception java.io.UnsupportedEncodingException; must be caught or declared to be thrown #68

Closed deodeveloper closed 6 years ago

deodeveloper commented 6 years ago

Compilation failure with release 3.5.1 On generated service proxy, Error - unreported exception java.io.UnsupportedEncodingException; must be caught or declared to be thrown

generate proxy code -

public void handle(Message msg) { try { ... } catch (Throwable t) { msg.reply(new ServiceException(500, t.getMessage())); throw t; } }

Stacktrace - UserAsyncServiceVertxProxyHandler.java:[339,7] unreported exception java.io.UnsupportedEncodingException; must be caught or declared to be thrown

    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure /Users/admin/Documents/Development/langAppServer/vertxweb/target/generated-sources/annotations/com/bijay/langapp/web/verticles/user/UserAsyncServiceVertxProxyHandler.java:[339,7] unreported exception java.io.UnsupportedEncodingException; must be caught or declared to be thrown

    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:858)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
deodeveloper commented 6 years ago

Finally, I got it.

One of method in the interface was throwing UnsupportedEncodingException. So code generation failed.

Long story short, make sure the service interface methods doesn't throw any checked exception, otherwise code generation fails.

Here is the method in the interface.

void generateQRUrl(User user, Handler<AsyncResult<String>> resultHandler) throws UnsupportedEncodingException;