Skip to content
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

Issue with POST request #214

Closed
alexmacavei opened this issue Jun 6, 2015 · 14 comments

Comments

@alexmacavei
Copy link

commented Jun 6, 2015

Hey there!

I have a POST endpoint like so:

post("/user") { postedUser : User => 
  repo.save(postedUser)
  response.created(postedUser)
}

I'm unfortunantly getting a NoClassDefFoundError:

[CallbackConverter-2] ERROR com.twitter.finagle - A server service  threw an exception
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassFileLookup
    at com.twitter.util.ExecutorServiceFuturePool$$anon$2.run(FuturePool.scala:122) [util-core_2.11-6.24.0.jar:6.24.0]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassFileLookup
    at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.scalaSigFromAttribute(ScalaSig.scala:38) ~[scalap-2.11.6.jar:na]
    at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.parse(ScalaSig.scala:41) ~[scalap-2.11.6.jar:na]
    at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$$anonfun$parseScalaSig$1.apply(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$$anonfun$parseScalaSig$1.apply(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
    at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.parseScalaSig(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.findSym(CaseClassSigParser.scala:106) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.parseConstructorParams(CaseClassSigParser.scala:30) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.jackson.CaseClassField$.createFields(CaseClassField.scala:24) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializer.<init>(FinatraCaseClassDeserializer.scala:39) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializers.findBeanDeserializer(FinatraCaseClassDeserializers.scala:13) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializers.findBeanDeserializer(FinatraCaseClassDeserializers.scala:6) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory._findCustomBeanDeserializer(BeanDeserializerFactory.java:104) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:130) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:399) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:348) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:261) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:241) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:394) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:1404) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.ObjectReader.<init>(ObjectReader.java:186) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.databind.ObjectMapper.reader(ObjectMapper.java:2593) ~[jackson-databind-2.4.4.jar:2.4.4]
    at com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper$class.reader(ScalaObjectMapper.scala:236) ~[jackson-module-scala_2.11-2.4.4.jar:na]
    at com.twitter.finatra.json.modules.FinatraJacksonModule$$anon$1.reader(FinatraJacksonModule.scala:60) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.json.FinatraObjectMapper.reader(FinatraObjectMapper.scala:40) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.FinatraDefaultMessageBodyReader.parse(FinatraDefaultMessageBodyReader.scala:26) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.MessageBodyManager$$anonfun$parse$2.apply(MessageBodyManager.scala:61) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at scala.Option.getOrElse(Option.scala:121) ~[scala-library-2.11.6.jar:na]
    at com.twitter.finatra.http.internal.marshalling.MessageBodyManager.parse(MessageBodyManager.scala:60) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createRequestCallback$1.apply(CallbackConverter.scala:37) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createRequestCallback$1.apply(CallbackConverter.scala:36) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createResponseCallback$3$$anonfun$apply$3.apply(CallbackConverter.scala:57) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createResponseCallback$3$$anonfun$apply$3.apply(CallbackConverter.scala:57) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
    at com.twitter.util.Try$.apply(Try.scala:13) ~[util-core_2.11-6.24.0.jar:6.24.0]
    at com.twitter.util.ExecutorServiceFuturePool$$anon$2.run(FuturePool.scala:115) [util-core_2.11-6.24.0.jar:6.24.0]
    ... 5 common frames omitted
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.util.ClassFileLookup
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_45]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_45]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_45]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_45]
    ... 41 common frames omitted

My User case class is nothing special:

case class User(username: String, password: String, email: String, dateOfBirth: LocalDate)

Using Finatra 2.0.0.M1, Scala 2.11.6 over OpenJDK 8:

openjdk version "1.8.0_45"
OpenJDK Runtime Environment (build 1.8.0_45-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

Maybe I'm missing some Maven stuff or wrong versioning? I mention I already tried with 2.11.4 to no avail.

Thanks a lot!
Alex

@scosenza

This comment has been minimized.

Copy link
Contributor

commented Jun 6, 2015

What build tool are you using?
What dependencies are you including?

-Steve

On Saturday, June 6, 2015, alexmacavei notifications@github.com wrote:

Hey there!

I have a POST endpoint like so:

post("/user") { postedUser : User =>
repo.save(postedUser)
response.created(postedUser)
}

I'm unfortunantly getting a NoClassDefFoundError:

[CallbackConverter-2] ERROR com.twitter.finagle - A server service threw an exception
java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassFileLookup
at com.twitter.util.ExecutorServiceFuturePool$$anon$2.run(FuturePool.scala:122) [util-core_2.11-6.24.0.jar:6.24.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_45]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: java.lang.NoClassDefFoundError: scala/tools/nsc/util/ClassFileLookup
at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.scalaSigFromAttribute(ScalaSig.scala:38) ~[scalap-2.11.6.jar:na]
at scala.tools.scalap.scalax.rules.scalasig.ScalaSigParser$.parse(ScalaSig.scala:41) ~[scalap-2.11.6.jar:na]
at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$$anonfun$parseScalaSig$1.apply(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$$anonfun$parseScalaSig$1.apply(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at scala.Option.map(Option.scala:146) ~[scala-library-2.11.6.jar:na]
at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.parseScalaSig(CaseClassSigParser.scala:93) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.findSym(CaseClassSigParser.scala:106) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.reflection.CaseClassSigParser$.parseConstructorParams(CaseClassSigParser.scala:30) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.jackson.CaseClassField$.createFields(CaseClassField.scala:24) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializer.(FinatraCaseClassDeserializer.scala:39) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializers.findBeanDeserializer(FinatraCaseClassDeserializers.scala:13) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.internal.caseclass.jackson.FinatraCaseClassDeserializers.findBeanDeserializer(FinatraCaseClassDeserializers.scala:6) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory._findCustomBeanDeserializer(BeanDeserializerFactory.java:104) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:130) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:399) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:348) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:261) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:241) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:394) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:1404) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.ObjectReader.(ObjectReader.java:186) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.databind.ObjectMapper.reader(ObjectMapper.java:2593) ~[jackson-databind-2.4.4.jar:2.4.4]
at com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper$class.reader(ScalaObjectMapper.scala:236) ~[jackson-module-scala_2.11-2.4.4.jar:na]
at com.twitter.finatra.json.modules.FinatraJacksonModule$$anon$1.reader(FinatraJacksonModule.scala:60) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.json.FinatraObjectMapper.reader(FinatraObjectMapper.scala:40) ~[finatra-jackson_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.FinatraDefaultMessageBodyReader.parse(FinatraDefaultMessageBodyReader.scala:26) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.MessageBodyManager$$anonfun$parse$2.apply(MessageBodyManager.scala:61) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at scala.Option.getOrElse(Option.scala:121) ~[scala-library-2.11.6.jar:na]
at com.twitter.finatra.http.internal.marshalling.MessageBodyManager.parse(MessageBodyManager.scala:60) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createRequestCallback$1.apply(CallbackConverter.scala:37) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createRequestCallback$1.apply(CallbackConverter.scala:36) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createResponseCallback$3$$anonfun$apply$3.apply(CallbackConverter.scala:57) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.finatra.http.internal.marshalling.CallbackConverter$$anonfun$createResponseCallback$3$$anonfun$apply$3.apply(CallbackConverter.scala:57) ~[finatra-http_2.11-2.0.0.M1.jar:2.0.0.M1]
at com.twitter.util.Try$.apply(Try.scala:13) ~[util-core_2.11-6.24.0.jar:6.24.0]
at com.twitter.util.ExecutorServiceFuturePool$$anon$2.run(FuturePool.scala:115) [util-core_2.11-6.24.0.jar:6.24.0]
... 5 common frames omitted
Caused by: java.lang.ClassNotFoundException: scala.tools.nsc.util.ClassFileLookup
at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_45]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_45]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_45]
... 41 common frames omitted

My User case class is nothing special:

case class User(username: String, password: String, email: String, dateOfBirth: LocalDate)

Using Finatra 2.0.0.M1, Scala 2.11.6 over OpenJDK 8:

openjdk version "1.8.0_45"OpenJDK Runtime Environment (build 1.8.0_45-b14)OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

Maybe I'm missing some Maven stuff or wrong versioning? I mention I
already tried with 2.11.4 to no avail.

Thanks a lot!
Alex


Reply to this email directly or view it on GitHub
#214.

-Steve

Sent from Gmail Mobile

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 6, 2015

Using Maven with these:

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <encoding>UTF-8</encoding>
        <scala.version>2.11.6</scala.version>
        <finatra.version>2.0.0.M1</finatra.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.scala-lang</groupId>
            <artifactId>scala-library</artifactId>
            <version>${scala.version}</version>
        </dependency>

        <dependency>
            <groupId>com.twitter.finatra</groupId>
            <artifactId>finatra-http_2.11</artifactId>
            <version>${finatra.version}</version>
        </dependency>

        <dependency>
            <groupId>com.twitter.finatra</groupId>
            <artifactId>finatra-logback_2.11</artifactId>
            <version>${finatra.version}</version>
        </dependency>

        <dependency>
            <groupId>com.twitter.finatra</groupId>
            <artifactId>finatra-utils_2.11</artifactId>
            <version>${finatra.version}</version>
        </dependency>
    </dependencies>
@scosenza

This comment has been minimized.

Copy link
Contributor

commented Jun 7, 2015

Hi Alex,

Below is a working pom for the finatra-hello-world example (I'll add it to master next week when we sync with our internal repo). The following is configured:

  • Compilation with Java 8 and Scala 2.11
  • scalatest-maven-plugin used to run tests
  • mvn exec:java to run the server locally
  • A deployable server zip file is created in target/finatra-hello-world-package-dist.zip
    • After unzipping, run the server with -help to see the available flags:
java -jar finatra-hello-world-1.0.0-SNAPSHOT.jar -help
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.twitter</groupId>
  <artifactId>finatra-hello-world</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <encoding>UTF-8</encoding>
    <scala.version>2.11.6</scala.version>
    <finatra.version>2.0.0.M1</finatra.version>

    <mainClass>com.twitter.hello.HelloWorldServerMain</mainClass>
    <buildPropertiesPackage>com.twitter.hello</buildPropertiesPackage>
  </properties>

  <dependencies>

    <!-- Scala -->
    <dependency>
      <groupId>org.scala-lang</groupId>
      <artifactId>scala-library</artifactId>
      <version>${scala.version}</version>
    </dependency>

    <!-- Finatra -->
    <dependency>
      <groupId>com.twitter.finatra</groupId>
      <artifactId>finatra-http_2.11</artifactId>
      <version>${finatra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.twitter.finatra</groupId>
      <artifactId>finatra-logback_2.11</artifactId>
      <version>${finatra.version}</version>
    </dependency>

    <!-- Test Deps -->
    <dependency>
      <groupId>com.twitter.finatra</groupId>
      <artifactId>finatra-http_2.11</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
      <version>${finatra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.twitter.inject</groupId>
      <artifactId>inject-core_2.11</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
      <version>${finatra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.twitter.inject</groupId>
      <artifactId>inject-modules_2.11</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
      <version>${finatra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.twitter.inject</groupId>
      <artifactId>inject-app_2.11</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
      <version>${finatra.version}</version>
    </dependency>
    <dependency>
      <groupId>com.twitter.inject</groupId>
      <artifactId>inject-server_2.11</artifactId>
      <scope>test</scope>
      <type>test-jar</type>
      <version>${finatra.version}</version>
    </dependency>

    <dependency>
      <groupId>org.scalatest</groupId>
      <artifactId>scalatest_2.11</artifactId>
      <scope>test</scope>
      <version>2.2.4</version>
    </dependency>
    <dependency>
      <groupId>org.specs2</groupId>
      <artifactId>specs2_2.11</artifactId>
      <scope>test</scope>
      <version>2.3.12</version>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
      <version>1.10.19</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
      <version>4.12</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>${project.artifactId}</finalName>

    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <resource>
        <directory>src/main/webapp</directory>
      </resource>
    </resources>

    <testResources>
      <testResource>
        <directory>config</directory>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
      <testResource>
        <directory>src/test/webapp</directory>
      </testResource>
    </testResources>

    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>scala-maven-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <configuration>
              <recompileMode>incremental</recompileMode>
              <useZincServer>true</useZincServer>
              <args>
                <param>-language:_</param>
                <param>-g:vars</param>
                <param>-unchecked</param>
                <param>-deprecation</param>
                <param>-encoding</param>
                <param>utf8</param>
              </args>
              <javacArgs>
                <javacArg>-target</javacArg>
                <javacArg>8</javacArg>
                <javacArg>-source</javacArg>
                <javacArg>8</javacArg>
              </javacArgs>
            </configuration>
            <goals>
              <goal>add-source</goal>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <configuration>
              <args>
                <param>-language:_</param>
                <param>-g:vars</param>
                <param>-unchecked</param>
                <param>-deprecation</param>
                <param>-encoding</param>
                <param>utf8</param>
              </args>
              <javacArgs>
                <javacArg>-target</javacArg>
                <javacArg>8</javacArg>
                <javacArg>-source</javacArg>
                <javacArg>8</javacArg>
              </javacArgs>
            </configuration>
            <goals>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <jvmArgs>
            <jvmArg>-Xmx2G</jvmArg>
          </jvmArgs>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>1.0</version>
        <configuration>
          <suffixes>Test|Spec</suffixes>
          <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
          <junitxml>.</junitxml>
          <filereports>WDF TestSuite.txt</filereports>
          <stdout>T</stdout>
          <parallel>false</parallel>
          <forkMode>once</forkMode>
          <logForkedProcessCommand>false</logForkedProcessCommand>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2.1</version>
        <dependencies>
          <dependency>
            <groupId>com.twitter</groupId>
            <artifactId>package-dist</artifactId>
            <version>0.0.6</version>
          </dependency>
        </dependencies>
        <configuration>
          <descriptorRefs>
            <descriptorRef>package-dist</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>${mainClass}</mainClass>
            </manifest>
          </archive>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <configuration>
          <mainClass>${mainClass}</mainClass>
          <systemProperties>
            <systemProperty>
              <key>log.access.output</key>
              <value>/dev/stdout</value>
            </systemProperty>
            <systemProperty>
              <key>log.service.output</key>
              <value>/dev/stdout</value>
            </systemProperty>
          </systemProperties>
          <arguments>
            <argument>-log.output=./log/twitter-server.log</argument>
            <argument>-http.port=:8080</argument>
            <argument>-admin.port=:8081</argument>
          </arguments>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.5</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>${mainClass}</mainClass>
              <classpathPrefix>libs/</classpathPrefix>
              <classpathLayoutType>custom</classpathLayoutType>
              <customClasspathLayout>
                ${artifact.groupId}-${artifact.artifactId}-${artifact.version}${dashClassifier?}.${artifact.extension}
              </customClasspathLayout>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.twitter</groupId>
        <artifactId>maven-build-properties-plugin</artifactId>
        <version>0.0.2</version>
        <configuration>
          <buildPropertiesPackage>${buildPropertiesPackage}</buildPropertiesPackage>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>twitter-repo</id>
      <name>twitter-repo</name>
      <url>http://maven.twttr.com</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>twitter-repo</id>
      <name>twitter-repo</name>
      <url>http://maven.twttr.com</url>
    </pluginRepository>
  </pluginRepositories>

</project>
@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 7, 2015

Thanks!
I'm going to try it out and let you know how it goes!

Alex

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 7, 2015

Hi Steve,

Unfortunately I'm getting the exact same issue on POST requests.
GET requests work fine. There must be some problem with my Request object, but I can't seem to figure out what it is.

I've tried building a UserRequest class to pass as query params like so:

case class UserRequest(@QueryParam id: String,
                       @QueryParam username: String,
                       @QueryParam password: String,
                       @QueryParam email: String,
                       @QueryParam @PastTime dateOfBirth: LocalDate) 

I've tried debugging but it doesn't even enter my POST method.
I've moved my UserRequest to a separate file, tried debugging but always fails at ScalaSig.scala(line 38)

  def scalaSigFromAttribute(classFile: ClassFile): Option[ScalaSig] =
    classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse)

I've also tried with regular User case class, to send the json-ized in the HTTP body, and also as UserRequest with query params, but I'm not getting this done.

Any help would be appreciated.

Here's my complete POST method:

  post("/rest/users") { postedUser: UserRequest =>
    userRepo.add(postedUser.toUser)
    val username: String = postedUser.username
    logger.info("Added user " + username + ".")
    response
      .created(postedUser)
      .location("rest/users/" + userRepo.findIdForUsername(username))
  }

Thanks,
Alex

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 7, 2015

1 more thing I noticed in the code:

def scalaSigFromAttribute(classFile: ClassFile): Option[ScalaSig] =
    classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse)

Evaluating classFile.attribute(SCALA_SIG) gives NoClassDefFoundError, but evaluating classFile.attribute("ScalaSig") evaluates fine. Maybe some mysterious issue with scalap?

Thanks,
Alex

@scosenza

This comment has been minimized.

Copy link
Contributor

commented Jun 7, 2015

Can you try compiling with Java 7 and/or Scala 2.10 to see if that works?

Thanks,
Steve

On Sunday, June 7, 2015, alexmacavei notifications@github.com wrote:

1 more thing I noticed in the code:

def scalaSigFromAttribute(classFile: ClassFile): Option[ScalaSig] =
classFile.attribute(SCALA_SIG).map(_.byteCode).map(ScalaSigAttributeParsers.parse)

Evaluating classFile.attribute(SCALA_SIG) gives NoClassDefFoundError, but
evaluating classFile.attribute("ScalaSig") evaluates fine. Maybe some
mysterious issue with scalap?

Thanks,
Alex


Reply to this email directly or view it on GitHub
#214 (comment).

-Steve

Sent from Gmail Mobile

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 7, 2015

I'm going to try it!

Also going to try to add scala-compiler dependency at runtime. Found this on stack overflow:

http://stackoverflow.com/questions/11824881/why-do-i-need-scala-compiler-at-runtime-play2-salat-with-scalap-dependency

I'm not at the computer right now. I'll try it later!

Thanks,
Alex

@Bugagazavr

This comment has been minimized.

Copy link

commented Jun 7, 2015

I have the same problem when i build standalone jar with assembly with sbt

this fix works for me:

just put scala-compiler into libraryDependencies

"org.scala-lang" % "scala-compiler" % scalaVersion.value

and add merge strategy

case PathList("scala", "tools", xs @ _*) => MergeStrategy.last
@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 7, 2015

Worked with adding scala-compiler in the pom. Real weird though...shouldn't probably need to depend on this at runtime.

@Bugagazavr: I'm using Maven myself, and am unsure how/if I should add the merge strategy thingy.

Thanks!

@alexmacavei alexmacavei closed this Jun 7, 2015

@scosenza

This comment has been minimized.

Copy link
Contributor

commented Jun 8, 2015

Sorry for the inconvenience! scala-compiler should not be needed at runtime, so we'll take a look to see what's going on. For some background, internally at Twitter we use the Pants build tool and we're running on Scala 2.10, so we're still in the process of getting the SBT cross build fully working.

@scosenza

This comment has been minimized.

Copy link
Contributor

commented Jun 13, 2015

@alexmacavei @Bugagazavr We've just released 2.0.0.M2 which removes the need for the scala-compiler dependency when using Scala 2.11. We've also updated the Sbt and Maven files in the hello-world example. Please let us know if you have any further problems.

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 14, 2015

That's awesome Steve!

Just removed the compiler dependency and added M2 to finatra version and all works awesomely 👍 :-)

Thanks!
Alex

@alexmacavei

This comment has been minimized.

Copy link
Author

commented Jun 24, 2015

Hi Steve,

One thing I didn't notice about this and I just had some time to test, thanks to an Openshift crash...long story short... the new build requires scala-reflect at runtime now, but only when I run with java -jar. Executing from IDE is fine.

I don't mind this, but just thought I'd let you guys know.

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.