Bug 509363 - ClassCastException below SearchIndex.<init> (thrown in Class.asSubclass)
Summary: ClassCastException below SearchIndex.<init> (thrown in Class.asSubclass)
Status: CLOSED DUPLICATE of bug 517935
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2016-12-16 11:35 EST by EPP Error Reports CLA
Modified: 2017-06-07 11:30 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description EPP Error Reports CLA 2016-12-16 11:35:44 EST
The following problem was reported via the automated error reporting:

Message: An internal error occurred during: "Indexing help...".
java.lang.ClassCastException: class org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat
    at java.lang.Class.asSubclass(Class.java:3404)
    at org.apache.lucene.util.SPIClassIterator.next(SPIClassIterator.java:158)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:70)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:51)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:38)
    at org.apache.lucene.codecs.PostingsFormat$Holder.<clinit>(PostingsFormat.java:49)
    at org.apache.lucene.codecs.PostingsFormat.forName(PostingsFormat.java:112)
    at org.apache.lucene.codecs.lucene60.Lucene60Codec.<init>(Lucene60Codec.java:167)
    at org.apache.lucene.codecs.lucene60.Lucene60Codec.<init>(Lucene60Codec.java:82)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeConstructorAccessorImpl.java:-2)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.apache.lucene.util.NamedSPILoader.reload(NamedSPILoader.java:72)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:49)
    at org.apache.lucene.util.NamedSPILoader.<init>(NamedSPILoader.java:38)
    at org.apache.lucene.codecs.Codec$Holder.<clinit>(Codec.java:47)
    at org.apache.lucene.codecs.Codec.forName(Codec.java:116)
    at org.apache.lucene.index.SegmentInfos.readCodec(SegmentInfos.java:417)
    at org.apache.lucene.index.SegmentInfos.readCommit(SegmentInfos.java:349)
    at org.apache.lucene.index.SegmentInfos.readCommit(SegmentInfos.java:284)
    at org.apache.lucene.index.StandardDirectoryReader$1.doBody(StandardDirectoryReader.java:56)
    at org.apache.lucene.index.StandardDirectoryReader$1.doBody(StandardDirectoryReader.java:53)
    at org.apache.lucene.index.SegmentInfos$FindSegmentsFile.run(SegmentInfos.java:685)
    at org.apache.lucene.index.StandardDirectoryReader.open(StandardDirectoryReader.java:76)
    at org.apache.lucene.index.DirectoryReader.open(DirectoryReader.java:63)
    at org.eclipse.help.internal.search.SearchIndex.<init>(SearchIndex.java:202)
    at org.eclipse.help.internal.search.SearchIndex.<init>(SearchIndex.java:156)
    at org.eclipse.help.internal.search.SearchIndexWithIndexingProgress.<init>(SearchIndexWithIndexingProgress.java:24)
    at org.eclipse.help.internal.search.LocalSearchManager.getIndex(LocalSearchManager.java:183)
    at org.eclipse.help.internal.search.federated.IndexerJob.run(IndexerJob.java:26)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)


The reporter(s) left the following comment(s):

--- Andreas Sewe wrote on 2689: ---
I have Ctrlflow Code Seach Professional installed (from <https://marketplace.eclipse.org/content/ctrlflow-code-search>) which ships with a Lucene 5.2.1 (not from Orbit, though). Apparently, this causes the Lucene 5.x and 6.x classes to be wired in a bad way.

Bundles:
| org.eclipse.core.jobs | 3.8.0.v20161110-0346 | 3.8.0.v20161110-0346 |
| org.eclipse.help | 3.8.0.v20160823-1530 | 3.8.0.v20160823-1530 |

Operating Systems:
| MacOSX | 10.10.5 | 10.10.5 |


The above information is a snapshot of the collected data. Visit https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/problems/5854158ce4b08535e634268a for the latest data.

Thank you for your assistance.
 Your friendly error-reports-inbox.
Comment 1 Andreas Sewe CLA 2016-12-16 11:40:51 EST
This happened while testing Oxygen M4 (Java EPP package) and installing Ctrlflow Code Search Professional [1] on top it.'

Some infos from the OSGi console:

osgi> ss | grep lucene
45	RESOLVED    org.apache.lucene.core_3.5.0.v20120725-1805
474	RESOLVED    org.apache.lucene.analyzers-common_6.1.0.v20161115-1612
475	RESOLVED    org.apache.lucene.analyzers-smartcn_6.1.0.v20161115-1612
476	RESOLVED    org.apache.lucene.core_6.1.0.v20161115-1612
477	RESOLVED    org.apache.lucene.misc_6.1.0.v20161115-1612
756	RESOLVED    org.apache.lucene.analyzers-common_5.2.1.v20151013-1320
757	RESOLVED    org.apache.lucene.core_5.2.1.v20151013-1320
758	RESOLVED    org.apache.lucene.queries_5.2.1.v20151013-1320

osgi> p org.apache.lucene.util
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="5.2.1.v20151013-1320"; version:Version="5.2.1"; osgi.wiring.package="org.apache.lucene.util"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.search,org.apache.lucene.store"<org.apache.lucene.core_5.2.1.v20151013-1320 [757]>
  org.apache.lucene.queries_5.2.1.v20151013-1320 [758] imports
  org.apache.lucene.analyzers-common_5.2.1.v20151013-1320 [756] imports
  com.codetrails.codesearch_2.1.0.v20161216-1601-b000 [762] imports
osgi.wiring.package; bundle-symbolic-name="org.eclipse.m2e.maven.indexer"; bundle-version:Version="1.8.0.20160921-2001"; provider="m2e"; version:Version="0.0.0"; osgi.wiring.package="org.apache.lucene.util"; mandatory:="provider"<org.eclipse.m2e.maven.indexer_1.8.0.20160921-2001 [602]>
  org.eclipse.m2e.core.ui_1.8.0.20160921-2002 [591] imports
  org.eclipse.m2e.core_1.8.0.20160921-2002 [590] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="3.5.0.v20120725-1805"; version:Version="3.5.0"; osgi.wiring.package="org.apache.lucene.util"<org.apache.lucene.core_3.5.0.v20120725-1805 [45]>
  org.eclipse.recommenders.snipmatch_2.4.6.v20161130-1433 [704] imports
  org.eclipse.mylyn.tasks.index.core_3.22.0.v20161011-2205 [648] imports
  org.eclipse.epp.logging.aeri.ide_2.0.3.v20161205-0933 [133] imports
  org.eclipse.recommenders.types.rcp_2.4.6.v20161130-1433 [707] imports
  org.eclipse.recommenders.models_2.4.6.v20161130-1433 [697] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="6.1.0.v20161115-1612"; version:Version="6.1.0"; osgi.wiring.package="org.apache.lucene.util"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.search,org.apache.lucene.store"<org.apache.lucene.core_6.1.0.v20161115-1612 [476]>
  org.apache.lucene.analyzers-smartcn_6.1.0.v20161115-1612 [475] imports
  org.apache.lucene.misc_6.1.0.v20161115-1612 [477] imports
  org.eclipse.help.base_4.2.0.v20161208-0830 [557] imports
  org.apache.lucene.analyzers-common_6.1.0.v20161115-1612 [474] imports

[1] <https://marketplace.eclipse.org/content/ctrlflow-code-search>
Comment 2 Nobody - feel free to take it CLA 2016-12-16 12:27:15 EST
Do you have an update site for me to install and reproduce?

Also, are you providing a pre-built index built with Lucene 5.2.1 ?
Comment 3 Andreas Sewe CLA 2016-12-16 12:38:15 EST
(In reply to Sopot Cela from comment #2)
> Do you have an update site for me to install and reproduce?

Hi Sopot. I got my Oxygen M4 EPP package from straight from Hudson [1]. The third-party plug-in (which I co-develop) using Lucene 5.2.1 is from the Marketplace [2]. Its Lucene 5.2.1 is not yet from taken Orbit (as Orbit didn't have it at the time), but that's on my to-do list.

> Also, are you providing a pre-built index built with Lucene 5.2.1 ?

No, the third-party plugin doesn't use any pre-built help indexes; all it does is include a copy of Lucene 5.2.1 in its features.

Hope that helps.

[1] <https://hudson.eclipse.org/packaging/job/oxygen.epp-tycho-build/145/artifact/org.eclipse.epp.packages/archive/>
[2] <https://marketplace.eclipse.org/content/ctrlflow-code-search>
Comment 4 Nobody - feel free to take it CLA 2016-12-16 12:48:11 EST
With Bug 466829 we now expect plugins to adopt Lucene 6.1.0 (it was also announced on cross-project list).

However installing from the market place doesn't work for me for some reason that's why I asked for a p2 update site to install and try to reproduce.
Comment 5 Andreas Sewe CLA 2016-12-16 12:51:53 EST
(In reply to Sopot Cela from comment #4)
> With Bug 466829 we now expect plugins to adopt Lucene 6.1.0 (it was also
> announced on cross-project list).

Yes, I know. But third-party plug-ins may still use all kinds of versions.

> However installing from the market place doesn't work for me for some reason
> that's why I asked for a p2 update site to install and try to reproduce.

Ah. Try the one listed at [1]. (FWIW, you don't need to register a trial; just installing is enough to add the Lucene bundles to your Eclipse installation.)

[1] <https://www.ctrlflow.com/trial/install/#updateSite>
Comment 6 Nobody - feel free to take it CLA 2016-12-16 12:57:19 EST
I installed it from the p2 site you mentioned then opened help and typed something. This did not bring anything out of the ordinary.

Can you supply some steps to reproduce?
Comment 7 Roland Grunberg CLA 2016-12-16 13:08:06 EST
I've also tried this out and it seems to work for me. I installed Oxygen M4 package for committers, and installed the Ctrlflow Code Search from the update site.

Help -> Help Contents, and doing any number of searches seems to work as expected. Even going to the Manual from the Help dropdown from within the Code Search view works for me. I could try playing around with some combination of both but it all seems to work.
Comment 8 Andreas Sewe CLA 2016-12-19 04:16:33 EST
(In reply to Sopot Cela from comment #6)
> I installed it from the p2 site you mentioned then opened help and typed
> something. This did not bring anything out of the ordinary.
> 
> Can you supply some steps to reproduce?

(In reply to Roland Grunberg from comment #7)
> I've also tried this out and it seems to work for me. I installed Oxygen M4
> package for committers, and installed the Ctrlflow Code Search from the
> update site.
> 
> Help -> Help Contents, and doing any number of searches seems to work as
> expected. Even going to the Manual from the Help dropdown from within the
> Code Search view works for me. I could try playing around with some
> combination of both but it all seems to work.

I tried to create a fresh Eclipse to exactly retrace my steps:

- I installed Neon.1a
- Then I installed Ctrlflow Code Search Professional
- Then I performed an upgrade (Help > Check for Upgrades) to Oxygen M4 using these update sites [1,2].

But I must have missed something; I cannot reproduce the issue. :-(

However, I still have the problematical install sitting on my hard-drive, so if you need me to type additional commands into the Host OSGi console to analyze the writing situation, please say so.

[1] <http://download.eclipse.org/technology/epp/packages/oxygen/M4>
[2] <http://download.eclipse.org/staging/oxygen>
Comment 9 Andreas Sewe CLA 2016-12-19 04:28:30 EST
(In reply to Andreas Sewe from comment #8)
> However, I still have the problematical install sitting on my hard-drive, so
> if you need me to type additional commands into the Host OSGi console to
> analyze the writing situation, please say so.

Dug some more myself:

The failed cast is from org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat to org.apache.lucene.codecs.PostingsFormat, with PostingsFormat$Holder.<clinit> using org.apache.lucene.util.NamedSPILoader to get a PostingFormat.

osgi> p org.apache.lucene.codecs.lucene50
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="5.2.1.v20151013-1320"; version:Version="5.2.1"; osgi.wiring.package="org.apache.lucene.codecs.lucene50"; uses:="org.apache.lucene.codecs,org.apache.lucene.codecs.compressing,org.apache.lucene.index,org.apache.lucene.store,org.apache.lucene.util"<org.apache.lucene.core_5.2.1.v20151013-1320 [803]>
  com.codetrails.codesearch_2.0.4.v20161214-1619-b646 [790] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="6.1.0.v20161115-1612"; version:Version="6.1.0"; osgi.wiring.package="org.apache.lucene.codecs.lucene50"; uses:="org.apache.lucene.codecs,org.apache.lucene.codecs.compressing,org.apache.lucene.index,org.apache.lucene.store,org.apache.lucene.util"<org.apache.lucene.core_6.1.0.v20161115-1612 [476]>
  org.apache.lucene.misc_6.1.0.v20161115-1612 [477] imports
  org.eclipse.help.base_4.2.0.v20161208-0830 [557] imports

osgi> p org.apache.lucene.codecs
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="5.2.1.v20151013-1320"; version:Version="5.2.1"; osgi.wiring.package="org.apache.lucene.codecs"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.store,org.apache.lucene.util"<org.apache.lucene.core_5.2.1.v20151013-1320 [803]>
  com.codetrails.codesearch_2.0.4.v20161214-1619-b646 [790] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="6.1.0.v20161115-1612"; version:Version="6.1.0"; osgi.wiring.package="org.apache.lucene.codecs"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.store,org.apache.lucene.util"<org.apache.lucene.core_6.1.0.v20161115-1612 [476]>
  org.apache.lucene.misc_6.1.0.v20161115-1612 [477] imports
  org.eclipse.help.base_4.2.0.v20161208-0830 [557] imports
  org.apache.lucene.analyzers-common_6.1.0.v20161115-1612 [474] imports

osgi> p org.apache.lucene.util 
osgi.wiring.package; bundle-symbolic-name="org.eclipse.m2e.maven.indexer"; bundle-version:Version="1.8.0.20160921-2001"; provider="m2e"; version:Version="0.0.0"; osgi.wiring.package="org.apache.lucene.util"; mandatory:="provider"<org.eclipse.m2e.maven.indexer_1.8.0.20160921-2001 [602]>
  org.eclipse.m2e.core.ui_1.8.0.20160921-2002 [591] imports
  org.eclipse.m2e.core_1.8.0.20160921-2002 [590] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="5.2.1.v20151013-1320"; version:Version="5.2.1"; osgi.wiring.package="org.apache.lucene.util"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.search,org.apache.lucene.store"<org.apache.lucene.core_5.2.1.v20151013-1320 [803]>
  org.apache.lucene.analyzers-common_5.2.1.v20151013-1320 [802] imports
  com.codetrails.codesearch_2.0.4.v20161214-1619-b646 [790] imports
  org.apache.lucene.queries_5.2.1.v20151013-1320 [804] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="3.5.0.v20120725-1805"; version:Version="3.5.0"; osgi.wiring.package="org.apache.lucene.util"<org.apache.lucene.core_3.5.0.v20120725-1805 [45]>
  org.eclipse.recommenders.snipmatch_2.4.6.v20161130-1433 [704] imports
  org.eclipse.mylyn.tasks.index.core_3.22.0.v20161011-2205 [648] imports
  org.eclipse.epp.logging.aeri.ide_2.0.3.v20161205-0933 [133] imports
  org.eclipse.recommenders.types.rcp_2.4.6.v20161130-1433 [707] imports
  org.eclipse.recommenders.models_2.4.6.v20161130-1433 [697] imports
osgi.wiring.package; bundle-symbolic-name="org.apache.lucene.core"; bundle-version:Version="6.1.0.v20161115-1612"; version:Version="6.1.0"; osgi.wiring.package="org.apache.lucene.util"; uses:="org.apache.lucene.analysis,org.apache.lucene.index,org.apache.lucene.search,org.apache.lucene.store"<org.apache.lucene.core_6.1.0.v20161115-1612 [476]>
  org.apache.lucene.analyzers-smartcn_6.1.0.v20161115-1612 [475] imports
  org.apache.lucene.misc_6.1.0.v20161115-1612 [477] imports
  org.eclipse.help.base_4.2.0.v20161208-0830 [557] imports
  org.apache.lucene.analyzers-common_6.1.0.v20161115-1612 [474] imports
Comment 10 Roland Grunberg CLA 2016-12-19 13:35:17 EST
I've been looking at the wiring that you've posted but nothing stands out as odd. There's nothing from Lucene 6 that gets wired to Lucen 5 that could explain this.

I did have a look through the sources and discovered the same cause you did, Lucene50PostingsFormat being cast to PostingsFormat. There did seem to be a bit of classloader manipulation happening just before so perhaps this is a bug in how Lucene is doing things.

Another possibility is that this could be a uses constraint violation that isn't defined in the metadata so it just silently fails like so. com.codetrails.codesearch uses Lucene 5, and I would think it calls the Help System in order to get that help page showing up from your  Ctrlflow View. The Help System uses Lucene 6, so that's where the overlap might occur.
Comment 11 Nobody - feel free to take it CLA 2016-12-22 06:49:07 EST
Andreas, if you come up with steps to reproduce I will push this on top of my list. Until then I'll resolve this as WORKSFORME.
Comment 12 Roland Grunberg CLA 2017-06-07 11:27:15 EDT
It seems this is Bug 517935. Does it make this one as a duplicate ?
Comment 13 Andreas Sewe CLA 2017-06-07 11:30:57 EDT
(In reply to Roland Grunberg from comment #12)
> It seems this is Bug 517935. Does it make this one as a duplicate ?

Oh, of course. Bug 517935 contains a far better analysis of the root cause (service implementation lock-in in Class.forName); in comment 9 I was still thinking this might be a wiring problem, which it is not.

*** This bug has been marked as a duplicate of bug 517935 ***