Menu

"Cannot find factory"

oxramone
2012-11-21
2014-11-11
  • oxramone

    oxramone - 2012-11-21

    Hello,

    I'm trying to realize a simple example in HLA EVOLVED, using ieee1516e.jar and a Pitch RTI.
    I get this runtime exception:

    Exception in thread "main" hla.rti1516e.exceptions.RTIinternalError: Cannot find factory
    at hla.rti1516e.RtiFactoryFactory.getRtiFactory(RtiFactoryFactory.java:48)

    This is the line that generates the exception:

    private RTIambassador rtiamb = RtiFactoryFactory.getRtiFactory().getRtiAmbassador(); 

    What mistake have I done?

    Thank you in advance.
    Ox.

     
  • Senfkoenig

    Senfkoenig - 2014-11-11

    The ServiceLoader needs a file specifing which class implements the interface RTIFactory.

    To do this you have to do the following:
    1. Locate where your .class files are. This is your main classpath
    2. Create subfolders: META-INF/services
    3. in this directory create a file with the name hla.rti1516e.RtiFactory
    4. write the full qualified name (including package names) of a class that implements the interface RtiFactory in that file. (e.g. net.sf.ohla.rti.hla.rti1516e.IEEE1516eRtiFactory )

     
  • Michael Newcomb

    Michael Newcomb - 2014-11-11

    You said 'Pitch' RTI, but did you mean 'OHLA' RTI?

    If so, you need to include the ohla-rti.jar file on your classpath. The ohla-rti.jar file includes the file mentioned above (by Senfkoenig) and the ServiceLoader can then locate the proper class.

     

Log in to post a comment.