0

I have developed an Application in Java using

    <dependency>
        <groupId>commons-chain</groupId>
        <artifactId>commons-chain</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
    </dependency>
    <dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>2.1</version>
    </dependency>

The deployed jar produces:

    Sep 09, 2015 4:26:17 PM org.apache.commons.digester.Digester startElement
SEVERE: Begin event threw exception
java.lang.ClassNotFoundException: lib.cF.gF.CE
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:210)
        at org.apache.commons.digester.Rule.begin(Rule.java:177)
        at org.apache.commons.digester.Digester.startElement(Digester.java:1583)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
        at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
        at org.apache.commons.digester.Digester.parse(Digester.java:1990)
        at org.apache.commons.chain.config.ConfigParser.parse(ConfigParser.java:190)
        at lib.Utilities.CatalogLoader.getCatalog(CatalogLoader.java:25)
        at main.PFChain.executePFChain(PFChain.java:27)
        at main.Main.main(Main.java:30)

I allready read in WebSphere ClassNotFoundException with deployed dynamic web project that i might have to copy the *digister.jar to my unix system as well.

But i dont know Where, since this is not a web application.

EDIT: as suggested by @Amila i ran

user@system:/folder$ java -cp "*.jar" main.Main        Error: Could not find or load main class main.Main

How do i get my jar to run on the server as well?

Community
  • 1
  • 1
Xlaech
  • 456
  • 3
  • 19

2 Answers2

1

You need to include the library jars you've used in classpath.

Something like:

java -cp 'program.jar:library1.jar:library2.jar' yourpackage.YourClass

Since you're using maven, you can copy all dependencies using maven dependency plugin, and store all of them in a lib directory.

Then you can do (Java 6+):

java -cp 'program.jar:lib/*' yourpackage.YourClass
Amila
  • 5,195
  • 1
  • 27
  • 46
  • Ok thank you. And can i use this together with a jar? – Xlaech Sep 09 '15 at 12:02
  • yes, program.jar is your jar. other jars (like commons) are in lib directory – Amila Sep 09 '15 at 12:04
  • Ok. tried the first one, with all the dependencies in the same folder as the main jar. Just java -cp "program.jar" main.Main works, but with the dependecies it doesn't: java -cp "program.jar:dep1.jar:dep2.jar" main:main – Xlaech Sep 09 '15 at 12:11
  • Is the Main class/package correct? Also, you have to either include all dependency jars by name or use wildcard ./* (I'm assuming you're using linux) – Amila Sep 09 '15 at 12:15
  • since java -cp "program.jar" main.Main seems to work, i am pretty sure. Ah and i use Windows :) (is there a difference? because i can run it on the server as well) – Xlaech Sep 09 '15 at 12:17
  • Maybe you're missing a dependency, can you edit the question with full stacktrace? – Amila Sep 09 '15 at 12:21
  • Done. I also tried main.Main.main, since this appeares in the log i posted – Xlaech Sep 09 '15 at 12:31
0

I found the sad solution to my problem. I refactored files a few Days ago, an maven did not get the refactoring a maven:clean solved the Problem

Thanks to @Amila for the help.

Xlaech
  • 456
  • 3
  • 19