Shell script to replace a class file - linux

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..

Related

creating a jar file - preserving file permissions

I would like to know how to create a jar file that preserves the file permissions of its content.
I'm packaging up source and executables in a jar file that will be extracted before use. People should be able to immediately run the examples and demonstrations by running batch / shell script files. Then they should be able to modify source and re-compile everything.
I'm trying to make life easy for people who use it and this includes people who are new to Java and programming who might be working on Linux / Unix.
I have access to machines running Windows and Linux. I don't use Linux a lot so maybe I've done something wrong.
I created a jar file on Linux using jar cf .... after setting permissions on the files so that everything worked as needed. Then I created a new test directory and extracted the jar file contents into it. The file permissions were not preserved ... i.e. -rw-rw-r--
The jar tool doesn't store file permissions, so you can't recover what has not been stored. jar format is not intended to archive files and metadata as zip or tar, it is a simple container to embed java files for an application.

WS02 ESB - How to get Custom java class property file on the classpath

I have loaded a custom jar file into WSO2 by placing it into the /repository/components/lib directory, performing a restart. I then call that class from a script mediator using inline groovy. The groovy script recognizes the class, however the custom class is attempting to load a properties file that must be on the classpath. I have put that property file nearly everywhere but I keep getting an error that it cannot find the file on the classpath.
I am running the standalone WSO2 ESB 4.7.0. I have put the file as part of the jar, I have also attempted to place it in several directories within the WSO2 file structure as well. All to to avail.
you could try to register a resource in the carbon registry and add a Property to this Resource. Basically there are two ways (in java...):
Here is an example how to connect to the registry via a service with the PropertiesAdminServiceStub: http://www.massapi.com/class/org/wso2/carbon/registry/properties/stub/PropertiesAdminServiceStub.java.html
The most important here is that you authenticated your user, the result is a cookie which yoou have to add to the stub.
The other would be something like this (probably a duplicate of your question)
I am unable to get the list of services with in the applicaton i.e.; wso2 governance registry? I am working with binary code
The last one asumes that the carbon-context is available, means you are running the search inside the wso2 like a feature for example.
Unfortunately there is no place to put that properties file. Luckily this jar file, is an in house entity. It was written to search the classpath for the properties file and upon not finding one on the classpath to throw an exception. We ended up rewriting the code that loads the properties file to upon not finding the file on the classpath to search in a directory which we specified as a system environment variable in the wso2server.sh file. Not very elegant, but it is working perfectly.

Issue with App.Config in the Startup Folder

I am writing a console app in c#.net. I have a batch file that currently copies the exe and exe.config to the startup folder on local machine from the network. It is set up that way so the user only has to run the batch file and then everytime the computer is started the exe will run.
Problem I am running into is that it also opens (or tries to open) the exe.config file as well. I am looking for the best workaround for this without it being overly complicated. Thought about putting the config file in a diferent location and then hardcoding the new location into the configuration manager but one of the concepts with the config file is to keep all hardcoded paths out of the code for easier updates if locations change. Also thought about putting a shortcut to the exe in the startup folder which would work but I want it to be transparant to the user. In other words all I want the user to do is run the .bat file once and forget about it.
Any help or ideas would be greatly appreciated as I am very new to .bat files
I like your idea of a shortcut, or for that matter a batch file pointing to the executable, with both the executable and config file located outside the startup folder.

Excluding jar files from GWTP war file

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?

How do I add a project to CruiseControl.NET?

I am looking at the cruisecontrol web dashboard. I can see one farm and one server. However, I don't see any way to add a project?
Is this something I can do with the UI or do I need to edit the config file by hand?
You'll need to edit the ccnet.config file by hand (located within the CruiseControl directory) to add projects. There are some graphical tools to help you do this however you do get used to doing it by hand fairly quickly - just have the documentation near by!
Update: An example of one such tool is http://www.codeplex.com/ccnetconfig
You can use CCNETConfig to edit the config file through an UI although it doesn't support higher version > CruiseControl.NET 1.4.
You have to basically edit the configuration file by hand, however I have it setup so that the raw config file is split into different include files, each of which is setup in my source control system. Then I created a project for the configuration, and then for the whole config. So when something changes in the config, CC.NET itself pulls out the changes, recreates it's config files and the refreshes the system configuration.
This means that anyone can edit the config (if they can access the files in sourcecontrol), and no-one has to go into the program files directory of the CC.NET machine itself.
Not sure whether this answers the question you asked, but this is how our setup works

Resources