Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException when creating a EntityManagerFactory #6963

Closed
1 task done
iitnmohit opened this issue Feb 6, 2024 · 1 comment
Closed
1 task done
Labels
type=defect Bug, not working as expected

Comments

@iitnmohit
Copy link

Description

https://stackoverflow.com/questions/69845106/arrayindexoutofboundsexception-when-creating-a-entitymanagerfactory

I'm using the Spring Framework in addition with the spring-data-jpa. I want to create my DataSource and EntityManagerFactory promatically by creating the beans because as from my Knowledge it's not possible to use a properties file with all that stuff in a pure Spring context.

Please do not wonder about my configuration if anything doesn't make sense. This is just a bunch of code I got from the internet because I'm not that into hibernate/spring-data-jpa/jpa and how its ever called.

So my problem now is that I want to create my EntityManagerFactory but, it throws an ArrayIndexOutOfBoundsException and I have no clue where it gets from and how I get rid of it.

Example

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [de/nebelniek/BukkitConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1154) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:908) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:93) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at de.nebelniek.Subserver.onEnable(Subserver.java:15) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Purpur-1418]
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Purpur-1418]
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Purpur-1418]
    at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:561) ~[patched_1.17.1.jar:git-Purpur-1418]
    at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:475) ~[patched_1.17.1.jar:git-Purpur-1418]
    at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:733) ~[patched_1.17.1.jar:git-Purpur-1418]
    at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:353) ~[patched_1.17.1.jar:git-Purpur-1418]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1230) ~[patched_1.17.1.jar:git-Purpur-1418]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[patched_1.17.1.jar:git-Purpur-1418]
    at java.lang.Thread.run(Thread.java:831) ~[?:?]
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
    at org.jboss.jandex.Indexer.updateTypeTarget(Indexer.java:903) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.jboss.jandex.Indexer.updateTypeTargets(Indexer.java:630) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.jboss.jandex.Indexer.index(Indexer.java:1698) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.archive.internal.JarFileBasedArchiveDescriptor.visitArchive(JarFileBasedArchiveDescriptor.java:147) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.archive.scan.spi.AbstractScannerImpl.scan(AbstractScannerImpl.java:48) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.model.process.internal.ScanningCoordinator.coordinateScan(ScanningCoordinator.java:76) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.prepare(MetadataBuildingProcess.java:107) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:269) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.<init>(EntityManagerFactoryBuilderImpl.java:182) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:52) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[bukkit-1.0-SNAPSHOT-shaded.jar:?]
    ... 21 more

Expected Behavior

There should be no such error, using version

com.google.guava
guava
30.1.1-jre

	resolve the issue.
	
	i wonder why new version have this issue if it was fixed before

Actual Behavior

Throwing Error

Packages

No response

Platforms

No response

Checklist

@iitnmohit iitnmohit added the type=defect Bug, not working as expected label Feb 6, 2024
@ben-manes
Copy link
Contributor

Looks like a jandex bug in parsing the class definition unrelated to Guava, but the library version made it happen in the wild. They fixed it in the stack overflow linked issue, so you should upgrade that dependency instead.

smallrye/jandex#147

@kluever kluever closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type=defect Bug, not working as expected
Projects
None yet
Development

No branches or pull requests

3 participants