Introspective Introspective - 1 year ago 117
Java Question


I am trying to follow this Apache CXF – JAX-WS – Simple Tutorial but building the downloaded sample (out of the box!) creates a client that upon invocation refuses to run, issuing this error:

Failed to load Main-Class manifest attribute from

I searched to find out more about this problem and found out this SO answer which prompted me to hack SampleWSCxfClient-0.0.1-SNAPSHOT.jar by opening it using
and adding into a file name
the following line:

Main-Class: com.areyes.sample.client.SampleWSClient

I figured out that main class by simply looking at the only Java file in the project:

package com.areyes.sample.client;

import com.sample.service.SampleWebService;

public class SampleWSClient {

public SampleWSClient() {

ClassPathXmlApplicationContext classPathXmlAppContext = new ClassPathXmlApplicationContext("classpath:META-INF/beans.xml");

SampleWebService sampleWebService = (SampleWebService)classPathXmlAppContext.getBean("client");



public static void main(String[] args){
new SampleWSClient();

I then tried to invoke SampleWSCxfClient-0.0.1-SNAPSHOT.jar again, but this time it fails with:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractApplicationContext
Caused by: java.lang.ClassNotFoundException:
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
Could not find the main class: com.areyes.sample.client.SampleWSClient. Program will exit.

How do I make this sample work?

For your convenience, the entire sample package ZIP can be downloaded from here.

Answer Source

I once came across a similar problem and after being unable to decipher the magic of running "a jar with many dependencies" from the command line, I worked around it by running it through Maven.

Try this:

mvn exec:java -Dexec.mainClass=com.areyes.sample.client.SampleWSClient
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download