Re: Running into issue using SparkIMain

2016-06-29 Thread Jayant Shekhar
Hello,

Found a workaround to it. Installed scala and added the scala jars to the
classpath before starting the web application.

Now it works smoothly - just that it adds an extra step for the users to do.

Would next look into making it work with the scala jar files contained in
the war.

Thx

On Mon, Jun 27, 2016 at 5:53 PM, Jayant Shekhar 
wrote:

> I tried setting the classpath explicitly in the settings. Classpath gets
> printed properly, it has the scala jars in it like
> scala-compiler-2.10.4.jar, scala-library-2.10.4.jar.
>
> It did not help. Still runs great with IntelliJ, but runs into issues when
> running from the command line.
>
> val cl = this.getClass.getClassLoader
>
> val urls = cl match {
>
>   case cl: java.net.URLClassLoader => cl.getURLs.toList
>
>   case a => sys.error("oops: I was expecting an URLClassLoader, found
> a " + a.getClass)
>
> }
>
> val classpath = urls map {_.toString}
>
> println("classpath=" + classpath);
>
> settings.classpath.value =
> classpath.distinct.mkString(java.io.File.pathSeparator)
>
> settings.embeddedDefaults(cl)
>
>
> -Jayant
>
>
> On Mon, Jun 27, 2016 at 3:19 PM, Jayant Shekhar 
> wrote:
>
>> Hello,
>>
>> I'm trying to run scala code in  a Web Application.
>>
>> It runs great when I am running it in IntelliJ
>> Run into error when I run it from the command line.
>>
>> Command used to run
>> --
>>
>> java -Dscala.usejavacp=true  -jar target/XYZ.war 
>> --spring.config.name=application,db,log4j
>> --spring.config.location=file:./conf/history
>>
>> Error
>> ---
>>
>> Failed to initialize compiler: object scala.runtime in compiler mirror
>> not found.
>>
>> ** Note that as of 2.8 scala does not assume use of the java classpath.
>>
>> ** For the old behavior pass -usejavacp to scala, or if using a Settings
>>
>> ** object programatically, settings.usejavacp.value = true.
>>
>> 16/06/27 15:12:02 WARN SparkIMain: Warning: compiler accessed before init
>> set up.  Assuming no postInit code.
>>
>>
>> I'm also setting the following:
>> 
>>
>> val settings = new Settings()
>>
>>  settings.embeddedDefaults(Thread.currentThread().getContextClassLoader())
>>
>>  settings.usejavacp.value = true
>>
>> Any pointers to the solution would be great.
>>
>> Thanks,
>> Jayant
>>
>>
>


Re: Running into issue using SparkIMain

2016-06-27 Thread Jayant Shekhar
I tried setting the classpath explicitly in the settings. Classpath gets
printed properly, it has the scala jars in it like
scala-compiler-2.10.4.jar, scala-library-2.10.4.jar.

It did not help. Still runs great with IntelliJ, but runs into issues when
running from the command line.

val cl = this.getClass.getClassLoader

val urls = cl match {

  case cl: java.net.URLClassLoader => cl.getURLs.toList

  case a => sys.error("oops: I was expecting an URLClassLoader, found a
" + a.getClass)

}

val classpath = urls map {_.toString}

println("classpath=" + classpath);

settings.classpath.value =
classpath.distinct.mkString(java.io.File.pathSeparator)

settings.embeddedDefaults(cl)


-Jayant


On Mon, Jun 27, 2016 at 3:19 PM, Jayant Shekhar 
wrote:

> Hello,
>
> I'm trying to run scala code in  a Web Application.
>
> It runs great when I am running it in IntelliJ
> Run into error when I run it from the command line.
>
> Command used to run
> --
>
> java -Dscala.usejavacp=true  -jar target/XYZ.war 
> --spring.config.name=application,db,log4j
> --spring.config.location=file:./conf/history
>
> Error
> ---
>
> Failed to initialize compiler: object scala.runtime in compiler mirror not
> found.
>
> ** Note that as of 2.8 scala does not assume use of the java classpath.
>
> ** For the old behavior pass -usejavacp to scala, or if using a Settings
>
> ** object programatically, settings.usejavacp.value = true.
>
> 16/06/27 15:12:02 WARN SparkIMain: Warning: compiler accessed before init
> set up.  Assuming no postInit code.
>
>
> I'm also setting the following:
> 
>
> val settings = new Settings()
>
>  settings.embeddedDefaults(Thread.currentThread().getContextClassLoader())
>
>  settings.usejavacp.value = true
>
> Any pointers to the solution would be great.
>
> Thanks,
> Jayant
>
>


Running into issue using SparkIMain

2016-06-27 Thread Jayant Shekhar
Hello,

I'm trying to run scala code in  a Web Application.

It runs great when I am running it in IntelliJ
Run into error when I run it from the command line.

Command used to run
--

java -Dscala.usejavacp=true  -jar target/XYZ.war
--spring.config.name=application,db,log4j
--spring.config.location=file:./conf/history

Error
---

Failed to initialize compiler: object scala.runtime in compiler mirror not
found.

** Note that as of 2.8 scala does not assume use of the java classpath.

** For the old behavior pass -usejavacp to scala, or if using a Settings

** object programatically, settings.usejavacp.value = true.

16/06/27 15:12:02 WARN SparkIMain: Warning: compiler accessed before init
set up.  Assuming no postInit code.


I'm also setting the following:


val settings = new Settings()

 settings.embeddedDefaults(Thread.currentThread().getContextClassLoader())

 settings.usejavacp.value = true

Any pointers to the solution would be great.

Thanks,
Jayant