Excluding jar files from GWTP war file - gwt-platform

Currently I am working on a GWTP application. While deploying to application server I remove all the jar files from the application.war file and then I push the war to webapps. I have put all the jars in the application server lib directory. The application works fine. I just have to know, can we remove all the jars from WEB-INF/lib of war file. Is this approach right? please let me know.
And also I have another question. I manually remove the jar files from the created war file which got created using ant. Please give me examples to automatically remove jars from build.xml.

I see only disadvantages from this approach:
If you want to run another application on your server which use an other version of a library, you can't.
Each time you update a jar in you dev environment, you will need to manually copy it to your server lib/ directory instead of having it automatically packaged.
Why having them in WEB-INF/lib bothers you?

Related

Shell script to replace a class file

I have read many posts about changing the contents of a file and replace the whole file, but little did I understand.
Referred this too. The .sh is the one that confuses me. Do I need to use .sh in my case too. I don't want to ruin the project by trying something new, without much understanding.
How do I replace a class file in a jar? I have the class file ready from my workspace. All I need to do is replace the already present class file in the jar. Moreover, need I restart the server after replacing, to see effects?
The application server that we are using is IBM websphere.
Should I also navigate to my ear file location in the server? For example, cd aaa/bbb/ccc and then execute the command.
Please help, I am totally new to this.
To extract/pull a particular class from your ear:
jar -xf sample.ear com/sample/Example.class
then overwrite com/sample/Example.class with your generated class and finally do:
jar -uf sample.ear com/sample/Example.class
To update the ear file again with updated class file.
PS: This will require you to deploy the ear file again on your app server and then restart the app server. I would also suggest looking into ant or maven for this task.
.sh file is an example of one of the file from jar that you wish to extract it from jar and edit the extracted file and then again archive it back to the jar... in EXAMPLE
so you don't need .sh if your file name is not ending with .sh..

Liferay projects building in wrong deploy folder

Working with liferay and portlets from last 3 weeks.
I downloaded the bundled liferay server and placed it on my local drive.
I did the set up and was able to access localhost:8080 properly.
I also created some custom portlets and when build them in eclipse the war files were getting deployed in the path C:/liferay/deploy.
Now, I changed the server location, I wanted to have the server in D:/ drive.
When I did the transition, started the tomcat server from D:/liferay/tomcat/bin/startup.bat
and then build the project, the war files are still building in c:/ drive.
When I copy the war file manually from c:/liferay/deploy to D:/liferay/deploy it gets deployed successfully.
I want the war file to be created directly in the d:/liferay/deploy folder.
Can someone help me understand what all changes do i need to do here?
If you are using Liferay plugin sdk then there would be file named as
build.<userid>.properties
in your plugin sdk.Change the below properties as per new configuration and give a try
app.server.portal.dir
app.server.lib.portal.dir
app.server.lib.global.dir
app.server.deploy.dir
auto.deploy.dir

How to edit Websphere server runtime library

How do I add/remove jar files to the WebSphere Application Server v7.0 library? It's not the 'Edit' button. I placed some new jar files in {WAS_HOME}/runtimes/base_v7plugins/ hoping they would be picked up on the next restart, but it didn't happen.
I believe IBM does not support using WAS product jar files in to the 3rd party tool. However if you can give me some more details what exactly this tool is ? and what exactly you are trying to do ?
You should not be copying all the jars file from plugins folder .
Only jar files that you can use on the client side from WAS product is from /WAS_HOME/runtimes folder.
Hope this helps.
-VT
Note: These opinions are my own .

How to deploy a WAR file on Linux machine

I have a Linux Machine. Apache server is running and I need to deploy my project which is a .war file developed on Windows machine.
Can someone give me bit idea how to do that?
if you have FTP or SCP access to the directories where Tomcat is installed, you should be able to simply copy the generated WAR file to the tomcat/webapps directory. Tomcat will automatically deploy the war for you.
When redeploying, I find it safest to delete the original .WAR file in Tomcat, and tomcat will automatically destory the exploded directory for you. When that's done, copy up the .WAR file.
Finally, make sure you copy the .WAR file "all at once". If you have a slow upload, Tomcat will try and deploy the .WAR file even though it has not completely been uploaded yet. This will lead to a partial or unsuccessful deployment. It's best if you upload to a neutral directory (home directory, temp, whichever), and then either rename (using mv) the .WAR into tomcat, or simply copy it there using the local file systems copy command. Much faster than the upload. Safest way is to mv the file from the same filesystem.
All of this assumes you do not have any of the manager or admin ports open for Tomcat, as it provides mechanisms to remotely deploy applications directly.
But, in truth, simply removing the old app and slipping in the new app works simply and well for many applications.

J2EE and Standard Java Application Log4j.properties

I have a project folder with merged J2ee application and standard java application. I am having trouble with configuring the Log4j.properties. I want to have separate log files 1 for my web application and another 1 for my standard application. I have two Log4j.properties files one under the root package of my web application and one under the root package of my standard application where both packages are under src folder.
When I ran both web app and standard app specifying only the file name, the log file for my webapp is created in the web server directory but my standard java app log file is created inside my WAR directory. I want the log file for my standard java app and my web app to be placed in the root folder that is why I specified in both log4j.properties absolute path to that folder. The problem is the only created log file depends on which log4j.properties file was detected and logs for both my web app and standard java app was written on that one file
This will be a detective work since I'll have more questions than you did.
I have a project folder with merged J2ee application and standard java application
This distinction seems to me a bit blurry. You have one project folder for two applications? It would be easier if they were separated. Is your standard java application a standalone application that can be run on a command line? A set of utility classes like a library?
I want to have separate log files 1 for my web application and another 1 for my standard application
I believe here lies your problem. If you're using your standard application's libraries in your web app, then during loading the application server will find two log4j.properties files on the classpath. You can not be sure 100% how this will behave.
When I ran both web app and standard app specifying only the file name, the log file for my webapp is created in the web server directory but my standard java app log file is created inside my WAR directory.
Running a web app specifying only the file name is unclear. What file name? When you say your WAR directory, do you mean the directory of your webapp, that's also inside your web server directory, or the directory under your (I'll assume you use Eclipse) IDE's project folder?
I want the log file for my standard java app and my web app to be placed in the root folder that is why I specified in both log4j.properties absolute path to that folder.
Root folder, like / in *nix? If you want them both to be placed in one folder, then you should remove one of log4j.properties files.
The problem is the only created log file depends on which log4j.properties file was detected and logs for both my web app and standard java app was written on that one file
Yes. You need to have only one log4j.properties file.

Resources