[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

03/27/2009 at 10:21PM PDT, ID: 24273280
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Classpath Problems running executable jar created with maven2

Asked by CarlosScheidecker in Java Programming Language

Tags: mvn maven jar junit executable jar-with-dependencies

Hello all experts,

I've created a pom to generate an executable jar that has included all the dependencies.

When I run this pom with mvn I successfully compile the whole thing and the final jar includes all the classes from the dependencies like junit and one of my jars myproject-common. Its classes are properly organized into dirs and subdirs inside the jar representing the package name. The jar has everything it needs inside.

However, when I execute it doing java -jar MyProject-itests-2.2.0-jar-with-dependencies.jar I have a class not found for one of the classes from my myproject-common jar which IS inside this MyProject-itests-2.2.0-jar-with-dependencies.jar.

Somehow, it cannot locate the class and so the tests fail. However it can locate the classes from junit, just not from my own jar which is part of it also as per my last dependency "myproject-common"

I need some help fixing my pom.xml so that when I execute the jar it works without the error: java.lang.NoClassDefFoundError: Could not initialize class com.scheidecker.SoapAccessUtil . The class is inside the jar inside com/scheidecker/SoapAccessUtil.class

So, first : Is my pom.xml wrong so that my MainTests class cannot see the myproject-common classes which are inside the jar?

Second, is my command to run the jar incorrect?

Thanks in advance.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<!-- POM version for Maven 2 -->
	<modelVersion>4.0.0</modelVersion>
 
	<!-- The Basics -->
	<!--
		groupId, artifactId, version, packaging, dependencies, parent,
		dependencyManagement, modules, properties
	-->
	<groupId>com.scheidecker.itests.ad</groupId>
	<artifactId>MyProject-itests</artifactId>
	<packaging>jar</packaging>
	
	<parent>
		<groupId>com.scheidecker.authentication.ad</groupId>
		<artifactId>ad</artifactId>
		<version>2.2.0</version>
	</parent>
	
	<dependencies>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<version>4.4</version>
			<!-- <scope>provided</scope> -->
		</dependency>
		<dependency>
			<groupId>junit</groupId>
			<artifactId>junit-dep</artifactId>
			<version>4.4</version>
		</dependency> 
		<dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<!-- <scope>provided</scope> -->
			<version>1.1</version>
		</dependency>
		<dependency>
			<groupId>com.scheidecker.dependency</groupId>
			<artifactId>myproject-common</artifactId>
			<version>2.2.0</version>
			<!-- <scope>provided</scope> -->
		</dependency>
	</dependencies>
	<build>
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>create-executable-jar</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
	    <tasks>
                  <property name="compile_classpath" refid="maven.compile.classpath"/>
                  <property name="runtime_classpath" refid="maven.runtime.classpath"/>
                  <property name="test_classpath" refid="maven.test.classpath"/>
                  <property name="plugin_classpath" refid="maven.plugin.classpath"/>
                  <echo message="compile classpath: ${compile_classpath}"/>
                  <echo message="runtime classpath: ${runtime_classpath}"/>
                  <echo message="test classpath:    ${test_classpath}"/>
                  <echo message="plugin classpath:  ${plugin_classpath}"/>
             </tasks>
              <descriptorRefs>
                <descriptorRef>
                  jar-with-dependencies
                </descriptorRef>
              </descriptorRefs>
              <archive>
                <manifest>
                  <mainClass>com.scheidecker.itests.ad.MainTests</mainClass>
                </manifest>
              </archive>
           </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
	<!-- Project Information -->
	<!--
		name, description, url, inceptionYear, licenses, organization,
		developers, contributors
	-->
	<name>NANDO :: Authentication :: AUTH1 :: Integration Tests</name>
	<description>TODO: description: AUTH1 :: Authentication :: NANDO ::
		Integration Tests</description>
	<!-- Environment Settings -->
	<!--
		issueManagement, ciManagement, mailingLists, scm, prerequisites,
		repositories, pluginRepositories, distributionManagement, profiles
	-->
</project>
[+][-]03/30/09 06:28 PM, ID: 24025053

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Java Programming Language
Tags: mvn maven jar junit executable jar-with-dependencies
Sign Up Now!
Solution Provided By: CarlosScheidecker
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625