Pleaase help me!!
Hello,
firstly, please excuse my english because i'm French and my english is not very fluent...
I'm working on a electronic signature software developped with java and i need do convert document into PDF.
My IDE is Netbeans 7.1.2 with JDK6.
Here is my problem, when i run the code I get this error :
run:
log4j:WARN No appenders could be found for logger (com.*.*.gui.MainForm).
log4j:WARN Please initialize the log4j system properly.
License about to read: ...
License is available: C:\\...\\*....key
Exception in thread "Thread-8" java.lang.NoClassDefFoundError: Could not initialize class com.jacob.com.ComThread
at idainfront.pdfcreator4j.PdfCreatorApi.(PdfCreatorApi.java:50)
at com.*.*.converter.plugins.PdfCreatorConverter.isReady(PdfCreatorConverter.java:103)
at com.*.*.converter.plugins.PdfCreatorIsAvalaible.command(PdfCreatorIsAvalaible.java:25)
at com.*.*.util.Timeout$TimeoutThread.run(Timeout.java:15)
at java.lang.Thread.run(Thread.java:662)
The moment where I use PDF Creator API 's function:
public PdfCreatorApi() { ComThread.InitMTA(true); mPdfCreator = new ActiveXComponent("PDFCreator.clsPDFCreator"); mEventHandler = new EventHandler(this); mDispatcher = new DispatchEvents(mPdfCreator, mEventHandler); } ```
I Think there is a problem with initMTA() function from the ComThread class because the error says : "Could not initialize...."
the comThread class look like this...
package com.jacob.com;/**
* Represents a COM level thread This is an abstract class because all the
* methods are static and no instances are ever created.
*/
public abstract class ComThread {
private static final int MTA = 0x0;<span class="kd" style="color: rgb(0, 128, 0); font-weight: bold; ">private</span> <span class="kd" style="color: rgb(0, 128, 0); font-weight: bold; ">static</span> <span class="kd" style="color: rgb(0, 128, 0); font-weight: bold; ">final</span> <span class="kt" style="color: rgb(176, 0, 64); ">int</span> <span class="n">STA</span> <span class="o" style="color: rgb(102, 102, 102); ">=</span> <span class="mh" style="color: rgb(102, 102, 102); ">0x2</span><span class="o" style="color: rgb(102, 102, 102); ">;</span> <span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Comment for
haveSTA
*/
public static boolean haveSTA = false;<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Comment for
mainSTA
*/
public static MainSTA mainSTA = null;<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Initialize the current java thread to be part of the Multi-threaded COM
* Apartment
*/
public static synchronized void InitMTA() {
InitMTA(false);
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Initialize the current java thread to be an STA
*/
public static synchronized void InitSTA() {
InitSTA(false);
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Initialize the current java thread to be part of the Multi-threaded COM
* Apartment, if createMainSTA is true, create a separate MainSTA thread
* that will house all Apartment Threaded components
*
* @param createMainSTA
*/
public static synchronized void InitMTA(boolean createMainSTA) {
Init(createMainSTA, MTA);
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Initialize the current java thread to be an STA COM Apartment, if
* createMainSTA is true, create a separate MainSTA thread that will house
* all Apartment Threaded components
*
* @param createMainSTA
*/
public static synchronized void InitSTA(boolean createMainSTA) {
Init(createMainSTA, STA);
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
*
*/
public static synchronized void startMainSTA() {
mainSTA = new MainSTA();
haveSTA = true;
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
*
*/
public static synchronized void quitMainSTA() {
if (mainSTA != null)
mainSTA.quit();
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Initialize the current java thread to be part of the MTA/STA COM
* Apartment
*
* @param createMainSTA
* @param mode
*/
public static synchronized void Init(boolean createMainSTA, int mode) {
if (createMainSTA && !haveSTA) {
// if the current thread is going to be in the MTA and there
// is no STA thread yet, then create a main STA thread
// to avoid COM creating its own
startMainSTA();
}
if (JacobObject.isDebugEnabled()) {
JacobObject.debug("ComThread: before Init: " + mode);
}
doCoInitialize(mode);
if (JacobObject.isDebugEnabled()) {
JacobObject.debug("ComThread: after Init: " + mode);
}
ROT.addThread();
if (JacobObject.isDebugEnabled()) {
JacobObject.debug("ComThread: after ROT.addThread: " + mode);
}
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* Call CoUninitialize to release this java thread from COM
*/
public static synchronized void Release() {
if (JacobObject.isDebugEnabled()) {
JacobObject.debug(“ComThread: before clearObjects”);
}
ROT.clearObjects();
if (JacobObject.isDebugEnabled()) {
JacobObject.debug(“ComThread: before UnInit”);
}
doCoUninitialize();
if (JacobObject.isDebugEnabled()) {
JacobObject.debug(“ComThread: after UnInit”);
}
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* @deprecated the java model leave the responsibility of clearing up
* objects to the Garbage Collector. Our programming model
* should not require that the user specifically remove object
* from the thread.
*
* This will remove an object from the ROT
* @param o
*/
@Deprecated
public static synchronized void RemoveObject(JacobObject o) {
ROT.removeObject(o);
}<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* @param threadModel
*/
public static native void doCoInitialize(int threadModel);<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
*
*/
public static native void doCoUninitialize();<span class="cm" style="color: rgb(64, 128, 128); font-style: italic; ">/**</span>
* load the Jacob DLL. We do this in case COMThread is called before any
* other reference to one of the JacboObject subclasses is made.
*/
static {
LibraryLoader.loadJacobLibrary();
}
}<p> </p><p>thank all of you in advance!</p><p> </p>