How to create the build using Eclipse 3.6 - java

I am developing an web app using java/j2ee as middle ware and Mysql 5.1 as database. I have to deploy it on AWS-EC2 server.
My questions are:
How do I create the build
How do I deploy on ec2 server?
I am using Apache Tomcat-6. Should I use any other server like Apache2 as web-server?

Use WTP to create a Dynamic Web Module project.
Use AWS Toolkit for Eclipse
That's pretty terse, but you'll need so many more details that it's pointless to list them here. Read the docs, then come back with specific questions :)
Whether you need Apache2 in front of Tomcat depends on your requirements. If you need it you'll know it :) Things that you might want to punt off on Apache2:
SSL
Static content
URL rewriting

If you are just planning to do every thing manually. You should read this manual http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/
Basically,
You need to create an AMI instance of platform of your choice. (Win/Unix-based).
Configure it with the software that you need. In your case, Tomcat-6 and MySQL-5.1. Configure them. Set Schema etc.
Upload your WAR file to the instance and deploy to Tomcat-6.
Make sure Tomcat port (8080 or whatever you've configured) is open. You can configure this from AWS console's Security Group setting.
Use the instance's Public DNS to access your app. Public DNS can be found from AWS console.
There are many freely available, pre-configured AMI available. Since your setting is one of the most common one. I am sure you will get one and skip Step#2.

Related

Is it possible to coppy weblogic and it's domain from linux to windows using some tools?

I searched about cloning or copying weblogic and it's domain, and found 2 ways that I think is the most nearest to my question.
1, packing and unpacking a weblogic domain
2, Creating Extension Templates .
There is weblogic 12.2.4 installed on Linux server and I want to coppy it's configuration and domain and create my own instance with exact configuration.
If it's possible, pleas give me solution or some clues and key-word to search more.
And do I need to change some configs by hand or provided tool does everything?
Is copying domain different from copying weblogic configuration?
Thanks very much.
If you want to create a domain with the same configuration, but on Windows, you should use Weblogic Deploy Tooling.
The first step is to install Oracle Weblogic on your windows machine(s).
The second step is to use the discoverydomain.sh to introspect the domain, which is running on Linux.
The previous step will generate a model in YAML, which represents your Linux domain as code and then you will have to customize it with proper values for Weblogic's user's passwords, data sources, etc.
Once you have the model ready, you can run createdomain.cmd on Windows to create the domain. By the way, if your domain is distributed on several machines you will have to run pack and unpack after creating the domain with Weblogic Deploy Tooling because it only works on the node, which will host the AdminServer.
Here you have an example about using Weblogic Deploy Tooling with Ansible to create a domain with SOA https://github.com/textanalyticsman/ansible-soa-wldt
Yes, it is theoretically possible to copy $DOMAIN_HOME (WebLogic domain) to or from Windows.
However, I would NOT copy the $WL_HOME directory. Here a fresh installation is the only way.
As you mention the tool recommended by Oracle would be pack and unpack. With the assumption, that there is no WebLogic security realm configured.
Another option would be to create a new domain (preferable with the same name) with the Configuration Wizard and then copy the XML-fragments from the old $DOMAIN_HOME/config/* files in the fresh domain. Watch out for the encrypted passwords. Don't mix the encrypted fields in the old a new domain.
Another option would to use Windows Subsystem for Linux (WSL2). In this case, you can copy your files 1:1. $JAVA_HOME, $WL_HOME and $DOMAIN_HOME in one go. You WebLogic Server will start without any problems, except some DNS-Names or IP-Addresses issues.

Deploying a Java web application to Amazon

I am sure this question has been asked and answered before multiple times. But unfortunately, I am still not clear. Here is my issue.
I have a JSP, Servlet application which uses MySQL as the database. I have built the WAR file as well. Now I am in need of deploying this so it can be accessed online by anyone.
I looked into lot of areas including normal web hosting. However even though the services like DailyReazor are highly secured, they provide little for MySQL, around 250 MB for the package I selected.
Now I am looking into Amazon AWS. In AWS I am expecting to deploy my aplication and make it available online.The MySQL server should not contain limits like 250MB.
But I have never ever used this service AWS before. By reading various posts, I know that Elastic Beanstalk is the easiest way to go, but still not convinced about how to deploy it properly with database access and all. And in the other hand, will they give me a web address like "www.example.com" or will they simply provide an IP address?? I am also familiar with tomcat so I need to use it.
We will not upload files (images etc) at the moment, so I believe we can manage with around 20$ per month?
I really appreciate if someone can provide a clear guidance on deploying java web applications in Amazon, with the requirements I mentioned about MySQL, Global access and so on.
Amazon RDS for MySQL is a Database-as-a-service offerring from AWS. It is scaleable up to 3TB, and has scaleable IO as well. Of course it also depends on how much you prepared to pay. they manage the DB for you (backup etc). You get a URL to connect, credentials and you are set to go.
Amazon Elastic Beanstalk uses Tomcat. So you should be familiar with that. You upload your WAR file and specify what EC2 flavor you want (CPU/MEM etc). They launch a VM that is configured with Jva and Tomcat and deploy the WAR for you. You get an IP address.
Amazon Route 53 is the DNS service, where you can assign the IP address to your domain (assuming you have one)

How to make website live? (From the point of having it as a Spring MVC project in Netbeans)

Silly question as I just started web dev. Consider that I've got the project build on Spring MVC Framework in the Netbeans (a web site). I would like to make it live.
What is the actual process of making it live considering the fact that I bought the domain and got the hosting? i.e. you upload project in the repository of hosting provider? (not sure if the question is correct, hence correct me if it's wrong)
Can I somehow connect the repository of hosting provider with my Netbeans to update my web site directly from it? (like it works f.e. with svn repository)
First of all, it's a java application that you want to host / publish, so you will need java hosting company.
You need domainname, you can buy one, or get free domainname (there's a few options, you can get free .tk domain, some hosts offer free domain with 1 year prepay as well).
Yes you can connect to your host's SVN with your Netbeans IDE. But deployment process depends on how you will set up your environment on host side. SVN is a place where you keep your source code, not a compiled java application. You can use your host's SVN server, but then still you need to compile java code and build war file which you can deploy under your java server. Some java hosting companies offer Apache Maven, which can helps in your case. Another solution is to build war locally, and upload ready app to your java host account (try to use SFTP or SCP, most of java hosting companies offer SSH access to your account, try to avoid FTP as it's pretty unsecure).

How do you access SQL database from GWT?

I've read some articles on the Internet that this is not possible. To communicate own SQL database that is located on other server from GWT application. Jetty doesn't allow it.
I found a way how to perform it but it's not very cosy. I have client and server part inside GWT. The server has to communicate with MySQL database on localhost. So I've written an ant script to build a war that I can launch on Apache Tomcat server. It works perfectly there but I'm not able to debug the code effectively.
Do you have some advices how to perform this task? I was thinking of writing the clienty only in GWT and find some waz how to communicate my own server written outside the GWT. I've found Apache Thrift for GWT but this edited library of thrift seem not to work properly.
Thank you very much for your answers:)
It is possible to communicate with a database from a GWT application. The client side has to call the methods of the server via GWT-RPC, which can communicate with any database.
Maybe Jetty does not support it (have not tested it personally) but you can develop your web application using Apache too. There you can access the database the same way as from any web application:
You will need the mysql-connector-java-5.1.20-bin.jar file (downloadable from: http://dev.mysql.com/downloads/connector/j/ ), and restart the server added to the $CATALINA_HOME/common/lib directory.
OR added to the WEB-INF/lib folder of your web application.
You can find tutorials online of how to develop an application using Tomcat instead of Jetty. For example: https://wiki.auckland.ac.nz/display/BeSTGRID/Deploying+GWT+to+Tomcat+in+Eclipse
Reshi, stop and think about how applications really work. Nobody provides web pages with javascript to read/write databases, that would be crazy and unsecure. Servers are always in themiddle of all communication in this case. You need to create services that run inside your server, one of these services will be a database layer.
Javascript cant create network connections and read/write binary data, thus it would be insane to attempt to get the gwt compiler to compile any jdbc drvier and more.
Jetty does NOT stop us from connecting to a database. All you have to do is to follow the MVP model way. Although MVP is better bet against all hurdles, at a minimal point, you would have to try not having SQL code on the client package.

Should I implement source control for j2ee application server configuration files?

For a typical J2EE web application, the datasource connection settings are stored as part of the application server configuration.
Is there a way to version control these configuration details? I want more control on the datasource and other application server config changes.
What is the standard practice for doing this?
Tracking configuration changes to your application server through version control is a good thing to ask for. However, It does imply that all changes are done via scripting, instead of the administrative web interface. I recommend
http://www.ibm.com/developerworks/java/library/j-ap01139/index.html?ca=drs-
as a good background information article on this topic.
Update: Just recently, part 2 has been published here: http://www.ibm.com/developerworks/java/library/j-ap02109/index.html?ca=drs-
When working with WebSphere we found the best approach was to script the deployment and place the script under version control plus the response files for each of the target environments.
Websphere canbe tricky as the directory structure is a mess of files - often there appears to be duplicates and it's hard to figure which is the magic file you need to backup / restore . The question of how to go about this should not detract from the need to do it. - which is a definite yes.
Our (Spring) apps have a hardcoded jndi name in the spring config file. That way, the same ear can be deployed to dev, qa and prod environments, and you don't have to worry about database connection details.
The app server admins ensure that a datasource is registered against that jndi name, with the connection details as appropriate on each environment.
But how does this let me manage changes to datasource configurations in the application servers. Here's a scenario:
DBAs change the connection password of the database server.
Webspehere/Weblogic administrator makes corresponding changes to server configuration through administrator console.
The above change is not version controlled so there is no clean way of knowing the history of such changes.
The problem is not about how the application should be configured but about how the configuration changes should be version controlled. Perhaps it sounds like an overkill for simple projects but for some projects, controlling changes like these really becomes a problem.
Any time you ask yourself "should X be in version control" the default answer is "yes".
For a more refined answer, ask yourself this: is the file created by a person (like a source file or a document) or is it generated by another program (like an object file or a distribution PDF)?
File that are created, and/or maintained, by a human should be under configuration control.
We are always using version control for our app server settings. It's a tool called WLST (weblogic scripting tool) which is part of the weblogic server distribution. The domain configuration is stored within a Jython script, which can easily be executed via command line and therefore integrates superb with our build tool maven.
Creating a preconfigured running weblogic domain only needs to execute a maven goal. All those annoying problems of misconfigured jdbc connections or wrong jms destination parameters are gone. You will always have a appserver configuration which matches the source code at a given time. You will never need to remember which app server setting must be applied for this specific version of the project you are working on.
I really recommend this.
I also would like to know, if there are similar solutions for other application server available. As far as i know there is a way for glassfish via ant. How this can be achieved for JBoss?

Categories