Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

JLink App Causing ProE To Crash

fiebigc

New member
I thought I had declared victory over JLink but it's not going down without a fight.

I have a JLink Asynchronous app that is causing
ProE to crash. This app will work perfectly many times for about an
hour and the all of a sudden when I run this program ProE will crash.





Java throws this error: com.ptc.pfc.Implementation.pfcExceptions$XToolkitCommError




If I restart ProE and run the jlink app ProE will keep crashing
with the same error. The only way to make the jlink app work again is
to restart my computer and the cycle continues. Does anyone have any
suggestions? Thanks.


Code:
//This is a JLink Asynchronos Program that will print the components of an assembly that is set to assemblyName String


//Status: Working.


//


//System Variables To Make Program Work (restart windows if necessary)


//-------------------------------------


//CLASSPATH =  .;C:\Program
Files\Java\jre1.6.0\lib\ext\QTJava.zip;D:\My_P rogramming\Netbeans\proeAsyncApp\build\classes\proeasyncapp; C:\Program
Files\proeWildfire  3.0\text\java\pfcasync.jar;%CLASSPATH%


//PATH = C:\Program Files\proeWildfire 3.0\i486_nt\lib;%PATH%


//PRO_COMM_MSG_EXE = C:\Program Files\proeWildfire 3.0\i486_nt\obj\pro_comm_msg.exe


//PRO_DIRECTORY = C:\Program Files\proeWildfire 3.0





package proeasyncapp;





import com.ptc.cipjava.*;


import com.ptc.pfc.pfcSession.*;


import com.ptc.pfc.pfcModel.*;


import com.ptc.pfc.pfcFeature.*;


import com.ptc.pfc.pfcAssembly.*;


import com.ptc.pfc.pfcComponentFeat.*;


import com.ptc.pfc.pfcAsyncConnection.*;





public class proeAsyncApp


{


  public static void main(String[] args)


  { 


 System.loadLibrary("pfcasyncmt");


  


 String assemblyName = "Enter Your Assembly Here";


 String fileType;


 


 Assembly assembly = null;


 Features components = null;


 String[] listOfParts;


 ModelDescriptor desc;


 ModelType modelType;


 ComponentFeat component;


 


 try {


    


   AsyncConnection connection =  pfcAsyncConnection.AsyncConnection_Connect(null,null,null,nu ll);


 


   Session curSession = connection.GetSession();


   


   assembly = (Assembly)curSession.GetModel(assemblyName, ModelType.MDL_ASSEMBLY );


    


   components = assembly.ListFeaturesByType(Boolean.FALSE, FeatureType.FEATTYPE_COMPONENT);


  


   listOfParts = new String[components.getarraysize()];


   


   for(int i=0; i<components.getarraysize(); i++)


   {


  component = (ComponentFeat)components.get(i);


  desc = component.GetModelDescr();


  modelType = desc.GetType();


  


  if(modelType.equals (ModelType.MDL_PART))


    fileType = "prt";


  else if(modelType.equals (ModelType.MDL_ASSEMBLY ))


    fileType = "asm";


  else if(modelType.equals (ModelType.MDL_DRAWING ))


    fileType = "drw";


  else


    fileType = "Unknown"; 


 


  listOfParts[i] = desc.GetFileName(); 


   }


   


   System.out.println();


   System.out.println("The Components In " + assemblyName);


   System.out.println("-----------------------------------");


   


   for(int i=0; i<listOfParts.length; i++)


  System.out.println(listOfParts[i]);


   


   System.out.println();


   


   connection.Disconnect(null);


   


 }catch(jxthrowable e){


      


   System.out.println();


   System.out.println(e);


   System.out.println();


 


 } 


  }


}

[/i][/i]XP Pro


Wildfire 3.0


NetBeans6.0


Java 1.6.0_06


Edited by: fiebigc
 
You're disconnecting, which is a very good thing, but you're using null? I'd try
putting a non-zero integer value here. The VB API gets a little upset when the
disconnect timeout is too low.



Just noticed this from the J-Link documentation on the Disconnect() method:
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


For J-Link only: In order to clear allocated Pro/ENGINEER memory owned by
the application, PTC recommends forcing garbage collection (using Java's
System.gc()) before disconnecting from Pro/ENGINEER.
</BLOCKQUOTE>





Marc
 
Thank you for the help. This JLink stuff is so esoteric it's hard to find answers. I will add the code and do some testing. I'll give an update in a couple of days to say if it's working or not.

You said the VB API does not like null or zero values for timeouts. I'll try and a timeout time to the connection method as well to see if this helps.

Where does Visual Basic fit into all of this? (if VB means something else let me know)


Edited by: fiebigc
 
To my great disappointment after adding System.gc() and a timeout time to the pfcAsyncConnection.AsyncConnection_Connect(null,null,null,3) ; and connection.Disconnet(3); I've had no improvement to stability.


I still can't understand why after a crash even if I restart ProE my JLink app will always cause ProE to crash until I restart Windows. After the restart the JLink will work well unitl ProE crashes again.


Knowing the general instability of ProE I can't be confident I'll ever get this to work.

Edited by: fiebigc
 
Hey fiebigc,

I tried to establish a connection to ProE with the function AsyncConnection_Connect() too (ProE is started manually).
But it doesn
 
Hi,

May I suggest to used Java JDK 1.5.0.10 instead of 1.6... ProeWildfire 3.0 is shipped with JRE 1.5.0.10

Also, when I was using NetBeans to do my own JLinf app, I was compiling with the javac (in the JDK \bin directory) command instead of using the NetBeans compiler to be able to run my application woth ProE.

(I didn't test what I just wrote, but this is what I would try)

Olivier
 
Try to debug the line where its failing .. so that U can replicate the behavior in better way .
U can log after each line of execution of code and it will give U a clear idea .. why its failing ..


To my GUESS .. It might be giving problem on


AsyncConnection connection = pfcAsyncConnection.AsyncConnection_Connect(null,null,null,nu ll);


when U try to connect for several times, Some problem is happening in Pro/E and either nmsd or communication is getting effected ...

Let Us know in details
 

Sponsor

Back
Top