Recently we added two datasources to our application and our application worked fine without newRelic. But as soon as we added newRelic to our application it failed with a strange error:
2024-11-08 20:22:37 java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
2024-11-08 20:22:37 at org.jboss.jandex.Indexer.updateTypeTarget(Indexer.java:903)
2024-11-08 20:22:37 at org.jboss.jandex.Indexer.updateTypeTargets(Indexer.java:630)
2024-11-08 20:22:37 at org.jboss.jandex.Indexer.index(Indexer.java:1698)
2024-11-08 20:22:37 at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)
2024-11-08 20:22:37 at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52)
2024-11-08 20:22:37 at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147)
2024-11-08 20:22:37 at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:48)
2024-11-08 20:22:37 at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76)
2024-11-08 20:22:37 at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:107)
2024-11-08 20:22:37 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:269)
2024-11-08 20:22:37 at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:182)
2024-11-08 20:22:37 at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:52)
2024-11-08 20:22:37 at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365)
2024-11-08 20:22:37 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409)
2024-11-08 20:22:37 at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396)
2024-11-08 20:22:37 at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341)
2024-11-08 20:22:37 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863)
2024-11-08 20:22:37 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)
After struggling for a lot of time we figured out that one of the datasource was not having any entity defined. After defining a dummy entity for the datasource the error was gone away and the application started working with newRelic also.
Please do comment if you find it useful.