[Hibernate-JIRA] Created: (HSEARCH-1106) Compile error on MappingModelMetadataProvider on some JVMs only
by Sanne Grinovero (JIRA)
Compile error on MappingModelMetadataProvider on some JVMs only
---------------------------------------------------------------
Key: HSEARCH-1106
URL: https://hibernate.onjira.com/browse/HSEARCH-1106
Project: Hibernate Search
Issue Type: Bug
Reporter: Sanne Grinovero
Assignee: Gail Badner
Priority: Critical
On some JVMs compiling Search results in a compile error:
{quote}
Compilation failure:
[ERROR]
\hibernate-search\hibernate-search-engine\src\main\java\org\hibernate\search\impl\MappingModelMetadataProvider.java:[251,34]
type parameters of <T>T cannot be determined; no unique maximal instance
exists for type variable T with upper bounds
T,java.lang.annotation.Annotation
[ERROR]
\hibernate-search\hibernate-search-engine\src\main\java\org\hibernate\search\impl\MappingModelMetadataProvider.java:[257,84]
type parameters of <T>T cannot be determined; no unique maximal instance
exists for type variable T with upper bounds
T,java.lang.annotation.Annotation
{quote}
See also thread on mailing list:
http://lists.jboss.org/pipermail/hibernate-dev/2012-April/008195.html
specifically Nicolas:
{quote}
After a goo bisect it seems 31b485c1aaabd9b0ff178505067147e5628e3010 is the
first bad commit.
It is HSEARCH-1084 Annotation proxies created by Programmatic Mapping
I m still on windows 7 x64 with 1.6.0_24 jvm
{quote}
and Emmanuel:
{quote}
It seems that we are a bit optimistic with out generic Russian dolls
http://stackoverflow.com/questions/2431334/java-generics-what-is-the-comp...
/**
* Creates the proxy for an annotation using Hibernate Commons Annotations
* @param annotation the AnnotationDescriptor
* @return the proxy
*/
private static <T extends Annotation> T createAnnotation(AnnotationDescriptor annotation) {
//This is a filthy workaround for the Annotations proxy generation,
//which is using the ContextClassLoader to define the proxy classes
//(not working fine in modular environments when Search is used by
//other services such as CapeDwarf).
//See HSEARCH-1084
//use annotation's own classloader
try {
return AnnotationFactory.create( annotation, annotation.type().getClassLoader() );
}
catch ( Exception e ) {
//first try, but we have another trick
}
//Use TCCL
return org.hibernate.annotations.common.annotationfactory.AnnotationFactory.create( annotation );
}
Basically the compiler cannot guarantee that T in the outer method is the same as T in the AnnotationFactory.create methods. Unfortunately it yells in some strange language.
It looks like the compiler is a bit more stupid on Windows for some obscure reason. Could you try 1.6.0_31 (the latest)?
{quote}
Assigning to Gail as she was able to reproduce locally and seems to have a solution already.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months
[Hibernate-JIRA] Created: (HSEARCH-1088) Specifying an analyzer on an entity class bridge using the programmatic API is broken
by Michael Heinrichs (JIRA)
Specifying an analyzer on an entity class bridge using the programmatic API is broken
-------------------------------------------------------------------------------------
Key: HSEARCH-1088
URL: https://hibernate.onjira.com/browse/HSEARCH-1088
Project: Hibernate Search
Issue Type: Bug
Components: engine
Affects Versions: 4.1.0.CR3
Environment: Hibernate 4.1.1.Final
Reporter: Michael Heinrichs
Attachments: MappingModelMetadataProvider.java.diff
The programmatic API provides the ability to specify an analyzer on an entity class bridge (ClassBridgeMapping), but during initialization, an exception is thrown. See below for an example search mapping, exception stack trace, and the diff for my fix.
I modified the Hibernate Search code by copying the analyzer initialization code from the creation of fields into the creation of class bridges. It appears that there may be other attributes that are not being properly processed for class bridges, but this fix solves my immediate problem.
Here is an example:
SearchMapping searchMapping = new SearchMapping();
searchMapping
.analyzerDef("customanalyzer", StandardTokenizerFactory.class)
.filter(LowerCaseFilterFactory.class)
.filter(NGramFilterFactory.class)
.param("minGramSize", "3")
.param("maxGramSize", "3")
.entity(Person.class)
.classBridge(NameAppendingBridge.class)
.name("fullName")
.analyzer("customanalyzer")
.index(Index.YES)
.store(Store.YES)
.param("fields", "frstName,othrName,lastName,mdnName")
.indexed()
...
java.lang.ClassCastException: java.util.HashMap cannot be cast to org.hibernate.search.annotations.Analyzer
at $Proxy26.analyzer(Unknown Source)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.bindClassBridgeAnnotation(AbstractDocumentBuilder.java:885)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeClassLevelAnnotations(AbstractDocumentBuilder.java:425)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.initializeClass(AbstractDocumentBuilder.java:352)
at org.hibernate.search.engine.spi.AbstractDocumentBuilder.<init>(AbstractDocumentBuilder.java:151)
at org.hibernate.search.engine.spi.DocumentBuilderIndexedEntity.<init>(DocumentBuilderIndexedEntity.java:179)
at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:419)
at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:221)
at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:145)
at org.hibernate.search.event.impl.FullTextIndexEventListener.initialize(FullTextIndexEventListener.java:129)
at org.hibernate.search.hcore.impl.HibernateSearchIntegrator.integrate(HibernateSearchIntegrator.java:82)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:304)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1740)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1778)
hibernate-search-4.1.0.CR3/project/hibernate-search-engine/src/main/java/org/hibernate/search/impl/MappingModelMetadataProvider.java.diff:
575c575,584
< if ( entry.getKey().equals( "params" ) ) {
---
> if ( entry.getKey().equals( "analyzer" ) ) {
> AnnotationDescriptor analyzerAnnotation = new AnnotationDescriptor( Analyzer.class );
> @SuppressWarnings("unchecked")
> Map<String, Object> analyzer = (Map<String, Object>) entry.getValue();
> for ( Map.Entry<String, Object> analyzerEntry : analyzer.entrySet() ) {
> analyzerAnnotation.setValue( analyzerEntry.getKey(), analyzerEntry.getValue() );
> }
> annotation.setValue( "analyzer", AnnotationFactory.create( analyzerAnnotation ) );
> }
> else if ( entry.getKey().equals( "params" ) ) {
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 8 months