hltfbk / Excitement-Transduction-Layer

1 stars 1 forks source link

InstantiationException for EntailmentRelation #321

Closed mmatthias closed 9 years ago

mmatthias commented 9 years ago

I got the following exception when running the graph optimizer.

14/11/06 15:55:20 WARN edgelearners.EfficientlyCorrectHtlLearner: OBJECTIVE-FUNCTION-VALUE: 69996.99132921502 14/11/06 15:55:20 INFO api.UntypedPredicateGraphLearner: Number of edges: 8 14/11/06 15:55:20 INFO api.UntypedPredicateGraphLearner: Objective value: 0.0 14/11/06 15:55:20 INFO graphoptimizer.SimpleGraphOptimizer: Removed 0 low-confidence edges. [error] play - Cannot invoke the action, eventually got an error: java.lang.RuntimeException: Edge factory failed [error] application -

! @6k5bpod3j - Internal server error, for (GET) [/api/excitement/build] ->

play.api.Application$$anon$1: Execution exception[[RuntimeException: Edge factory failed]] at play.api.Application$class.handleError(Application.scala:293) ~[play_2.10-2.2.3.jar:2.2.3] at play.api.DefaultApplication.handleError(Application.scala:399) [play_2.10-2.2.3.jar:2.2.3] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3$$anonfun$applyOrElse$3.apply(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3] at scala.Option.map(Option.scala:145) [scala-library.jar:na] at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$3.applyOrElse(PlayDefaultUpstreamHandler.scala:264) [play_2.10-2.2.3.jar:2.2.3] Caused by: java.lang.RuntimeException: Edge factory failed at org.jgrapht.graph.ClassBasedEdgeFactory.createEdge(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.graph.AbstractBaseGraph.addEdge(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.Graphs.addGraphReversed(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.alg.StrongConnectivityInspector.stronglyConnectedSets(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.alg.CycleDetector.findCycles(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at eu.excitementproject.tl.composition.graphoptimizer.SimpleGraphOptimizer.findEquivalenceClassesAsCycles(SimpleGraphOptimizer.java:150) ~[tl-1.0.10.jar:na] Caused by: java.lang.InstantiationException: eu.excitementproject.tl.structures.rawgraph.EntailmentRelation at java.lang.Class.newInstance0(Class.java:357) ~[na:1.7.0_10] at java.lang.Class.newInstance(Class.java:325) ~[na:1.7.0_10] at org.jgrapht.graph.ClassBasedEdgeFactory.createEdge(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.graph.AbstractBaseGraph.addEdge(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.Graphs.addGraphReversed(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5] at org.jgrapht.alg.StrongConnectivityInspector.stronglyConnectedSets(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5]

The line which produces the error is the following: graph = graphOptimizer.optimizeGraph(egr, graphConfidenceScore);

Did anyone else had this error?

mmatthias commented 9 years ago

The problem is that a default constructor for the eu.excitementproject.tl.structures.rawgraph.EntailmentRelation class is missing. Maybe you added specific constructor so the default constructor is not there anymore.

mmatthias commented 9 years ago

mmh think that the constructor have to have 2 arguments, as I saw in decompiled code. Something is not ok with the constructor I think. The jgraph framework tries to create an instance but is not able to.

KathrinEichler commented 9 years ago

Hi Matthias, could you please send us the piece of code in which the error occurs (including the data we need to run it), so we can try to reproduce the error. Thanks.

gilnoh commented 9 years ago

Hello, Matthias, we had talked about this issue in WP6 Telco today --- for now, we suspect that this is caused by "jar hell" situation. There is more than one version of "jgrapht" library in the dependency list. TL needs to use "later" version of library; but it seems that somehow on your system, the older version is first visible and being used.

Managing Dependency order (or, rather visibility)

Would you please try the following? It would be best if I can actually follow the error and handle why it fails --- but since we (WP6) can't reproduce the error on our side, let's try to resolve it a little bit by the following...

TL layer uses jgrapht 0.8.3 --- however, it seems that the above code shows that actual running of the above code used jgrapht 0.7.3. Some part of code in EOP open platform uses jgrapht 0.7.3 (let's call it "old"), but TL only uses jgrapht 0.8.3 (let's say, "new").

To resolve this within TL; we have expliticely declared the following dependency in the TL Maven POM file: note that, in Maven, dependencies are satisfied in the order of "dependency" appearance. Within TL, this guarantees that in all of TL, only jgrapht 0.8.3 is first visible in classpath, ( and older version (regardless of its existance) is not used).

<dependency>
   <groupId>net.sf.jgrapht</groupId>
   <artifactId>jgrapht</artifactId>
   <version>0.8.3</version>
</dependency>

<dependency>
   <groupId>jgraph</groupId>
   <artifactId>jgraph</artifactId>
   <version>5.13.0.0</version>
</dependency>

[The above two dependencies are the first dependencies. 
All other dependencies including EOP dependency, etc ... goes on...] 

But somehow, in your system, it seems that old version first appears in the classpath. Some constructors of seems to have been changed from jgrapht "old" version to "new" version, and code that designed with "new version" would fail on old version (different constructor signature). We suspect that this is the cause: and also, your trace output shows old version.

[From your posting of issue] 
 Caused by: java.lang.RuntimeException: Edge factory failed
at org.jgrapht.graph.ClassBasedEdgeFactory.createEdge(Unknown Source) ~[jgrapht-jdk1.5-0.7.3.jar:0.7.3-jdk1.5]

Thus, this is a typical jar-hell situation. Note that all of TL code does not require capabilities from old version. Some part of EOP lexical miner (Wikipedia minor) uses that old jgrapht, but those codes are not called (even cannot be accessed) from TL layer --- we are not using any of older version of jgrapht. So in this case, the Jarhell situation can be resolved, simply by somehow hiding older version and let only the newer version is visible and used.

For now, this is our best guess. (thanks to Lili, for pointing out this possibility). Here's our recommendation.

Can you adjust your system's "dependency list" and make sure your project first sees the required (new) version of jgrapht and jgraph? In Maven, this can be done by adding the above dependency explicitely, and before "before" anything else (e.g. even before TL) --- but I guess you are using some other project tool; so I guess you need to follow that tool's policy...

What I'm suggesting is to add the above two graph related libraries within your top project dependency directly, before including any other dependencies. Which will make sure your environment is running the above two modules with the correct versions: jgrapht with 0.8.3, jgraph with 5.13.0.0. --- or any equivalent method that will make this happen.

Eh, --- please try this and let us know. Sorry we caused such inconvenience!

mmatthias commented 9 years ago

Ok, I ve got it. You gave me a good advice. Because of the history of the integration we added each component by its own. In our build file we loaded at first the eop and the lap of the project. After this includes we added the tl. Because of that the wrong lib was loader.

The solution was to remove the eop and lap from the build file. Now, this libs get loaded from the tl dependencies.

Thanks to all for the help.

Best Matthias

gilnoh commented 9 years ago

Great that you were able to resolve the issue. Hope that everything works flawless up from now :-) (I am closing the issue, assuming that this is closed for now.)