java.lang.TypeNotPresentException from common library

We’re working on building a module that will expose some web services to allow some external control over Ignition. When the Endpoint gets published, it’s throwing a TypeNotPresentException on the interface defined in the Common project. If I add the code to publish the same endpoint to a regular main() method and fire it up locally, it works just fine, so I’m thinking it has to do with the way we’ve built the module. Below is the module definition and the stack trace for the exception. The hook is in the Cell jar, the IProductionOrder is in the Common jar.

Note: For the sake of simplicity, I’ve reduced all the web service hosting down to just Endpoint.publish(“http://localhost:8080/wsServerExample”, new IgnitionCellTierInterface()); It does work in a static void main() method, but does not within AbstractGatewayModuleHook.startup();

[code]<?xml version="1.0" encoding="UTF-8"?>

Project Cell Module

	<jar scope="G">company-project-common.jar</jar>
	<jar scope="G">company-project-cell.jar</jar>

	<!-- Tell the Gateway and/or Designer where to find the hooks -->
	<hook scope="G"></hook>


java.lang.TypeNotPresentException: Type not present at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType( at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature( at sun.reflect.generics.tree.ClassTypeSignature.accept( at sun.reflect.generics.visitor.Reifier.reifyTypeArguments( at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature( at sun.reflect.generics.tree.ClassTypeSignature.accept( at sun.reflect.generics.repository.FieldRepository.getGenericType( at java.lang.reflect.Field.getGenericType( at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getFieldType( at com.sun.xml.internal.bind.v2.model.nav.ReflectionNavigator.getFieldType( at com.sun.xml.internal.bind.v2.model.impl.FieldPropertySeed.getRawType( at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl$RuntimePropertySeed.getRawType( at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl$RuntimePropertySeed.getRawType( at com.sun.xml.internal.bind.v2.model.impl.PropertyInfoImpl.<init>( at com.sun.xml.internal.bind.v2.model.impl.ERPropertyInfoImpl.<init>( at com.sun.xml.internal.bind.v2.model.impl.ElementPropertyInfoImpl.<init>( at com.sun.xml.internal.bind.v2.model.impl.RuntimeElementPropertyInfoImpl.<init>( at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.createElementProperty( at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.addProperty( at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.findFieldProperties( at com.sun.xml.internal.bind.v2.model.impl.ClassInfoImpl.getProperties( at com.sun.xml.internal.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties( at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo( at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo( at com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo( at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet( at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>( at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$ at com.sun.xml.internal.bind.v2.ContextFactory.createContext( at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance( at$1.createJAXBContext( at$ at$ at Method) at at at at at at at at at at at at at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$LoadedModule.startup( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.startupModule( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$ at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.executeModuleOperation( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.installModuleInternal( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl.access$1400( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$InstallCommand.execute( at com.inductiveautomation.ignition.gateway.modules.ModuleManagerImpl$Receiver.receiveCall( at com.inductiveautomation.ignition.gateway.cluster.QueueableMessageReceiver.receiveCall( at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl.dispatchMessage( at com.inductiveautomation.ignition.gateway.redundancy.RedundancyManagerImpl$ at com.inductiveautomation.ignition.common.execution.impl.BasicExecutionEngine$ at java.util.concurrent.Executors$ at java.util.concurrent.FutureTask$Sync.innerRun( at at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301( at java.util.concurrent.ScheduledThreadPoolExecutor$ at java.util.concurrent.ThreadPoolExecutor$Worker.runTask( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: java.lang.ClassNotFoundException: at$ at Method) at at java.lang.ClassLoader.loadClass( at java.lang.ClassLoader.loadClass( at java.lang.ClassLoader.loadClassInternal( at java.lang.Class.forName0(Native Method) at java.lang.Class.forName( at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType( ... 70 more

E: Edited to put in correct stack trace, other one was from a previous test and not the latest.

We’ve tried a variety of different scenarios, including rolling the .class files into the same jar, trying to put additional jars like jaxb dependencies in the module (just in case it was crashing on generating the web service), etc. We did try just using the classes as regular objects within the startup and are able to instantiate and get a value from them, so the objects are available, just not to the Endpoint publishing. The only thing that’s worked for that piece is putting the common library on the class path using ignition.conf. At this point I really have no idea why it worked, just that it did. So, with that I’ve got some questions about this solution:

  1. If we’re adding libraries there, will they be usable by clients?
  2. Since this fix is only intended to address the gateway hosting a web service - are there any foreseeable issues with using this on the gateway?
  3. Does this shed any light on why it doesn’t work from within the module? All we did was copy the common.jar to the /lib folder and add a line to Ignition.conf for the # Java Classpath section.


I don’t really see anything wrong with it, other than its hacky-ness. More overhead to remember and the like.

We don’t use any of the Endpoint / web service stuff, so I don’t really know why it doesn’t work. My guess it that its trying to load the classes from a ClassLoader above the one that jar files provided by modules are loaded and available in.

Ok, I think we found a way to hack around the class loader issue based on this blog post. Here’s what we ended up with inside of a web service manager to control starting and stopping the web service. We pass in the web service class to be hosted as part of the constructor and that’s where clazz comes from.

ClassLoader oldTCCL = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(clazz.getClassLoader()); endpoint.publish(context); } catch (Exception e) { logger.error("Unable to start web service.", e); } finally { Thread.currentThread().setContextClassLoader(oldTCCL); }

Cool, glad you got it fixed.

As for making JAR files provided by a module available to clients - the scope in the module.xml influences that. Something scoped “dcg” as opposed to “g” should get sent to the clients.

Another question on this topic - it looks like we’ll be using Ignition as the platform for at least two of the tiers in this architecture, possibly a third. All will need common functionality like this web service, so I tried to make an Ignition-specific common library to create my own AbstractIgnitionTier class (extending AbstractGatewayModuleHook) that all three tiers will extend, but with my first pass at this I’m getting ClassNotFoundException for the AbstractIgnitionTier class. Before I dig into how I’ve set up the module - is it likely facing the same ClassLoader issues?

Is each of the “tiers” its own module? Explain your project/lib setup a little bit more if you can.

Whoops…turns out when I copied the Ant build files, I forgot to give the new project a new jar name, so it was being overwritten by the original common.jar during the module bundling process. It’s working great now!