-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
verticle extends with org.vertx.scala.platform.Verticle failed to deploy #47
Comments
Umm, can you try this?
I think it tries to use Java as a default if you have a class name and don't prefix it. That's why you need to have |
@Narigo If that's the case, I think the |
Ok. I got different error now. At first, I use add "scala" prefix like you said above. It gave me an error.
Then, I added langs.properties to src/main/resources. Note, I already have "io.vertx:lang-scala:0.1.0-SNAPSHOT" in my build.gradle dependencies. After I added langs.properties, now it complains "can't cast to scala's verticle" instead of "can't cast to java's verticle". I did not change SockJSVerticle.
|
I think above problem is due to different classloader in the system. One loads org.vertx.scala.platform.Verticle and the other one loads my verticle. They should be in the same classloader. According to http://stackoverflow.com/a/11945858/772481, maybe Vertx ModuleClassLoader should call super(classpath, platformClassLoader) to pass parent's classloader to URLClassLoader constructor.
|
Here is a simple test case for this issue.
Here is the exception I got.
|
@angeloh Could you create a small project and share it on github to be able to reproduce that problem? |
@Narigo Thank you! I create 3 tests in the following commit. Only 3rd one runs okay. The differences are explained below: 1st: this test case throws "cannot be cast to org.vertx.java.platform.Verticle" error |
Ok, here are my findings: I'm not sure what to do with 1st/2nd test cases. If I prepend a "scala:" right before the deployed verticle name, I get a class cast exception, that it cannot be casted to org.vertx.scala.platform.Verticle - but debug output says that it is. Maybe someone with more inside view can handle this. @raniejade from what I can see, the |
Hi, I'm not sure if it's possible to deploy scala verticles under the current testtools infraestructure (issue #23). But you can use the same trick of the scala test suite. Create a java verticle and add all the needed conversions manually, e.g. class LocalTestVerticle1 extends org.vertx.java.platform.Verticle {
import org.vertx.scala.core.eventbus.EventBus._
lazy val eb:EventBus = EventBus(vertx.eventBus)
...
override def start() {
eb.registerHandler("some-address")(hdl, rst => {
if (!rst.succeeded)
fail()
else
testComplete()
})
}
} look at local "eb" val and it's use. |
Yeah. This is exactly what I did in LocalTestVerticle3. |
Sorry guys for the delay. Just getting around to catching up with this (I've been working on some improvements to be able to run Scala scripts as well as Scala classes). Do we have a fix for this? Do you need me to look into it? |
Can you try this again with the branch of #63 ? I hope everything is fixed with that then as we had a lot of refactorings and class loading stuff changed in vert.x itself. |
This doesn't work in 1.0.0 I'm trying to avoid having a langs.properties file so that I can specify the language implementation in the mod.json and keep each module fully modular. Unfortunately I need to use Ideally when deploying a scala class from within a scala module you wouldn't need to specify the prefix it would just use the current ScalaVerticleFactory |
@brendanator Thanks for the info! I'll look into it and see if we can fix it and release a patch version. |
All, this is a bit tricky, but I might have found a workaround that does not involve langs.properties files. Let me explain the issue first: First of all, the module does not get deployed by the scala specific verticle factory in the first place. Instead, it's vert.x core's DefaultPlatformManager that, given the verticle name, tries to figure what verticle factory it needs to use. Without any hints, it defaults to the Java verticle factory, which leads to the CCE you see. The default can be changed either via langs.properties, or with system properties, with the latter overriding the former. So, the workarounds here are: a) Modify langs.properties so that by default the scala verticle factory is used:
b) Prepend the verticle name with c) Pass the following system properties:
(NOTE: the first system property needs two From a Scala language extension, there's little else we can do to force one verticle factory by default. In the current set up, it's down to Vert.x core to decide what verticle factory to use. The workarounds explained here try to take advantage of the facilities within core to override defaults. |
@brendanator Can you verify if the system property method works for you? |
In the referenced pull request, I'm adding a test that verifies that system property overrides I mentioned in the last comment work as expected. |
Guys, can you verify this? As far as I'm concerned, the workaround I suggested gets rid of this issue. Unless I see an update, I'll be closing this in the next few days. |
Closing this, feel free to reopen if the issue is still present after applying wokaround. |
Conflicts: .gitignore
Conflicts: .gitignore
Conflicts: .gitignore
Backported test to 1.0.x too. |
When testing verticle extends with org.vertx.scala.platform.Verticle, it would throw an exception.
java.lang.ClassCastException: verticles.SockJSVerticle cannot be cast to org.vertx.java.platform.Verticle
Here is my deploy code:
Here is my verticle code
The text was updated successfully, but these errors were encountered: