We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Words Java - Test Example

Hi,

I am new to Aspose.

I downloaded Aspose.Words for Java 11.1.0 for evaluation.

I am trying to run a basic example in java 1.6 using Spring framework on eclipse IDE. Following is the code for my words test;

package org.primefaces.examples.moviecollector.view;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;

@Component(“test123”)
@Scope(“session”)

public class Test
{
public static void main123()
{
try
{
// Document doc = new Document(“Test.doc”);
// doc.save(“TestOut.doc”);

Document doc1 = new Document();
DocumentBuilder builder = new DocumentBuilder(doc1);

builder.writeln(“Hello World!”);

doc1.save(“DocumentBuilderAndSave Out.doc”);}
catch (Exception e)
{
e.printStackTrace();
}

}

}

In My Application i have the following button to call the main123() method;

<h:commandButton id=“generate” action="#{test123.main123}" value=“Generate” />

When this method is called; i get the following error;

SEVERE: java.lang.NoClassDefFoundError: com/aspose/words/Document
javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: com/aspose/words/Document

WARNING: #{test123.main123}: java.lang.NoClassDefFoundError: com/aspose/words/Document
javax.faces.FacesException: #{test123.main123}: java.lang.NoClassDefFoundError: com/aspose/words/Document

I want to highlight that when i change the following method, main123() to main(String args[]) and run it from command line; it works; but when i change the method from main(String args[]) to main123() and run it from web application it gives me above error.

As i am new to Aspose; can anyone help me on this issue please; i am not sure if it is an issue with licence or i need to do something different to run this basic example as jsf?

Many Thanks

Sheraz

Can anyone tell me why i get the following error.

java.lang.NoClassDefFoundError: com/aspose/words/Document

Hi Sheraz,


Thanks for your inquiry. Could you please attach the input document which causes the exception? We will test on our side and provide you with some further feedback.

Hi Imran Rafique,

Thanks for reply, i have attached the code files and the exception file. I am running this app as JSF web app on tomcat.

Many Thanks

Sheraz

Hi Sheraz,


Thank you for additional information. Actually this problem is not related to Aspose.Words. I suppose this problem is related to Java on your platform. I think the following article will be useful for you:

http://javarevisited.blogspot.com/2011/06/noclassdeffounderror-exception-in.html


Thank you,

It’s working fine now.

It was a problem with the classpath. I had the Aspose.Words.jar file in Aspose/Words/*.jar folder. After i moved the jar file to WEB-INF/lib classpath, it works absolutely fine.

Thanks for your assistance.

Regards

Sheraz

Hi Sheraz,


It is great to hear that your issue has been resolved. You are always welcome and please feel free to ask if you have any query in future.

We always welcome constructive response from our customers.