On 07/23/2013 07:00 AM, Michael Born wrote:
  Hello,
 I currently developing an additional component, this component need 3rd
 party jars to run.
 I have included my project in Eclipse, where I stored the jars in the
 build path.
 To create the jar with Maven works without error.
 Whenever I install my component in xwiki.basedir {} / WEB-INF/lib, and
 then try to execute this in Velocity in a page I get the following error
 displayed:
 Caused by: org.apache.velocity.exception.MethodInvocationException:
 Invocation of method 'createProjectPages' in  class
 com.acme.internal.BlueAntComponentScriptService threw exception
 java.lang.NoClassDefFoundError:
 org/apache/commons/discovery/tools/DiscoverSingleton at xwiki:BlueAnt
 Space.WebHome[line 2, column 19]
      at
org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:261)
      at
 org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:187)
      at
 org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
      at
 org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
      at
 org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
      at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:228)
      ... 106 more
 Caused by: java.lang.NoClassDefFoundError:
 org/apache/commons/discovery/tools/DiscoverSingleton
      at
 org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
      at java.security.AccessController.doPrivileged(Native Method)
      at
 org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
      at
 org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33)
      at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
      at org.apache.axis.client.Service.getAxisClient(Service.java:104)
      at org.apache.axis.client.Service.<init>(Service.java:113)
      at
 net.proventis.axis.blueant.BaseServiceLocator.<init>(BaseServiceLocator.java:12)
      at com.acme.internal.ClientTest.<init>(ClientTest.java:41)
      at
com.acme.internal.BlueAntDefaultComponent.createProjectPages(BlueAntDefaultComponent.java:73)
      at
com.acme.internal.BlueAntComponentScriptService.createProjectPages(BlueAntComponentScriptService.java:50)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
      at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
      at
 org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
      ... 110 more
 Caused by: java.lang.ClassNotFoundException:
 org.apache.commons.discovery.tools.DiscoverSingleton
      at
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
      at
 org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
      ... 128 more
 I've tried to make the jars available via the command:
 mvn install:install-file -Dfile=src\main\resources\axis.jar
 -DgroupId=axis -DartifactId=axis -Dversion=1 -Dpackaging=jar
 ...
 ...
 ...
 But this has not helped.
 My pom file looks like:
 <?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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.xwiki.commons</groupId>
 <artifactId>xwiki-commons-component-archetype</artifactId>
    <version>3.3-milestone-2</version>
    <name>XWiki BlueAnt Component</name>
    <description>XWiki BlueAnt Component</description>
    <properties>
 <platform.core.version>3.3-milestone-2</platform.core.version>
    </properties>
    <build>
      <plugins>
        <!-- plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
          <configuration>
            <source>1.6</source>
            <target>1.6</target>
          </configuration>
        </plugin -->
        <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
 <compilerVersion>1.5</compilerVersion>
              <source>1.5</source>
              <target>1.5</target>
            </configuration>
          </plugin>
      </plugins>
    </build>
    <dependencies>
      <dependency>
        <groupId>org.xwiki.commons</groupId>
 <artifactId>xwiki-commons-component-default</artifactId>
 <version>${platform.core.version}</version>
      </dependency>
      <!-- Only needed if some of the component's APIs must be made
 visible to scripting in wiki pages -->
      <dependency>
        <groupId>org.xwiki.commons</groupId>
 <artifactId>xwiki-commons-script</artifactId>
 <version>${platform.core.version}</version>
      </dependency>
      <!-- Testing dependencies -->
      <dependency>
          <groupId>org.xwiki.commons</groupId>
 <artifactId>xwiki-commons-test</artifactId>
 <version>${platform.core.version}</version>
          <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.0</version>
        <type>jar</type>
        <scope>system</scope>
<systemPath>D:\Entwicklung\JAVA\Maven\TestProject\example\src\main\resources\axis.jar</systemPath>
      </dependency>
      ... and for all other third party jars
    </dependencies>
 </project>
 Can anyone help a desperate trainee? :)
 
 Hi Michael,
 First of all, the error doesn't show up because of how the build is set
 up, but because by default dependencies aren't included in the generated
 jar.
 So, it is not enough to just copy your project's jar to WEB-INF/lib, you
 need to copy it along with all its dependencies. To check what
 dependencies are needed by a project, just execute:
 mvn dependency:tree
 If a dependency already exists in WEB-INF/lib, you don't have to copy
 it, even if it has a different version. You can't use two different
 versions of the same class anyway, so you'll cause more problems if you do.
 Second, you should not use system dependencies. Unless you're using a
 very unpopular library, most of the open source projects are available
 on the central maven repository. Use 
http://search.maven.org/ to look
 for their exact coordinates. Searching for "axis" shows a bunch of
 results, including axis:axis (1.4 being the latest version) and
 axis2:axis2, in case you want to upgrade.
 
http://search.maven.org/#artifactdetails|axis|axis|1.4|jar
 Thanks for the quick help!
--
MPDigital GmbH
Michael Born
Auszubildender Fachinformatiker Anwendungsentwicklung
Kantstraße 5-13
44867 Bochum
Tel.: (0 23 27) 307-323
E-Mail: born(a)mpdigital.de
Geschaeftsführer: Hans-Joachim Janke
Sitz und Registergericht:
Amtsgericht Bochum - HRB 6454