Amazon Elastic Beanstalk Java How To Get Oracle JDK - java

I am new to Amazon web services and have recently inherited a lot of existing services.
One of the things I've been desperately needing is for our Amazon Elastic Beanstalk instance to be using Sun's Oracle JDK rather than openJDK.
This inconsistency has been making my java functionalities not working as expected since I do java development using Sun's Oracle JDK. Our legacy code is based on JDK7.
For example, the JPEG codec doesn't exist in openJDK, and the javascript Rhino engine doesn't support a JSON.stringify function. I've made workarounds to these, but that's just avoiding the bigger issue which is that I have no idea what openJDK doesn't support, and Oracle JDK seems to support just about everything.
According to the previous owner, I was recommended not to create my own "AMI" because then I would have to take care of all the internal resources myself. I was told that doing so would defeat the purpose of Elastic Beanstalk supposedly handling everything for us.
I cannot seem to find a straight answer around. I do not want to leave the Elastic Beanstalk ecosystem. I'm under the assumption that Amazon's EC2 is a whole different ecosystem where I would have to manage all the server's internals myself.
I just want to know, as of this current day, is it possible to have an Elastic Beanstalk instance for Tomcat7 with Oracle JDK?
I am hoping that it is simply a simple configuration change somewhere on the site.
How can can this be done?

You can install you preferred JDK and change the java linux link to it, so it'll be the default one.
Since EB instances are automatically created and destroyed by EB, you need to include a small script that instructs EB to make the required java change whenever it decides to spin up a new web instance.
Now to do that you need to need to write a conf file and place it in a .ebextensions folder. in that file you manually install java and replace it with the current one.
The formal (tiring) documentation about eb config files is here.
To get you up and running fast, check out this gist.

Related

Will Oracle Universal Installer mess up my existing database setup?

I'm asking here because I haven't been able to get a clean answer from Oracle, so I wanted to see if there were any Oracle experts out here!
As a high-level overview of what I'm trying to accomplish, I want to get a recently-moved two-way interface to authenticate through the served ASMX file to authenticate the username and password against an Oracle DB. I am getting an 'Invalid Credentials' SOAP Header Exception error on the web interface. In reviewing the setup of the old IIS server, I see there's an Oracle Data Provider installed on it. When I search for this ODP.Net provider, I see it's included with a configuration tool called the Oracle Universal Installer.
When I begin the install, I see it copying over a bunch of java JRE files, so I exited out as I was concerned it would mess up my existing setup. (This is the OXI server, not the App/DB server)
So my question is...would installing Oracle Universal Installer mess up my existing environment? (I realize this question is extremely specific to a particular environment) I've taken a snapshot of both my OXI and DB servers as a just in-case...I guess I am looking for a little extra comfort before continuing.
Thank you
In terms of Java I don't think so. The installer copies java files into sub-folder of your Oracle folder and that's it.
However, for other components it might do a lot and also break your existing application. It may overwrite the ODP.NET provider, change your PATH variable, etc.
Your question has to be more specific.

How do I upgrade to jlink (JDK 9+) from Java Web Start (JDK 8) for an auto-updating application?

Java 8 and prior versions have Java Web Start, which auto-updates the application when we change it. Oracle has recommended that users migrate to jlink, as that is the new Oracle technology. So far, this sounds good. This comes with a host of benefits:
Native code on Windows, Mac and Linux
Modularization of the code (although Proguard does this as well)
The use of new, supported technology.
The problem: I can't find the canonical Java solution to auto-update with jlink.
One would think that Java Web Start could continue to be used, especially if one casually reads this document. Notice the fact that Java Web Start continues to be prominently listed. But there's a fly in the ointment: Oracle is deprecating Java Web Start. It's slated for removal in JDK 11. So, what's the official path forward. Failing that, is there a standard way that people proceed?
For the purposes of this question the following are out of scope:
Paying huge amounts of money yearly to someone with an feature-packed enterprise solution. The application to be distributed is already packaged into a single jar that is smaller than 50MB.
Forcing users to run an InstallShield style app to reinstall the new version, and then manually uninstall the old version every time an update is pushed. That's sooo 1990's.
Porting the entire app to be a webapp, rewriting the UI and client side logic to fit in a browser and dealing with all the incompatibilities that entails. The authors of the application worked on GWT and know exactly what web browsers are capable of. Unfortunately, they also know the level of effort required.
Allowing users to continue to run old versions of the application. That, too, is sooo 1980's. Modern apps update quickly, and supporting every version of the application ever released is not tenable. That's what my father's COBOL application had to deal with, and he didn't enjoy it. I'm hoping technology has progressed.
Continuing to use Java Web Start. Until/unless Oracle changes its mind, Java Web Start is a doomed technology.
In May 2019 commented to watch the OpenWebStart project.
Now (October 2019) it is time to give OpenWebStart serious consideration. While not yet feature complete, a alpha beta release of OpenWebStart is now available for download under a "GPL with Classpath exception" license.
The OpenWebStart Technical Details page states:
OpenWebStart is based on Iced-Tea-Web and the JNLP-specification defined in JSR-56. It will implement the most commonly used features of Java Web Start and it will be able to handle any typical JWS-based application. We plan to support all future versions of Java, starting with Java 11. In addition to Java 11, the first release of OpenWebStart will also support Java 8.
The page goes on to state that OpenWebStart will support interactive installers with auto-update, and non-interactive installers. Some JNLP features will be supported, and it will include a replacement for the Java Control Panel. A more comprehensive list of planned features1 and their implementation status is provided in the feature table.
1 - If you have a requirement that is not on their feature list (e.g. jlink support), you could contact the OpenWebStart team, and offer a suitable incentive (e.g. money to pay developers) to implement the feature for you. They also offer commercial versions of the software for paying customers.
Disclaimer: I have no connection with the OpenWebStart project, the company (Karakun) or the project sponsors. This is not a recommendation.
I had a similar problem in a past project. We needed to migrate from Webstart to another technology.
The first approach was to install IcedTea. It is directly bundled with the AdoptOpenJDK Project.
But as far as I understood the problem, Java wasn't meant to be installed on the Client side like this anymore and we didn't want problems with all of our customers.
Our solution was then building an own specific Executable, which connects to the server, ask for enviroment settings from the server side, and then download and extracts the JLink Java. So we could use the old technologies and just wrapped it in an Executable.
Last thing done then was redirecting to the download location of the Executable when calling the jnlp-URL.
Do you use maven?
I've resolved my similar problem with maven (I need to update an EAR).
My main app (the ear package) has a pom.xml with listed the dependencies and repositories.
The dependencies have the <version> tag with a range (documentation) as in this example
<version>[1.0.0,)</version>
That means : get version 1.0.0 or newer of the dependency. (You can put also an upper bound to the version, [1.0.0, 2.0.0) so if you develope a new version, it is not used in old app)
In the repository section I added my personal repository.
Now, in the remote machine I need only to rebuild my ear package with maven : the compiler download the newer version of my jar and put it together.
You need a system to check if there are newer dependencies version and warn the user to update the app and also lock its work (you can't work if you don't update). Maybe you need a little app to make users do the rebuild process easily. It's 1990's but a lot of desktop-app works in this way
PRO
This schema can be used in a lot of different projects.
CONTRO
You need to build the app in the remote machine, so the client must have a JDK and access to your repository (like artifactory);
You must write code in different jars and add them like dependencies in the main archive.
You must change JAR version each time and publish on the repository (this could be a good practice)

AWS S3 local server for integration testing

I have some code that uploads and downloads files using AWS S3 (using the Java AWS SDK). I want to be able to write some tests for it, I was wondering if anyone has any good options. Ideally I would like a light-weight S3 server that runs locally that can be started fast and requires no system configuration (the tests need to be run by Jenkins).
Some options I have looked at so far:
FakeS3 - Almost exactly what I'm looking for, however, when using the Java AWS SDK, you must edit your /etc/hosts file and restart networking, not something I can do in Jenkins. Also when trying it out there seems to be a bug with the creation date field being formatted wrong which makes my client throw an exception, which doesn't inspire me with much confidence in the project.
Ceph - Implements S3 API but takes several minutes to install
You can try localstack, which is an open source local AWS cloud stack made for testing. It provides implementations of several of AWS services, including S3.
It looks like a very popular open source project on GitHub.
You can try installing minio server on your laptop/system, its open source & single static binary. Server is S3 compatible. Then you can try minio-java client library for all operations, following is basic operations example.
Installing minio server [GNU/Linux]
$ wget https://dl.minio.io/server/minio/release/linux-amd64/minio
$ chmod 755 minio
$ ./minio --help
Hope it helps
Disclaimer: I work for Minio
Late answer, will be useful mostly for Docker users. There's a great S3 compatible storage software called Riak CS and there's docker-riak-cs image that allows to quickly launch the server.
I've been using it for nearly 2 years for local development and integration testing with great success. It has some limitations, but nothing major that comes in the way, see api / compatibility documentation.
If you need Docker-less solution, you can set it up locally for each build, all setup and configuration scripts are available in docker-riak-cs repository.
Minio offers (in my opinion) the best set of features, flexibility and ease of use.
It is available as a docker container or binary for major OSes.
To start with minio, it is as easy as:
Download
Start the binary minio server /data
Use it
It works flawlessly with s3cmd and it has nice documentation for popular programming languages.
I started a S3 Server API project for Ladon, it contains a simple File System Repository. Its a Java Project and contains a Spring Boot Starter for simple testing. Not all S3 API features are supported yet but I will add them on request. Its on Github: Ladon S3 Server
findify/s3mock - an in-process, Java S3 server aimed at testing. Didn't test it - just stumbled upon it. Needs no docker, which might be an advantage. HTH! :)
ive tried both minio and localstack, and the problem with localstack is that the storage in the s3 bucket is not persistence. I think only if you have the pro version it will support percistency. minio was very easy to use, and it is persistent for free.
I created different buckets to use for the different use cases. For example: my-dev-bucket and my-prod-bucket. I don't know if this meets your use criteria but you might want to consider it. The side benefit is it makes your pre production and production code follow the exact same flows.

EC2 Amazon: Set up autoscaling tools environment without JRE?

I am following this guide here:
http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/UsingTheCommandLineTools.html
I don't have JRE, although I have Java 7 setup (I develop in Java). So, I believe that I am stuck on this step in the tutorial: export JAVA_HOME=/usr/local/jre (but my /usr/local does not have JRE.)
See information here:
lucas#lucas-ThinkPad-W520:~$ ls /usr/local/
bin etc games include lib man sbin share src
lucas#lucas-ThinkPad-W520:~$ which java
/usr/bin/java
lucas#lucas-ThinkPad-W520:~$ which jre
lucas#lucas-ThinkPad-W520:~$
Should I install JRE separately, or is there a way to configure my system to work with these auto-scaling tools?
You should not use as-cmd anymore. Please use AWS CLI. Here is the AWS CLI relevant autoscaling commands
The reason being, as-cmd is not maintained by Amazon anymore and all the old CLI features have been exported to AWS CLI. AWS CLI is a one stop shop for all the AWS Services unlike older CLIs where you had to install a separate CLI for individual services.
as-cmd is JAva based and hecne your question. However, AWS-CLI is python based and in my opinion (which is ofcourse subjective), It is bit faster than older JAva based AWS CLIs.
AWS CLI provides output in JSON format which is much more easier to parse.
BESIDES, You don't have to play with CLI for autoscaling. Now, you can do the same job via AWS Console.
Your best bet is to download JRE.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
Bottom right of that page. Small download should be done within seconds. Hope this helps

How to take a Java Web-application offline?

We develop Java Web-aps (Websphere, DB2) which display graphical and databased information. We would also like to offer the same application offline (distribution via CD/DVD) with online data-update. We have tried a number of alternatives in the past, but nothing has been really stable. What are the new best practices to take a Web ap plus data (in a small database) offline?
I don't know how well it works with the CD/DVD distribution front, but the first thing that comes to mind is Gears. On the .NET side of the fence there's Silverlight 2. Then there's the Mozilla Prism project, although I don't know how far advanced that is.
These are all designed for not just offline access, but mixed offline/online, talking to a server when it's available and working locally when necessary.
I'd suggest using Apache Derby as the database (also available as Sun's Java DB, and possibly still IBM Cloudscape (does that still have DB2 compatibility in place?)).
I'm sure there's plenty of Web servers/Servlet containers about. Apache Tomcat is the obvious one. An alternative approach would be to use an embedded native browser within a single Java process. That approach should be relatively hassle free for users and tech support, and you can just use WebStart to install and update.
If you're using EJBs and other nonsense, then there are similar freebies about. I understand Sun Glassfish is nice and fast starting.
You could create an image of your server as a VMware instance and distribute it with a copy of VMware player (licensing allowing of course). Personally I'd build it on top of a Linux distribution like CentOS5.
You can bundle a JRE along with JETTY server and use a different database e.g HSQLDB (that you can bundle inside the webapp itself).
If you are using an ORM tool to connect to database, you might not have to make many code changes for this.
A lot of Application server distribute their admin consoles like this.For e.g Weblogic admin console runs offline (it uses internal ldap server for its database)
Also as far as Google gears is concerned, they are also pretty much doing the same thing.
They have a server that is bundled along with SQLDB and they allow to synchronize the data between online offline app.
You can sync the data too (use webservices in the online app) and talk over https from the offline app to sync the data, if you need the sync feature.
Also you can check this link
http://developers.sun.com/learning/javaoneonline/2007/pdf/TS-69700.pdf

Categories