title: Scala: class type required but T found
body: <p>I've found similar issues of this particular problem, however the problem was due to someone trying to instantiate T directly. Here I'm trying to create a trait that is a general interface to extend classes and store them automatically in a database such as Riak using <code>classOf[T]</code>. Using Scala 2.10.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>trait RiakWriteable[T] {
  
    /**
     * bucket name of data in Riak holding class data
     */
    def bucketName: String
  
    /**
     * determine whether secondary indices will be added
     */
    def enable2i: Boolean
  
    /**
     * the actual bucket
     */
    val bucket: Bucket = enable2i match {
      case true =&gt; DB.client.createBucket(bucketName).enableForSearch().execute()
      case false =&gt; DB.client.createBucket(bucketName).disableSearch().execute()
    }
  
    /**
     * register the scala module for Jackson
     */
    val converter = {
      val c = new JSONConverter[T](classOf[T], bucketName)
      JSONConverter.registerJacksonModule(DefaultScalaModule)
      c
    }
  
    /**
     * store operation
     */
    def store = bucket.store(this).withConverter(converter).withRetrier(DB.retrier).execute()
  
    /**
     * fetch operation
     */
    def fetch(id: String): Option[T] = {
      val u = bucket.fetch(id, classOf[T]).withConverter(converter).withRetrier(DB.retrier).r(DB.N_READ).execute()
      u match {
        case null =&gt; None
        case _ =&gt; Some(u)
      }
    }
  
  }
  </code></pre>
  
  <p>Compiler error is <code>class type required but T found</code>. </p>
  
  <p>Example usage (pseudo-code):</p>
  
  <pre><code>class Foo
  
  object Foo extends RiakWriteable[Foo]
  
  Foo.store(object)
  </code></pre>
  
  <p>So I'm guessing that a manifest of T is not being properly defined. Do I need to implicitly define this somewhere?</p>
  
  <p>Thanks!</p>