Building a Java Web Start App for Multiple Codebases - java-web-start

I have a Java Web Start application for which the JNLP is generated dynamically. The JWS application is built in NetBeans, which offers me several options RE the codebase for this app, including not specifying one. But so far, I've been using the "User defined" option, i.e., I've been specifying the codebase within every build. My question is, what do I need to do to get my app to run if I don't specify a codebase? Right now, I have to rebuild with a different codebase for each environment in which I want to run this application, which is not ideal. But if I don't specify the codebase, the JWS application won't run. I'm currently writing the dynamic JNLP to a ServletOutputStream. Would I have to write it out to an actual file first before I could use it?

Related

Tomcat/WildFly - fast webapp auto-reload on IDE compile-on-save?

Is it possible to do what "mvn jetty:run" does, ie. run it against an extracted webapp and auto-reload/auto-restart the webapp if any of the extracted files have been changed?
Beware! I'm NOT talking about updated WAR files and auto-deploying them. My IDEs currently update the class files directly inside the "extracted" webapp file structure.
Context: I'm wondering what (freely licensed, ie apache/lgpl, not CDDL/GPL) Java EE 7 solution provides the fastest roundtrip times for developing test units against the full stack/bugfixing.
I'm also thinking about continuing to use Jetty 9.4, maybe with openejb, because I'm not using most of the JavaEE features anyways. I'm not really a big fan of IoC/DI because if you try to avoid scanning overhead, you put configuration into XML, whereas setting up an embedded server programmatically is strongly typed and cleaner IMHO (remember jetty.xml? programming Java using XML, wtf...). I also don't like JSTL/JSP etc. because templates feel like PHP and j2html seems much more Java-like to me.
But what I want is JPA transaction handling/connection pools for my Jersey servlets. Currently I'm doing that inside a RequestListener, and a more seamless support seems preferable, though not at the cost of being able to run a full stack jetty embedded server in my unit tests without much hassle.
Update
I'm using a simple BASH script using inotifywait now. It simply uses Glassfish's and WildFly's RESTful admin consoles for redeploy:
https://github.com/jjYBdx4IL/snippets/blob/master/bash/jee_autodeploy.sh
It doesn't even deploy the war, instead it simply deploys the build directory. It should be fast enough for most use cases. And if your app grows too large and increases reload times beyond a certain point, one should probably start thinking about refactoring it into multiple modules anyways.
You could try using OpenLiberty, which was released today and is the core (Java EE 7 complaint) subset of WebSphere Liberty. It comes with an eclipse plugin known as "WebSphere Developer tools" and is under the EPL-1.0 license.
http://openliberty.io/

Prevent user from changing ClickOnce application files after installation

I'm developing a WPF application that I deploy with ClickOnce to a network share on the intranet from which clients can install it.
I need to make sure that the user can't modify any of the application files (especially DLLs and the main executable) on their machine. That is, if any of the application files have changed, the application should refuse to run. I was under the impression that, when using ClickOnce, this was available out of the box and that the application would refuse to start if the file hashes didn't match the manifest.
However, I tried to manually replace the executable or a DLL with a slightly different version after installation and the application still ran fine (executing the modified code).
Does ClickOnce provide what I'm looking for?
How can I enable the functionality?
I'm using a level 2 StartSSL code-signing certificate to sign the application manifest if this matters.
P.S.: just to be sure: I'm talking about the installed application files, not the installation files.
You can sign AND strong name each one of DLLs to prevent tampering but then, doing so has its own pain points when it comes to upgrades and distribution in general. Note that even doing so, doesn't entirely prevent someone from injecting code into your running process. It's a sticky subject.
I recommend going thru this question which already discusses these points in detail. Does code-signing without strong-naming leave your app open to abuse?
I think it will be a fairly manual process.
Doesn't look like the VS2013 deployment tools handle code obfuscation but they do support signing and app permissions. Start with that, then you might have to get the generated manifest as a starting point to build your own with obfuscated assemblies.
MS docs break it into 3 steps: 1. obfuscate, 2. build manifest, 3. manually publish
Here is what MS docs say...
Securing ClickOnce Applications
Deploying Obfuscated Assemblies
You might want to obfuscate your application by using Dotfuscator to prevent others from reverse engineering the code. However, assembly obfuscation is not integrated into the Visual Studio IDE or the ClickOnce deployment process. Therefore, you will have to perform the obfuscation outside of the deployment process, perhaps using a post-build step. After you build the project, you would perform the following steps manually, outside of Visual Studio:
Perform the obfuscation by using Dotfuscator.
Use Mage.exe or MageUI.exe to generate the ClickOnce manifests and sign them. For more information, see Mage.exe (Manifest Generation and Editing Tool) and MageUI.exe (Manifest Generation and Editing Tool, Graphical Client).
Manually publish (copy) the files to your deployment source location (Web server, UNC share, or CD-ROM).

Web framework with user-friendly desktop deployment?

I'm building a web app with Backbone.js (I'm not tied to Backbone yet though). I need a back-end framework only for persistence to a database via a RESTful API. However, I also need to able to deploy it as a 'desktop' app for off-line use, i.e. running a local server and launching a browser window, but I don't want users to have to start a server from the command line to run the application.
I can use SQLite as a database since it's only a single user application, it's just the framework that I'm stuck on. I have looked at the following:
Rails and Django: Default web servers are too flimsy, requires Ruby/Python and runs from the command line. I'm aware of the Bitnami stacks but at 99mb it's too big of a dependency and not exactly hidden from the user.
Sproutcore: Run from command line, also too bulky.
Pyjamas Desktop - Depends on MSHTML which I suspect limits my ability to use HTML5 features.
I'm leaning towards creating a Java app that starts a Scala/Lift server instance and opens a web browser, then sits in the system tray (kind of like WAMP). Is anyone familiar with a tool or framework built for user-friendly deployment as a standalone desktop app?
I do not know if PHP is an option for you? Then I would recommend phpdock.
web2py has a standalone deploy-to-desktop feature with no dependency on Python: http://web2py.com/books/default/chapter/29/14#How-to-distribute-your-applications-as-binaries
As Eydun said, phpdock is an option but it's commercially licensed .
I settled on using Java/Spring/H2/Hibernate/Jetty. I find that Jetty serves requests VERY quickly so the application looks real-time when launched in a browser. There is a tutorial on embedding the Jetty server here. I imagine it's quite trivial to build a GUI that launches the server and a browser.
Another Java option is to use the Play Framework, which may be more at home to those coming from a Django/Rails background. However, the documentation for "creating a standalone version of your application" for Play 2.0+ indicates that they have ditched using Java EE containers (Tomcat/Jetty) and WAR files in favor of running the JARs with the bundled copy of JBoss Netty, so it may take a bit of work to get it running the way you want it.
I would recommend the Play Framework approach if you're OK with using/learning Scala.

Integrate automated GWT GUI testing with build system

I am in flux for integrating an automated GUI testing with my build system. My GUI application is developed in GWT. I use HUDSON as my automated build system. I would like to perform sanity test of my application. As I understand, the entire test setup will have following steps.
Build and deploy the application in predefined application server. In my case, it would be create and install the application in Android emulator.
Start/Launch the application.
Perform pre-defined user actions(UI Test cases) and validate them.
Somehow include validations for different browsers. I am really not sure how can I do this.
Generate report of test cases performed.
I am not posting the details of application as I think this detail will not make any difference in the approach. Can somebody guide me using past experience if this is possible and if it is then to what extent. The best UI automation tool (preferably open source) which can fit easily here.
We use TeamCity as build server for a GWT application. We just use it as a build server with two tasks: compile sources into Javascript, and deply war file to Tomcat application server. Although I didn't manually set it up yet, I believe it's possible to add a third task for UI testing using Selenium (which we used for another JSF web application testing).
A fairly good example of using Selenium automated testing is RichFaces. If you download its source code package, it includes hundreds of UI-testnig codes written generated by Selenium.

I have a J2EE application that needs updating within a client's intranet

I have a J2EE application that runs fine and is accessible to the internet. Some of our prospective customers would like to use it, but are unwilling to send their data over the internet.
As a workaround I've thought of providing them with the war file and letting them run it themselves.
The problem is: how do I make it trivial for them to update the application when I make a new version available? The more difficult it is, the less likely they are to buy in.
What's involved in writing an updater that fetches the latest war file from online and updates the web application? Is this even possible?
In the least they would need to redeploy the war file. Most application servers have an interface through which you can upload a new war file. I am in favor of doing this process manually i.e. you send them a war file and they can use the app server's admin page to deploy the new war. This way they explicitly know when they are updating the app. Also they control when they want to deploy a new version of the app and easily roll back to an older version.
I would recommend using Jetty as an embedded solution. I have used a few apps that that use the embeded functionality. It allows you to create a packaged distribution of your application that runs a servlet container out of the box.