We're updating the issue view to help you get more done. 

DefaultStringBridge cannot be used with programmatic configuration API

Description

I'm defining a SearchMapping, which includes the following line:

1 .property("connectedGP", ElementType.FIELD).field().analyze(Analyze.NO).norms(Norms.NO).bridge(org.hibernate.search.bridge.builtin.impl.DefaultStringBridge.class)

Because DefaultStringBridge's constructor is private, I get the following exception during initialization:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 15:05:18,019 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./a9b6b6ca-cc36-4a38-9bd0-4717da5ce7e6: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./a9b6b6ca-cc36-4a38-9bd0-4717da5ce7e6: Failed to start service at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.0.Final.jar:1.2.0.Final] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_45] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_45] at java.lang.Thread.run(Thread.java:744) [rt.jar:1.7.0_45] Caused by: java.lang.RuntimeException: org.hibernate.search.SearchException: HSEARCH000139: Unable to instantiate FieldBridge for connectedGP of class org.jgroups.Address at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:216) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:86) at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:71) at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final] at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final] ... 3 more Caused by: org.hibernate.search.SearchException: HSEARCH000139: Unable to instantiate FieldBridge for connectedGP of class org.jgroups.Address at org.hibernate.search.bridge.impl.BridgeFactory.doExtractType(BridgeFactory.java:617) at org.hibernate.search.bridge.impl.BridgeFactory.doExtractType(BridgeFactory.java:578) at org.hibernate.search.bridge.impl.BridgeFactory.guessType(BridgeFactory.java:394) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindFieldAnnotation(AnnotationMetadataProvider.java:798) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.checkForFields(AnnotationMetadataProvider.java:1006) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeMemberLevelAnnotations(AnnotationMetadataProvider.java:634) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.initializeClass(AnnotationMetadataProvider.java:345) at org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.getTypeMetadataFor(AnnotationMetadataProvider.java:119) at org.hibernate.search.spi.SearchFactoryBuilder.initDocumentBuilders(SearchFactoryBuilder.java:373) at org.hibernate.search.spi.SearchFactoryBuilder.buildNewSearchFactory(SearchFactoryBuilder.java:219) at org.hibernate.search.spi.SearchFactoryBuilder.buildSearchFactory(SearchFactoryBuilder.java:143) at org.infinispan.query.impl.LifecycleManager.getSearchFactory(LifecycleManager.java:213) at org.infinispan.query.impl.LifecycleManager.cacheStarting(LifecycleManager.java:73) at org.infinispan.factories.ComponentRegistry.notifyCacheStarting(ComponentRegistry.java:228) at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:214) at org.infinispan.CacheImpl.start(CacheImpl.java:675) at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:553) at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:516) at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:398) at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:412) at org.jboss.as.clustering.infinispan.DefaultCacheContainer.getCache(DefaultCacheContainer.java:103) at org.jboss.as.clustering.infinispan.DefaultCacheContainer.getCache(DefaultCacheContainer.java:94) at com.sgi.song.gp.util.InfinispanCacheRestarter.restartCaches(InfinispanCacheRestarter.java:33) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_45] at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45] at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:93) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:266) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:253) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:232) at org.jboss.weld.event.FastEvent.fire(FastEvent.java:125) at org.jboss.weld.servlet.HttpContextLifecycle.contextInitialized(HttpContextLifecycle.java:113) at org.jboss.weld.servlet.WeldInitialListener.contextInitialized(WeldInitialListener.java:95) at io.undertow.servlet.core.ApplicationListeners.contextInitialized(ApplicationListeners.java:173) at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:187) ... 7 more Caused by: java.lang.IllegalAccessException: Class org.hibernate.search.bridge.impl.BridgeFactory can not access a member of class org.hibernate.search.bridge.builtin.impl.DefaultStringBridge with modifiers "private" at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109) [rt.jar:1.7.0_45] at java.lang.Class.newInstance(Class.java:368) [rt.jar:1.7.0_45] at org.hibernate.search.bridge.impl.BridgeFactory.doExtractType(BridgeFactory.java:592) ... 42 more

I can't leave the bridge unspecified, because that causes an exception saying that Hibernate Search doesn't know how to map the field (which happens to be a JGroups UUID Address), and the SearchMapping API doesn't provide a way to give an instance of a bridge rather than the bridge's class.

I'm currently working around this by making a copy of the DefaultStringBridge class and commenting out the private constructor, so it ends up with the default public constructor which can be instantiated.

Environment

None

Status

Assignee

Hardy Ferentschik

Reporter

Rich DiCroce

Fix versions

Affects versions

4.5.0.Final

Priority

Major