{"record":{"id":"49a97daf29b693bf","repo":"quarkusio/quarkus","slug":"failed-to-read-model-class","errorCode":null,"errorMessage":"Failed to read Model class","messagePattern":"Failed to read Model class","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java","lineNumber":1288,"sourceCode":"        for (io.quarkus.hibernate.orm.deployment.AdditionalJpaModelBuildItem additionalJpaModel : deprecatedAdditionalJpaModelBuildItems) {\n            additionalClassNames.add(additionalJpaModel.getClassName());\n        }\n        for (String className : additionalClassNames) {\n            try {\n                byte[] bytes = IoUtil.readClassAsBytes(HibernateOrmProcessor.class.getClassLoader(), className);\n                if (bytes == null) {\n                    bytes = IoUtil.readClassAsBytes(Thread.currentThread().getContextClassLoader(), className);\n                }\n                if (bytes == null) {\n                    throw new RuntimeException(\"Failed to read class bytes for '\" + className\n                            + \"', class not present in class loaders: \"\n                            + HibernateOrmProcessor.class.getClassLoader()\n                            + \", \" + Thread.currentThread().getContextClassLoader());\n                }\n                byte[] enhanced = hibernateEntityEnhancer.enhance(className, bytes);\n                additionalClasses.produce(new GeneratedClassBuildItem(false, className, enhanced != null ? enhanced : bytes));\n            } catch (IOException e) {\n                throw new RuntimeException(\"Failed to read Model class\", e);\n            }\n        }\n    }\n\n    @BuildStep\n    public JpaModelPerPersistenceUnitBuildItem buildJpaModelPerPersistenceUnit(HibernateOrmConfig hibernateOrmConfig,\n            List<AdditionalJpaModelBuildItem> additionalJpaModelBuildItems, JpaModelBuildItem jpaModel,\n            CombinedIndexBuildItem indexBuildItem) {\n        IndexView index = indexBuildItem.getIndex();\n        Map<String, JpaPersistenceUnitModel> modelPerPersistenceUnit = new HashMap<>();\n\n        boolean hasPackagesInQuarkusConfig = hasPackagesInQuarkusConfig(hibernateOrmConfig);\n        Collection<AnnotationInstance> packageLevelPersistenceUnitAnnotations = getPackageLevelPersistenceUnitAnnotations(\n                index);\n\n        Map<String, Set<String>> packageRules = new HashMap<>();\n\n        Set<String> persistenceUnitsConfiguredThroughQuarkusConfiguration = new LinkedHashSet<>();","sourceCodeStart":1270,"sourceCodeEnd":1306,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java#L1270-L1306","documentation":"In the same model-class enhancement flow, after the class bytes are read, an IOException while reading class bytes (or the enhance step reading the stream) is wrapped in a RuntimeException 'Failed to read Model class' with the original IOException as cause.","triggerScenarios":"IoUtil.readClassAsBytes throws IOException while reading bytes for a model class name from either classloader inside the enhancement loop.","commonSituations":"Corrupt jar/class file in the local Maven repository; truncated class resources from a partially-built dependency; jar file access issues (permissions, locked file on Windows).","solutions":["Inspect the IOException cause to find the offending resource, then delete/clean the corrupt artifact from the local Maven repo and rebuild","Run mvn clean install on the module containing the entity class","Check file permissions and disk state for the jars on the classpath"],"exampleFix":"// shell\nrm -rf ~/.m2/repository/com/acme/entities\n./mvnw clean install -f extensions/","handlingStrategy":"try-catch","validationCode":"// Verify jars on the classpath are readable/corruption-free:\nnew java.util.jar.JarFile(pathToEntitiesJar).close(); // throws if corrupt","typeGuard":null,"tryCatchPattern":"try {\n    // build / enhancement step\n} catch (RuntimeException e) {\n    if (\"Failed to read Model class\".equals(e.getMessage()) && e.getCause() instanceof java.io.IOException io) {\n        // inspect io, clean corrupt artifact from ~/.m2 and rebuild\n    }\n    throw e;\n}","preventionTips":["Clean stale artifacts from the local Maven repository after interrupted builds","Run mvn clean install after modifying entity modules","Check disk space and file permissions in CI environments"],"tags":["ioexception","hibernate-orm","bytecode-enhancement","classpath"],"backgroundTag":"class-bytes-read-failure","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}