Deployment with Eclipse, Git and Elastic Beanstalk - java

Is there a way to specify if the java source files are included in the WAR file when deploying through eclipse?
Please consider the following scenarios:
Using export to war: This is simple and straight forward. If you check the check box marked "Export source files", then the source files are included in the WAR.
Publishing to the local Tomcat server: The source files are never included in the wtpwebapps directory and there is no WAR file. Again, simple.
Publishing to Elastic Beanstalk through the eclipse AWS toolkit on a Windows machine: The source files are ALWAYS included with the WAR file (which is exploded into the git folder and then deployed as a Zip file).
Publishing to Elastic Beanstalk through the eclipse AWS toolkit on a Linux (Ubuntu) machine: The source files are NEVER included with the WAR file which is eventually deployed.
I have not found a way to stop the source files from being included in 3 or include them in 4. This may well NOT be an OS issue, but a simple setting in some configuration file that is set differently on the two machines. Or it could be the way the plug-ins were written for the two Operating Systems (are plug-ins OS specific?). Even if that's the case, is there a setting where it can be changed?
I tried playing with the Web Deployment Assembly settings, but couldn't figure out how to make that work as far as source is concerned.
Any insight you may have into this will help.

Related

Running website on Tomcat 7.0: Windows 2008 R2

My team and I originally had a server running through Eclipse (Java EE), but wanted to switch it to running on the Tomcat 7.0 service found in Windows 2008 R2. We are completely clueless on what files to put where in the Tomcat folders found in program files. The entire server has gone down and we can't go back to the original setup. Any help is appreciated. All we're asking is where do we put our JSP/ROOT ect folders in the Tomcat program files.
Copying JSP files are not good idea rather you can package your jsp file into an archive file called WAR file. You can export your project from Eclipse IDE as a WAR file.
After creating the WAR file (.war), you need to find out tomcat installation directory and its called tomcat HOME. Now you just need to copy the WAR file into the following folder:
{TOMCAT HOME}/webapps/<project>.war
I'll add to the answer.
If you have folders of running applications from before you can put 'em under
{TOMCAT HOME}/webapps/
war file will un-zip after you start the service.
once the war is un-zipped, you can delete it, but only after you stop the service for the first time after war deployment.

Steps to deploy web application on JBoss via install4j installer

I am not sure where should I start from as I have to deploy a web application on JBoss via install4j installer.
I have created the Dynamic Web Apllication and I want to deploy this application on JBoss but deploy a war file and configure JBoss on client machine is not a good idea thus I want to create a installer file (.exe) file which will take care of following things:
Installation of JBoss server on client machine
Deploy my application on JBoss server
so that I just have to give that installer file to client and on single click the installer will do all the things for me and as I am new to install4j tool, I am not able to do this with install4j tool.Anyone can provide simple steps to create .exe file using install4j or any other tools
EDIT
what I tried so far
General Settings
1.1 Application Info
Specify all The information like full name,Short name,version...
1.2 Java version
min version=1.4
max version=1.7
*NOTE: Confuse about the Environment variables JAVA_HOME,JDK_HOME*
1.3 Languages
English-en
1.4 Media File Options
Media File Output Directory:*/home/shekhar/*
Media file Pattern
name:${compiler:sys.shortName}_${compiler:sys.platform}_${compiler:sys.version}
Use LZMA compression
Note: Rest of options are unchanged
Files
2.1 Distribution Files
Add Files and Directories:specify the path where application exists
Note: Rest of options are unchanged
Launchers
3.1 Generated Launcher
add a new Launcher
Installer
Unchanged
Media
Installer
create a new installer by default
build
6.1 Start Build
Preparing configuration
Creating media file 'Unix Installer':
Collecting files:
Compiling launchers:
Compiling launcher 'connector':
Generating launcher script file
Generating VM options file connector.vmoptions.
Creating media file:
Generating launcher script file
Zipping custom code & resources JAR file
Identifying components
Shrinking runtime
Compressing files
Applying LZMA compression
Moving media files to media directory /home/shekhar/Desktop
The name of the media file is she_unix_1_0_0.sh (click to execute)
The size of the media file is 1.7 MB
Writing md5sums.
Writing updates.xml.
To check your settings, you can generate a project report
Build was completed in 13.9 seconds.
I have run this exe but it has created application folder structure but where is JBoss Configuration and how can i deploy this apllication on JBoss
Deploying a web application locally involves copying a WAR file to a specific directory which in the case of JBoss is the standalone\deployments directory. in install4j, you can use a "Copy file or directory" action to copy a war file from a distribution tree to an arbitrary directory.

importing an eclipse project from file system, then running on server

I am trying to do the spring security tutorial at this link.
In the section entitled "Running the Tutorial application without Spring Security", I took the following steps (adjusted for differences between the current version and the version that was in use when the tutorial was written):
1.) I downloaded the latest release of the Spring Security Distribution,
2.) found and unzipped a war file in the dist directory called spring-security-samples-tutorial-3.1.2.RELEASE.war
3.) Renamed the resulting folder spring-security-tutorial
4.) Created a general project in eclipse called spring-security-tutorial
5.) Imported all of the contents of the unzipped spring-security-samples-tutorial-3.1.2.RELEASE.war
6.) Right clicked on the project in eclipse and selected configure...convert to maven project
7.) Then right clicked on the project and clicked run as...
But there was no "run on server" option. (I had chosen a general project instead of a Dynamic Web Project in hopes of preserving the file structure of the application to be imported)
I then started to repeat the process, but creating a Dynamic Web Project instead of a general project, and eclipse wants me to select the "src folders on build path". The file structure of the web application has 8 .class files in subfolders of WEB-INF, and I am not able to locate any .java files.
What steps can I take in order to download this and run it in eclipse on the server? With the ability to edit the classes?
I have read that I can select a .class file in eclipse and it will open the bytecode in the editor, so I imagine I can convert the class files to java files easily enough. But doing that within a general project triggers the error message that the class is not part of the classpath, so we need to get it in a working web project that can be run on the tomcat server from within eclipse first, I think.
A war file is a Web application ARchive (basically a zip). It is meant to contain a web application's compiled class files and resources (properties files, jsps, css, html, js, etc.). It a package that can be used by an application server (or servlet container) like Tomcat. Except through a Decompiler, you will not have access to the source code from the compiled .class files.
I doubt you can run this on Eclipse's Tomcat instances. Instead go to your Tomcat installation. Mine is at C:\apache-tomcat-7.0.22. Rename the war to something simple like security.war and place it inside the webapps folder, ie. C:\apache-tomcat-7.0.22\webapps\security.war. Go to C:\apache-tomcat-7.0.22\bin and execute the startup.bat Windows batch file. This script sets up the classpath and launches a Java application containing all the applications in webapps. You can see the startup logs in C:\apache-tomcat-7.0.22\logs\catalina.out (as you would normally in Eclipse console).
You can then go to localhost:8080/security to hit the application. Replace 8080 with whatever port you're configured on. security is the same name as the war file. When Tomcat starts (based on a config parameter) it will extract the war into a package directory under webapps with the same name.
You can play around with configuration settings. Some of the important ones are here.
You can shutdown Tomcat by running the C:\apache-tomcat-7.0.22\bin\shutdown.bat Batch file script. You'll have to do this and restart if you change something in the application (ex. the web.xml or a properties file).
I think the tutorial you linked was meant more for trying security settings than actually changing the source code. I'm sure there are other samples online for Spring security, I just don't know them.

Deployment to Tomcat using War file resulting in ClassNotFoundException

I am developing a web application and have hit a wall and could use some advice. So the application was written by a coworker who is no longer at our company. They wrote a web application for Apache Tomcat with Java and Javascript in the back end. The application makes use of the JDBC api to interface with a SQL Server database. This person did all the development in Eclipse and running it this way.
I am trying to take this web application and move it to a server. I attempted this by using Eclipse to export a WAR file and then placing this within the Tomcat webapps folder. Then when I started Tomcat the program was extracted. So far so good. The website comes up and works well. However, when I try to access the pages which rely upon database info everything is coming up NULL. I went through the Tomcat logs and found that in the standard out the following message was given:
ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
I had assumed that the WAR file would include all dependencies but I am guessing that probably this is not the case. If anyone is experienced, is this what has happened? If anyone out there is aware, is there a way to tell Eclipse to do this? Otherwise, what is my option? I am not a Java dev and so I would not know how to install JDBC if needed.
Any help is appreciated.
Mike
You can do the following
Go to Microsoft JDBC Driver download page and download the JDBC driver and install it to a location.
Open the .war file using a zip utility like 7-zip or winzip.
Copy the sqljdbc.jar from the sqljdb_4.0/enu directory where you installed the downloaded JDBC driver and paste it in WEB-INF/lib of the extracted war file.
Zip it back as .war file and deploy it again.
This will get the application running.
If you want to fix this permanently, then you should add the stop to include sqljdbc.jar to your WEB-INF/lib while building war file, in your build system, i.e. in build.xml if you are using ANT or in your Maven's pom.xml under dependencies section for this particular dependency.
You don't need to do the "Export WAR > copy to tomcat > start tomcat" manually, you could configure eclipse to do the deploy directly in your tomcat installation, firts double click tomcat server, and then select "Use tomcat installation" in the "Server Locations" section.
Make sure that your application contains the SQLServer JDBC driver (sqljdbc4.jar) in your project WebContent/WEB-INF/lib directory (assuming your coworker used the Eclipse "Dynamic Web Project" for the project layout), if not, download from here, unzip and copy it to the mentioned folder, the next time you start tomcat, it will automatically add it for you.
If the project uses the maven project layout (there is a file named pom.xml in the project root folder), use the following instructions to install the dependency in your local repository (there are some disagreements between Maven and Microsoft about licensing and redistribution of the driver, so there is no repo)

Can we update a jar / war file in a deployed server and then reload the new jar / war file?

Can we update a jar / war file in a deployed server and then reload the new jar / war file ?
if so how simple we can achieve this, and please if possible list web servers which support this feature.
Yes.
All major Java EE Servlet containers support this. All that I've worked with anyway, which includes Glassfish, Tomcat, WebSphere, WebLogic and JRun.
I haven't used the other Oracle container, but I would think it does too.
That said, none of them support it all that reliably (they'll detect most changes, but there are certain types of class changes that will always require a restart), unless you're using JavaRebel underneath.
Just by copying the 'war' file in the Server domain folder will automatically deploy it. I have done it with glassfishv3.1
The path for windows is C:\Program Files\glassfish-3.1\glassfish\domains\domain1\autodeploy
Once pasted another file gets created automatically [if the server is on] in the same directory
For the editing purposes the 'war' file can be opened with programs like WinRar or WinZip
Just open the files that you want to change and save it when the winrar asks for it.
Both Tomcat and Jetty will support a hot deploy. They simply monitor the deploy directory for changes, so you can just copy the .war file into that directory, and the server will undeploy/redeploy.
JBoss. Just drop in the files in the correct location.

Categories