use scala in existing java play-app

173 views
Skip to first unread message

getagrip

unread,
Jul 12, 2010, 12:43:06 PM7/12/10
to play-framework
Is it not possible to use the scala-module with an existing play
application, that is mix java with scala?
After enabling the scala module in application.conf an error is thrown
upon the first request.
It looks like the scala-compiler tries to compile java classes I
guess:

play.exceptions.CompilationException: missing type arguments
at play.scalasupport.core.ScalaPlugin$ScalaCompiler$$anon
$1.info0(ScalaPlugin.scala:158)
at scala.reflect.generic.Trees$Traverser$$anonfun$traverseTrees
$1.apply(Trees.scala:566)
at scala.reflect.generic.Trees$Traverser$$anonfun$traverseTrees
$1.apply(Trees.scala:566)
at scala.reflect.generic.Trees
$Traverser.traverseTrees(Trees.scala:566)
at scala.reflect.generic.Trees$Traverser$$anonfun$traverse
$1.apply$mcV$sp(Trees.scala:465)
at scala.reflect.generic.Trees$Traverser.atOwner(Trees.scala:
581)
at scala.reflect.generic.Trees$Traverser.traverse(Trees.scala:
464)
at play.scalasupport.core.ScalaPlugin
$ScalaCompiler.compile(ScalaPlugin.scala:318)
at
play.scalasupport.core.ScalaPlugin.compile(ScalaPlugin.scala:145)
at
play.scalasupport.core.ScalaPlugin.compileAll(ScalaPlugin.scala:96)
at
play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:
362)
at play.Play.start(Play.java:376)
at play.Play.detectChanges(Play.java:480)
at play.Invoker$Invocation.init(Invoker.java:98)
at Invocation.HTTP Request(Play!)


Any hints?

Guillaume Bort

unread,
Jul 12, 2010, 12:59:27 PM7/12/10
to play-fr...@googlegroups.com
Yes when the scala module is enabled the scala compiler is used for
Java too (it is required to properly handle java/scala cross
compilation)

However it should work. Perhaps it is more strict than the eclipse
compiler though. Can you show the code that does not compile?

> --
> You received this message because you are subscribed to the Google
> Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en
> .
>

getagrip

unread,
Jul 12, 2010, 2:53:45 PM7/12/10
to play-framework
Here it is:

Compilation error:
The file /app/service/KVService.java could not be compiled. Error
raised is : missing type arguments

import java.util.HashMap;
import java.util.Map;

@OnApplicationStart
// the compiler doesn't like the following line:
public class KVService extends Job implements Constants {

public KVService() {
}

private static Map<Long, KV> kvmap = new HashMap<Long, KV>();

}

Guillaume Bort

unread,
Jul 12, 2010, 4:04:25 PM7/12/10
to play-fr...@googlegroups.com
Well in fact the Job class is generic. It seems that the scala
compiler is more strict. Perhaps you should specify Void explicitly:

public class KVService extends Job<Void> implements Constant

> --
> You received this message because you are subscribed to the Google Groups "play-framework" group.
> To post to this group, send email to play-fr...@googlegroups.com.
> To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
>
>

--
Guillaume Bort, http://guillaume.bort.fr

For anything work-related, use g...@zenexity.fr; for everything else,
write guillau...@gmail.com

getagrip

unread,
Jul 13, 2010, 5:36:54 AM7/13/10
to play-framework
Thanks you very much, it works now :-)


Sam Liu

unread,
Apr 21, 2011, 10:25:54 PM4/21/11
to play-fr...@googlegroups.com
I got the same problems, This is very important thing if you update to Play 1.2 with Scala module.

And the SearchReindexJob.java in the search module has same problem, it should extends Job<Void>.

Thanks a lot!

2010/7/13 getagrip <geta...@web.de>
Thanks you very much, it works now :-)


--
Reply all
Reply to author
Forward
0 new messages