This user hasn't shared any biographical information
Posted in Java on March 23, 2013
Problem: “Failed to load Main-Class manifest attribute from” error while trying to call main class bundled in a jar file.
Below is the documentation from oracle related to the above error, but i will also show you how do to do this in case if you are using build tool like maven to bundle your jar file.
Setting an Application’s Entry Point
If you have an application bundled in a JAR file, you need some way to indicate which class within the JAR file is your application’s entry point. You provide this information with the
Main-Class header in the manifest, which has the general form:
classname is the name of the class that is your application’s entry point.
Recall that the entry point is a class having a method with signature
public static void main(String args).
After you have set the
Main-Class header in the manifest, you then run the JAR file using the following form of the
java -jar JAR-name
main method of the class specified in the
Main-Class header is executed.
We want to execute the
main method in the class
MyClass in the package
MyPackage when we run the JAR file.
We first create a text file named
Manifest.txt with the following contents:
Warning: The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
We then create a JAR file named
MyJar.jar by entering the following command:
jar cfm MyJar.jar Manifest.txt MyPackage/*.class
This creates the JAR file with a manifest with the following contents:
Manifest-Version: 1.0 Created-By: 1.7.0_06 (Oracle Corporation) Main-Class: MyPackage.MyClass
When you run the JAR file with the following command, the
main method of
java -jar MyJar.jar
Setting an Entry Point with the JAR Tool
The ‘e’ flag (for ‘entrypoint’), introduced in JDK 6, creates or overrides the manifest’s
Main-Class attribute. It can be used while creating or updating a JAR file. Use it to specify the application entry point without editing or creating the manifest file.
For example, this command creates
app.jar where the
Main-Class attribute value in the manifest is set to
jar cfe app.jar MyApp MyApp.class
You can directly invoke this application by running the following command:
java -jar app.jar
If the entrypoint class name is in a package it may use a ‘.’ (dot) character as the delimiter. For example, if
Main.class is in a package called
foo the entry point can be specified in the following ways:
jar cfe Main.jar foo.Main foo/Main.class Pom.xml
where com.MyPackage.MyClass is the file where the main method exists and classpathPrefix is something where i am expecting some dependant jars to be available. We are interested in mainClass element at this time.
This is how Manifest.MF looks like in META-INF folder inside the jar file
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Main-Class described above will help to load the main method.
Posted in Axis2 on March 23, 2013
Installing Axis2 WAR Distribution
- Download the Axis2 WAR distribution from here: http://axis.apache.org/axis2/java/core/download.cgi
- Deploy it as an exploded directory in your preferred Servlet Container (JBoss, Tomcat, etc).
- axis2.war will be the container to hold multiple aar files, which independently are axis projects themselves
- Go to the axis2.war/WEB-INF/conf/axis2.xml file, and set the hotupdate parameter to true, as follows:
|…<parameter name=”hotupdate”>true</parameter>Check that the Axis2 webapp was successfully deployed by going to this link http://localhost:8080/axis2/ and clicking on ‘Validate’.|
Developing a contract-first web service
- Create a Maven project in eclipse.
- Copy your wsdl and xsd files to src/main/resources. Note: This process assumes you already have an existing WSDL file with external xsd files for the messages definition (Contract-first approach)
- Copy the following to your pom.xml file:
- To generate the java sources from the wsdl, run: mvn clean generate-sources -Pcodegen. This will create the input and output objects of every service, as well as the skeleton files and the services.xml file.
- Copy the files from target/generated-sources/axis2/wsdl2code/src to your src folder.
- Copy the services.xml file from target/generated-sources/axis2/wsdl2code/src to src/main/resources
- Edit the Skeleton class to include the logic you want.
- To generate the .aar file, run: mvn clean compile axis2-aar:aar
- Copy the generated .aar file from target to testws.war/WEB-INF/services
- WSDL URLhttp://host:port/axis2/services/test-services?wsdl
Posted in Microsoft on March 3, 2013
If you would like to convert all your 2003 office documents to 2007, but would like to do all of them in a single shot, here you go.
1. Download Migration Manager from microsoft and install it, which is a free tool
2. Download Office compatibility pack
Once step 1 is done, open the folder where it is installed and look for tools\ofc.ini
Below ofc.ini is complete file and we are interested in one part, the path to provide the source folder under [FoldersToConvert], make sure you have this fldr=C:\localfolder (without a ; before fldr and where localfolder is name of your folder)
; The Converter will attempt to convert all supported files in the specified folders
; (do not include if specifying FileListFolder)
Also you can update DestinationPathTemplate to the path where your converted files need to be available
4. Now open cm.exe and navigate to folder where migration manager is installed and simply run the cmd as ofc.exe
all your files will be converted and available in destination provided above without original files getting affected.
Posted in Unix on January 29, 2013
Specific to CShell……….
1. How to comment multiple lines in shell scripts
Line 1 to be commented
Line 2 to be commented
and so on….
2. How to loop through files in a directory
if (-d $dirpath) then
foreach file (-d $dirpath)
3. How to get filename from filepath
org.apache.cxf.interceptor.Fault: Unmarshalling Error: Unable to create an instance of scala.collection.immutable.List
Problem: Trying to call CXF Service, which is calling scala functions utilizing scala List object and getting the error org.apache.cxf.interceptor.Fault: Unmarshalling Error: Unable to create an instance of scala.collection.immutable.List when calling the CXF service
Basically CXF unable to marshall the request to cala List object. Check for the scala function where you are using Scala List object, change it to java.util.List object by explicitly mentioning the List object as java.util.List. Also, in the files where you are doing this,
which works in scala 2.8 and above
Problem: Converting from reference cursor to oracle pipelined results
Solution: Package body declaration is shown here, it is assumed that the specification is already taken care to declare the pipelined record datastructure, if not please look into my other posts on how to declare the specification part of it at
(firstName IN VARCHAR2 DEFAULT NULL, lastName in VARCHAR2 DEFAULT NULL)
return customerpipelineddata PIPELINED AS
–select statement goes here
open v_customerdetails for (select statement query)
–Below is the part needed to have reference cursor data into pipelined data
fetch v_customerdetails_cursor bulk collect into output_record limit batchsize;
for i in 1 .. output_record.count() loop
pipe row (output_record(i));
exit when output_record.count < batchsize;
here customerpipelineddata is the actual pipelined data record, a set of records of a particular data structure like
TYPE customerpipelinedrecord IS RECORD (id varchar2(100),firstname CUSTOMER.FIRST_NAME%type);
TYPE customerpipelineddata IS TABLE OF customerpipelinedrecord;
Hope this helps….Please do not forget to like or post your comments 🙂
Posted in Java on November 13, 2012
The OracleXMLQuery class generates XML given an SQL query.
This methods generates the XML Schema(s) corresponding to the specified query; returns the XML Schema(s).
Transforms the object-relational data, specified in the constructor, into a XML document. Returns the string representation of the XML document. The options are described in the following table.
Following snippet converts oracle result set to XML WHERE cs is a valid callable statement object and rs is the jdbc result set object
OracleXMLQuery qry = new OracleXMLQuery(cs.getConnection(),rs); // prepare Query class
str = qry.getXMLString();
Above snippet will create XML in the following format
we will see in the next tutorial on how to transform this generated XML to user defined XML schema definition using XSLT