Load a file a Lift boot? - scala

I have a CSV file I want to load at boot of my Lift app, but I can't figure out where to place this file. I've tried putting it under src\main\resources and then using LiftRules.getResource/doWithResource, but no dice (I get a MalformedURLException).
What's the standard way to do this in Lift?

Answered on the Lift mailing list. Turns out that sbt does not copy resources over when issuing compile or container:start commands, but only when executing the package command. This may be an sbt bug.

Related

provide wrong classpath for netbeans [duplicate]

I need to make a GUI Application for my class , so I want to make sure I can transfer a netbeans project using the GUI Builder (I know how to make it without it, but that's more time consuming and I think it would look neater without me guessing coordinates etc. and I was use to the netbeans GUI builder) from netbeans onto unix and compile it. So here's what I did I made a new JFrame form (using netbeans GUI Builder) called StartFrame.java and another called MenuFrame.java. (keep in mind that it ran with no errors in netbeans) StartFrame creates a new instance of MenuFrame and opens it on it's first run. So I transferred all of it onto the unix system. So at first I tried compiling it, but of course it got errors, saying that org.jdesktop... isn't found.
Okay so I've already searched stackoverflow and the web for this. So I ended up getting the swing-layout-1.0.4.jar from the libraries in netbeans.
I'm kind of new at compiling from command line, but I put them all in the same folder, and while I was in that directory.
I did
javac StartFrame.java -cp swing-layout-1.0.4.jar
and I got the error that NoClassDefFoundException: MenuFrame even though it is in the same folder. So then I tried
javac StartFrame.java MenuFrame.java -cp swing-layout-1.0.4.jar
and it compiled fine with no errors. So then It created 6 files StartFrame.class StartFrame$1.class StartFrame$2.class StartFrame$3.class StartFrame$4.class MenuFrame.class
I tried running it with
java -cp swing-layout-1.0.4.jar StartFrame
and it had a NoClassDefFoundException: StartFrame. I searched the web for fixes for this and stack overflow and found similar (not exact though) problems like this, but none of those fixed it.
The file dist/README.TXT will tell you how to proceed. Type ant -p at the command line to see that available commands: ant run is usually good.
Addendum:
The machine doesn't have ant installed
That would be unusual, so you should certainly verify it. You may need to add the current directory to the path, e.g.
java -cp .:swing-layout-1.0.4.jar StartFrame

Where is the phpunit.php file?

I'm trying to set up Eclipse to be able to debug PHPUnit tests. I'm trying to follow the instructions here. It says to set up a new Run Configuration, and choose PHP script, and the php file should be phpunit.php
My problem is, I can't find that file anywhere! Does the new version of PHPUnit not come with such a file? How else can you debug the unit tests?
Thanks
The file that the IDE is looking for is a single file that can run all the tests. One convention in the PHPUnit community is to call that file AllTests.php.
Kristian from Denmark explains this in an article that covers more than that.
Hope this helps!

Play framework 2 with sass and compass config file

I am testing stuff with scala, play framework 2.1.1 and I wanted to add sass with compass stylesheets using the compass plugin "compass-normalizer". For the sass part I am using the jlitola plugin.
I already got play working with sass and compass but using compass plugins has proven to be a nightmare for me. I have tried adding it as a ruby requirement:
SassPlugin.sassOptions := Seq("--compass","-r","compass-normalizer")
This was just a try and obviously didn't work because normalizer needs compass to be already initialized, however I can make it work from the terminal if I have the contrib.rb compass config file where I call sass #sassfile# --compass.
In that way of thinking I tried adding the contrib.rb file in the play project with no luck. I tried to add it to the app, conf and project folders with the same luck in all of them.
Can someone tell me what am I doing wrong?
It looks like it's just using the "current working directory" when running (see: https://github.com/jlitola/play-sass/blob/master/src/main/scala/SassCompiler.scala#L16). This is using a shady implicit to convert the Seq[String] => ProcessBuilder.
So, you may be able to put the contrib.rb file in the default directory (should be where you're running sbt from) and have the work. If not, according to the JVM docs:
The default value is the current working directory of the current process, usually the directory named by the system property user.dir.
So you could make a task that prints this in sbt to see what it is:
TaskKey[Unit]("show-user-dir") := println(sys.props("user.dir")

How do I update Clojure dependencies when working with nrepl.el?

As I understand it, when I do nrepl-jack-in a REPL is loaded along with all the dependencies defined in project.clj. If I then update project.clj to add a new dependency, do I need to kill the server and re-run nrepl-jack-in or is there way to update the dependencies in the current REPL?
Update: Maybe there is some hope,
See https://github.com/cemerick/pomegranate
Previously:
The short answer is yes - you do have to restart the JVM process.
I am aware of no good way to update dependencies in a live repl. Leiningen (called by nrepl-jack-in) will manage dependencies and set up the classpath only upon restarting. Trying to do something dynamic and clever is horribly fragile.
The struck out text below is factually true but upon a moment's reflection seemed such bad advice I have marked it up as such...
If you have a local dependency (e.g. jar file) you might use the long-time deprecated function add-classpath at the repl. But you will be entering the dragon infested swamp of java classloaders.
Restarting the REPL seems to be the simplest way. This can be done
with:
M-x cider-restart
That also appears to accomplish a lein deps. So the whole process
of adding a new dependency simply involves adding the require to
your project.clj and then invoking cider-restart.
Another (very convenient) way is to use
clj-refactor.
Adding the artifact (C-c m a p or cljr-add-project-dependency)
will prompt for the version you want, automatically put the new
dependency into your project.clj file, and reload your session.
Before pomegranate existed, I wrote my own library to dynamically load dependencies.
https://github.com/bmillare/dj
After the release of lein2 and how it under the covers can use pomegrante, I rewrote dj to use this underneath. So, even if you don't use 'dj', it might be a useful as a reference to see what its doing.

deploying a scala app built using IDEA

I developed a simple scala app that uses casbah to query the DB for the command line argument passed to it. For example
$ querydb.scala execution 10
it will run a casbah query to find 10 records matching execution in mongo. Now i have two questions.
1) How do i test this in my local. If i click execute in intellij it is just running the program, i am not able to pass command line arguments to my program.
2) How do i deploy it to run on my server, it is just going to used as console app in my ubuntu server, but im not sure how i should deploy this, which files i should put up on the server and how do i execute it in server, and stuff like that.
Any pointers would be useful for me.
or try to use sbt, IDEA has a plugin with sbt, the wiki of it has an explanation on how to use it.
I usually use sbt directly in Terminal instead of running in IDE.
1) First you need to find "Select Run/Debug Configuration" button at the top of your screen
Click on it and choose edit
Create new one, if you haven't got it yet.
Your program parameters should be written in "Program parameters" field
2) Compile your .scala files with scalac and you'll got .class files.
Then deploy it, as you usually do with java code. Hence you don't need to install scala on target machine - all you need is JDK.