GWT Deployment Confusion, Please give some guidelines - gwt

I wanted to know one thing. When deploying a GWT application on
the server, lets say an application in which there are client files
Greeting.java(entrypoint), service.java,serviceAsync.java and server
file serviceImpl.java(), only the client files will converted to
javascript. After compilation, I take the war file and place it on the
server, but where to place the server file that is serviceImpl.java???

The war file will also contain a /WEB-INF folder with the web.xml your libs and the other java classes needed for the server side.
So you only need to copy your war file in the proper webapps folder from your server.

Related

Bring back the original project from a WSDL file or a WAR file

We have lost our java code that implement a web service. Now we have only a wsdl file (and a WAR file) published in tomcat. We need to bring back the original java project so I have tried to generate java source code from WSDL file (and WAR file) and I succeeded -by using axis2 (WSDL2JAVA) plugin- but I think it generates only the java classes that should exist in the src package of the project.. no welcome pages or index.xml etc.. I Don't know what other things are missing and how to bring them back.
My question is: what to do after generating java classes from WSDL file? should I complete the other project parts in my own? Is there a way to bring back exactly the original project from WSDL or WAR file?
As per the Scenario you mentioned for WAR file you can use JAD tool to unpack the whole code but with certain limitations like you cannot edit or save the code and I am not sure about the copy feature because it was not working for previous version.
Here is the link below.
https://varaneckas.com/jad/

Problems with relative paths in Eclipse.

I am trying to use relative paths in a Dynamic Web Project in Eclipse. I am NOT using them in the Servlet, but in another class that is called by the Servlet. The file I am trying to access to is a property file located in
MyProject/WebContent/WEB-INF/propertyFile.properties
I have tried almost every relative path...
WebContent/WEB-INF/propertyFile.properties
/WebContent/WEB-INF/propertyFile.properties
./WebContent/WEB-INF/propertyFile.properties
MyProject/WebContent/WEB-INF/propertyFile.properties
/MyProject/WebContent/WEB-INF/propertyFile.properties
WEB-INF/propertyFile.properties
/WEB-INF/propertyFile.properties
./WEB-INF/propertyFile.properties
...and so on...what can I do?
Thanks in advance!
You nee to understand that file IO read files, from the filesystem, and relative to the directory from which the JVM (i.e. your web container) is started.
Remember that, once your app is deployed to production, there won't be any MyProject or WebContent folder. That's what exists on your development machine. The only thing that will exist in production is the war file deployed in the application server.
What you actually want is to load a resource, located in the deployed web application (i.e. which is inside your war file).
To do that, you must use ServletContext.getResourceAsStream():
InputStream in = servletContext.getResourceAsStream("/WEB-INF/propertyFile.properties");

Tell Glassfish to Use Existing Zip File

I am using Glassfish 3.1.2 with Dojo 1.7 and would like to shorten the build process, it's taking quite a while for maven to copy the dojo js files each build. I could use the CDN version dojo but I would like to be able to debug when offline. Is there a way to tell Glassfish to use the pre-zipped dojo source file? Just to be clear, I don't want Glassfish to zip the files for me.
Can you place the desired resources in an independent WAR file, and deploy separately? You'll have a context path to the resources (diff URL) that is dependent on the new WAR file, but you'll be able to deploy it once.
If that's not satisfactory, you could alternatively write a small servlet (packaged in your normal app) to expose resources that you locate (*.getClass().getResourceStream()) from a jar file you've placed in glassfishv3/glassfish/domains/domain1/lib. This is trivial to do via a restful-ws, also some libraries (primefaces) facilitate exposing resources.

hosting GWT project

What do i need to upload from my gwt project to web hosting?
its just html or all project files?
Any modern Java IDE gives you an option to export a web project as a war module. If your are not using an IDE, it depends:
If you just write your code under client folder, no need to upload any .class files to the server. You don't need any Java Application server as well, and a normal HTTP server (such as Apache) would suffice. An example of such a GWT application is GWT showcase which is included in GWT download package.
If you have any server-side code under server package, then you should upload .class files (under WEB-INF/classes folder in your web modile) as well as the rest of .js, .css, .jpg/gif, .html files. In this case you need a servlet container such as Tomcat to serve your server-side code.
You'll only need to upload the html files, the css files, and your java file. Also, any other file linked to within your html files need to go in the same directory.

Deploy war file with modifiable properties files

I am building a web service and am packaging it into a war file for deployment. Right now all of my config files (.properties and .xml) are being packaged into my .war file. This isn't going to work as some of these files will need to be modified for each individual installation. I know that some servlet containers will leave the .war files intact which would mean the config files would never be easily modified. My question is this: what is the best practice for deploying a .war file with these external config files? I'm thinking that the config files will need to be shipped separate from the .war file and placed into a directory that is in the classpath. Is there a default directory setup like this in Tomcat that these files can just be dropped into and my web service will be able to find without much trouble?
Maybe I shouldn't be using a war file for this setup? Maybe I should just be providing a zip file (with the same contents as the war file) and the deployment will simply be to extract the zip into the webapps directory?
I do not know any default directory in Tomcat to store configuration, my
attempts to solve the same issue have been :
1 - Move configuration to the DB and provide scripts or webpages to modify values.
2 - Have a script to deploy the war. The script would merge configuration from a user directory into web.xml or other deployed config files.
3 - Have webapps look first in a user directory for configuration and
if not found then look for configuration files deployed by the war.
Least favorite is 3 - it require all webapps to check two places for configuration and
you end up with two different xml files on the server with different values and it is not always clear which one is used.
Next favorite is 2 - the webapps can be written without knowledge of multiple config files, but you run into issue when someone does a deploy from Tomcat manager instead of using your script.
Favorite is 1. This just works in most cases. Problem is when you don't have a DB or
want to configure how you connect to the DB.
If having the file visible from all webapps is not an issue, you could put it $CATALINA_HOME/lib.
One solution is to modify property file after deployment of war file is to use ServletContext.getRealpath() method to get the real path means path of file in the server where it is deployed and then modify that file it will modify file in container only not the original file. So you need to backup it if it is important modification for you. So by this you do not need to redeploy war file as it is already modifying file from deployed container.
This solution can edit a file that is in webpages folder also from the java class.
If you want more description or how to do it then let me know i have did it.