Btw:
@Resource(lookup = "java:app/osgi/Bundle")
Bundle activatorBundle;
public <T> T getService(Class<T> serviceInterface) {
return activatorBundle.getBundleContext()
.getService(activatorBundle.getBundleContext().getServiceReference(serviceInterface));
}
-----Original Message-----
From: Remo Liechti [mailto:[email protected]]
Sent: Mittwoch, 24. August 2016 09:36
To: [email protected]
Subject: LinkageError, but why?
Hi Guys
As you know by now, I wrap an osgi application into a j2ee web app on Weblogic.
Weblogic uses felix.
I can successfully deploy the app and communicate on sockets with it, all fine.
But when it comes to accessing the app using the OSGI Services, I can call a
few methods. However, as soon as I call a method on a service that has non
Java-Datatypes, I get LinkageErrors, like this one:
java.lang.LinkageError: loader constraint violation: loader (instance of
org/apache/felix/framework/BundleWiringImpl$BundleClassLoaderJava5) previously
initiated loading for a different type with name
"com/kuka/nav/robot/MobileRobotType"
at
com.kuka.nav.fleet.simulation.internal.FleetSimulationImpl.addRobot(FleetSimulationImpl.java:137)
at
com.kuka.nav.fleet.simulation.internal.FleetSimulationImpl.addRobot(FleetSimulationImpl.java:177)
at com.swisslog.wm6.test.MoveServlet.processRequest(MoveServlet.java:71)
at com.swisslog.wm6.test.MoveServlet.doGet(MoveServlet.java:95)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
What I try to achieve is:
69: IResourceManager resMan = getService(IResourceManager.class);
70: FleetSimulation simulation = (FleetSimulation)
resMan.getResource("FleetSimulation").getCapability(FleetSimulation.class);
71: simulation.addRobot(new BasicRobotType(7), "Robotinator");
72: simulation.startAllRobots();
As you can see, the type to pass to addRobot is of BasicRobotType.
We tried with a different method, that instead of a BasicRobotType takes a
regular integer instead:
69: IResourceManager resMan = getService(IResourceManager.class);
70: FleetSimulation simulation = (FleetSimulation)
resMan.getResource("FleetSimulation").getCapability(FleetSimulation.class);
71: simulation.addRobot(7, "Robotinator");
72: simulation.startAllRobots();
Information about the classes:
public interface MobileRobotType
public final class BasicRobotType implements MobileRobotType The java classes
are in a single jar file and are not duplicated on the classpath.
This works fine then. But this also means we would have to change the API
significantly and to a low level API who nobody likes.
Any idea what can be done to solve the linkage error? Maybe any Devs out there
of felix itself?
Thanks
This message may contain legally privileged or confidential information and is
therefore addressed to the named persons only. The recipient should inform the
sender and delete this message, if he/she is not named as addressee. The sender
disclaims any and all liability for the integrity and punctuality of this
message. The sender has activated an automatic virus scanning, but does not
guarantee the virus free transmission of this message.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
This message may contain legally privileged or confidential information and is
therefore addressed to the named persons only. The recipient should inform the
sender and delete this message, if he/she is not named as addressee. The sender
disclaims any and all liability for the integrity and punctuality of this
message. The sender has activated an automatic virus scanning, but does not
guarantee the virus free transmission of this message.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]