How can I create an Upstart Zip package using sbt-native-packager? - scala

I am unable to generate an upstart zip package.
I have added the following to my sbt project
...
enablePlugins(UpstartPlugin).
enablePlugins(JavaServerAppPackaging)
and then run
sbt clean universal:packageBin
And a Zip file is produced but it contains the shell script in ./bin and the jars in ./lib that look like what is produced when I use JavaAppPackaging!
Where are the conf files etc needed for upstart?
Am I missing the secret sauce or using the wrong incantation?
Reading all the docs at this page I am under the impression that the archetype plugins determine what goes into my package while the format plugins determine what form the package takes.
So for example I could have a Java Server project that is designed to launch running as a daemon user using the JavaServerAppPackaging (archetype) and adding the daemonUser setting, but then have this bundled up as a Zip or Tar.gz using the Universal (format) plugin or a .deb file using the Debian (format) plugin.
Well I want a Java Service with all the files necessary to be started with the upstart System Loader but packaged as a Zip file. So I assume I need the upstart (archetype system loader) plugin with the universal (format) plugin.
There is even a tip on the system loader docs for the upstart plugin saying
You can use systemloaders with the Java Application Archetype or the Java Server Application Archetype!
Well that exactly what I want however it doesn't state how to do it!
Please can someone tell me how to get a zip bundle with an upstart layout that starts a Java Server application? And if you can point out the documentation I have clearly missed than that would help my understanding too :-)
Cheers
Karl

Thanks for ready the docs so carefully and sorry that the docs are lacking an explanation what package types support system loaders.
The short answer is: only rpm and debian packages support system loaders ( systemd, systemV and upstart ).
Why is that so? A system loader is tight to the target operation system. It's nothing universal, which is the reason it's not in there. The configuration files and or scripts and platform dependent and this is not part of your regular application directory.
Cheers,
Muki

Related

scala and akka on linux: compiling and executing

I'm trying to run a scala/akka based program on a linux cluster machine. I was following the tutorial link (this was the only example I could find):
http://doc.akka.io/docs/akka/2.0/intro/getting-started-first-scala.html
It says to use the command to obtain the akka library:
git clone git://github.com/akka/akka.git
But it doesn't have any jars files inside it as per the tutorial.
I'm not able to get a basic akka-scala-sbt combo working on linux. So any help on this is much appreciated. I'm not aware (not able to find any clear source) of the commands needed to compile/execute with and without using SBT.
Java version: "1.8.0_31"
Scala version: "2.11.5"
Akka: I'm not sure, I did git clone, believe its the latest
SBT: 0.13.9
Java,Scala are already installed on the cluster, I had to just use module load.
You can start with this simple example: https://github.com/izmailoff/SmallAkkaProjectExample. It will help you to understand how to compile and run a project.
Usually the steps are:
Start SBT
Compile code
Run it from SBT
or:
Start SBT
Compile executable JAR
Run the JAR from command line
If you want a more advanced example take a look at: https://github.com/izmailoff/remote-akka-server-template
In either of these projects you don't need to download any libraries/JARs. SBT will download everything you need automatically.
In short, you need to understand how to build projects with SBT and how to run them - not related to Akka. Separately from that you need to know how Akka runs, i.e. ActorSystem, kernel, etc.

Running Simple Hadoop Programs On Eclipse

I am pretty new to hadoop & ubuntu so please bear with me. I find it very inconvenient to compile my hadoop .java files from command line. So I have created an eclipse project & imported all the hadoop libraries so that the eclipse does not throw any reference errors. And it does not. However when I run the files as a standalone java application I get the following error
WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
I am running on ubuntu and I have researched this problem elsewhere on web. I do not expect to see this error since the only difference is that I am running it within eclipse and not from command line. Where I am going wrong. Is there a specific way in which I need to add hadoop dependencies to my hello world hadoop projects? Will a simple buildpath configuration and importing of the necessary libraries not suffice? Appreciate all your responses.
you can try right-clicking the Project, ->Build Path -> Configure Build Path
Go to your src folder, point to "Native Library", then edit the location to the location of your hadoop native library folder (normally: ~/hadoop-x.x.x/lib/native/"folder-depending-on-your-system")
It is a warning and not an error which tells you that there is some problem in loading the native libraries which Hadoop makes use of. It should not have any negative impact on your job's output though. Remember Hadoop has native implementations of certain components for performance reasons and for non-availability of Java implementations. On the *nix platforms the library is named libhadoop.so. Using Eclipse doesn't make any difference the way Hadoop works. It's just that your Eclipse is unable to load the native libraries due to some reasons.
One possible reason might be that there is some problem with your java.library.path. You can configure Eclipse to load the proper libraries by configuring the build path as per your environment. To know more about Hadoop's native libraries, and how to build and use them you can visit this link.

How to build a scala application that was created in eclipse scala plugin FROM THE CL

I have developed a scala application for the first time, but I have to deploy it with a "one-click" type script that can run and build the scala application from source WITHOUT ECLIPSE.
Since I'm completely new to scala I don't know how to tell it where all my source files are etc... to get it to build my app from the command line. I also have 2 3rd party .jar libraries that I need to tell the scala compiler to link to...
Any documentation on this? Or example command lines? My project hierarchy is:
src/packagename: contains all .scala
bin/packagename: contains all.class files
libs/ -> contains 2 .jar files I will need to import somehow
I'm working on debian linux
EDIT: I found this ability to export in eclipse so I created a .java file and called my main scala object from it. Then I exported as a runnable jar. However, when I go to run the new runnable jar "sudo java runnable.jar" it says "class not found exception: runnable.jar"
You should take a look at https://github.com/harrah/xsbt/wiki which is the common way to build a Scala project. Run through the tutorial in the wiki to learn how you should organise your directory structure, so that everything may run fine.
If you want to combine it with eclipse, checkout this plugin: https://github.com/typesafehub/sbteclipse

How to create install file for a Web Dynamic project Java EE

What's the best way to create/generate a setup file (.EXE) for a web dynamic project from Eclipse ?
the project must be installed after installing tomcat & SqlCE silently, since it depends on them both to work
thanks
There are many custom exe packers are available on web.
Just google for some "jar to exe" or "setup maker" type things you would definitely find something.
Something like this.
Java has no support for exe files. Exe files are specific to Windows platform while Java is intented to be platform independent.
Eclipse for Java doesn't offer builtin facilities to generate exe files since they have absolutely nothing to do with Java. Java's way is an executabele JAR file. You could create an executabele JAR file wherein you do the installing job in a main() method. Once you have the main() method finished, Eclipse can autogenerate the JAR by the Runnable JAR wizard.
If you really want an exe file, you'd need to write a custom one using C++ or C# (at least, the same language as Windows is written in and natively supports). It should then do basically the same as what you would do in the Java's main() method.

Add system packages to PDE runtime configuration

I created an eclipse run configuration for a number of bundles. One of the bundles has a dependency to the following packages:
com.sun.mirror.apt,
com.sun.mirror.declaration,
com.sun.mirror.type,
com.sun.mirror.util
I believe these are part of the Sun Java JVM. When I add these packages as system packages to a Felix container, the bundle is loaded fine by that container.
However, I was unable so far to find out, how I can configure these packages as additional system packages for a run configuration in eclipse (I found how eclipse as a whole can be made aware by changing the config.ini).
EDIT: It seems that these classes are in the system library tools.jar. Or in my case, as I am using Mac OS X, they could be in classes.jar?
The OSGi specification defines a property called "org.osgi.framework.system.packages.extra" (explained in paragraph 4.2.2 that deals with launching properties) that allows you to specify extra packages that should be exported by the framework. Add your packages to that property in your run configuration and it should work.