Giter VIP home page Giter VIP logo

Comments (16)

Narigo avatar Narigo commented on June 25, 2024

I get the same error - we both added the entries for scala in langs.properties in Vert.x 2.0.2-final. @galderz can you please have a look at this? Seems like running scripts doesn't really work when using vertx run X ?

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

If you're trying to use latest master, you have to build mod-lang-scala jars locally and copy them over to you have to copy over the jar files. These are the instructions I use (adjust to your own env) when testing scripts with snapshot releases I build locally.

from mod-lang-scala.

Narigo avatar Narigo commented on June 25, 2024

Okay, so after doing this:

./gradlew install
vertx install io.vertx~lang-scala~0.2.0-SNAPSHOT

I don't have the jar files of mod-lang-scala inside its own module dir in sys-mods, even though the .class files are available directly in the module directory (not in lib/ as jars).

So putting these .class files into a jar and adding those into the modules lib directory seems to do the trick.

Why is that? Is this a general Vert.x issue, that it needs the language modules in a really strange format and cannot do that itself on install? Do we have to change something in the gradle build?

Will users have to do this themselves when they try to run Scala code?

from mod-lang-scala.

purplefox avatar purplefox commented on June 25, 2024

You shouldn't have to copy anything manually - perhaps you're not building mod-lang-scala properly with the jar files in it's lib directory?

from mod-lang-scala.

Narigo avatar Narigo commented on June 25, 2024

@purplefox we have the following structure in the module:

lib/
  + scala-library.jar
  + scala-compiler.jar
  + scala-reflect.jar
org/vertx/scala/
  + All the class files in their respective package...
mod.json

It looks like we need to have all the org/vertx/scala/<class-files> in a .jar and put that inside the lib/ directory as well, otherwise it won't work. That's strange that it somehow doesn't use the class files directly. Just tried a JS Script which downloaded lang-rhino and a Groovy Script with lang-groovy: Their modules have the same structure and do not need their class-files (or js scripts) in a jar lying in <mod-name>/lib/<classes-jar>. So something still is wrong with the Scala module and we shouldn't need to copy anything around in it... Guess the interpreter somehow gets the wrong ClassLoader so it doesn't have org.vertx.scala.* available? Or that regex stuff which adds the *.jar files should add the module directory itself, too?

from mod-lang-scala.

purplefox avatar purplefox commented on June 25, 2024

Most probably you have a classloader issue in the mod-lang-scala module. Did you implement the recommendation I made last time about removing the second classloader that was being specifically used for scripts?

from mod-lang-scala.

Narigo avatar Narigo commented on June 25, 2024

Looks like it doesn't have a second class loader anymore. @galderz knows more about the implementation now...

from mod-lang-scala.

purplefox avatar purplefox commented on June 25, 2024

This line looks suspicious to me:

https://github.com/vert-x/mod-lang-scala/blob/master/src/main/scala/org/vertx/scala/lang/ScalaInterpreter.scala#L28

Does this mean it's setting the context class loader to null?

from mod-lang-scala.

purplefox avatar purplefox commented on June 25, 2024

Looks like this assembles the classpath for the interpreter:

https://github.com/vert-x/mod-lang-scala/blob/master/src/main/scala/org/vertx/scala/platform/impl/ScalaVerticleFactory.scala#L126

But it looks strange to me, can't the interpreter just load resources from the context classloader? It seems odd to have to construct it this way...

from mod-lang-scala.

raniejade avatar raniejade commented on June 25, 2024

As far as I know you cant, you have to explicitly set the interpreter's
classpath.

On Thu, Oct 24, 2013 at 7:19 PM, Tim Fox [email protected] wrote:

Looks like this assembles the classpath for the interpreter:

https://github.com/vert-x/mod-lang-scala/blob/master/src/main/scala/org/vertx/scala/platform/impl/ScalaVerticleFactory.scala#L126

But it looks strange to me, can't the interpreter just load resources from
the context classloader? It seems odd to have to construct it this way...


Reply to this email directly or view it on GitHubhttps://github.com//issues/65#issuecomment-26974153
.

Ranie Jade Ramiso
Software Engineer | Open Source Enthusiast | Professional Slacker
Philippines

w: raniejaderamiso.com
e: [email protected]

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

Guys, leave this with me and I'll sort it out :)

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

My fault guys, I messed it up when I refactored the ScalaVerticleFactory to split the interpreter out. PR coming right up...

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

This is very weird. While trying to verify fix for #69 this issue seems to have reappeared :|. This was working with the 2.0.x snapshot, so maybe when we switched to 2.1-M1 something changed in the way Vert.x module classloader. Looking into it...

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

Fixed properly now. Apologies for the inconvenience.

from mod-lang-scala.

 avatar commented on June 25, 2024

I still get this error when using 2.1M2 ?

λ omnivore scala → λ git master → vertx run http/Server.scala
Downloading io.vertxlang-scala0.2.0. Please wait...
Downloading 100%
Module io.vertxlang-scala0.2.0 successfully installed
Compiling http/Server.scala as Scala script
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
:7: error: object scala is not a member of package org.vertx
import org.vertx.scala., org.vertx.scala.core., org.vertx.scala.core.buffer., org.vertx.scala.core.dns., org.vertx.scala.core.eventbus., org.vertx.scala.core.file., org.vertx.scala.core.http., org.vertx.scala.core.json., org.vertx.scala.core.net., org.vertx.scala.core.streams.
^
Script contains compilation errors, or http/Server.scala is a Scala class (pass -Dvertx.scala.interpreter.verbose=true to find out more)
Compiling as a Scala class
/Volumes/data-store/src/vertx-examples/src/raw/scala/http/Server.scala:17: error: expected class or object definition
vertx.createHttpServer.requestHandler { req: HttpServerRequest =>
^
Failed in deploying verticle
java.lang.IllegalArgumentException: Unable to run http/Server.scala as neither Scala script nor Scala class
at org.vertx.scala.platform.impl.ScalaVerticleFactory$$anonfun$1.apply(ScalaVerticleFactory.scala:116)
at org.vertx.scala.platform.impl.ScalaVerticleFactory$$anonfun$1.apply(ScalaVerticleFactory.scala:116)
at scala.Option.getOrElse(Option.scala:120)
at org.vertx.scala.platform.impl.ScalaVerticleFactory.load(ScalaVerticleFactory.scala:115)
at org.vertx.scala.platform.impl.ScalaVerticleFactory.createVerticle(ScalaVerticleFactory.scala:68)
at org.vertx.java.platform.impl.DefaultPlatformManager$19.run(DefaultPlatformManager.java:1540)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:724)

Failed in deploying verticle
java.lang.IllegalArgumentException: Unable to run http/Server.scala as neither Scala script nor Scala class
at org.vertx.scala.platform.impl.ScalaVerticleFactory$$anonfun$1.apply(ScalaVerticleFactory.scala:116)
at org.vertx.scala.platform.impl.ScalaVerticleFactory$$anonfun$1.apply(ScalaVerticleFactory.scala:116)
at scala.Option.getOrElse(Option.scala:120)
at org.vertx.scala.platform.impl.ScalaVerticleFactory.load(ScalaVerticleFactory.scala:115)
at org.vertx.scala.platform.impl.ScalaVerticleFactory.createVerticle(ScalaVerticleFactory.scala:68)
at org.vertx.java.platform.impl.DefaultPlatformManager$19.run(DefaultPlatformManager.java:1540)
at org.vertx.java.core.impl.DefaultContext$3.run(DefaultContext.java:176)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:354)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:353)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101)
at java.lang.Thread.run(Thread.java:724)

from mod-lang-scala.

galderz avatar galderz commented on June 25, 2024

You are using the latest available release, 0.2.0, which is known to have that issue. In the mean time, please do gradle install from master locally and then point conf/lang.properties to the 0.3.0-SNAPSHOT version.

from mod-lang-scala.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.