hibernate/hibernate-orm · error · HibernateException

Error accessing StAX stream

Error message

Error accessing StAX stream

What it means

Error "Error accessing StAX stream" thrown in hibernate/hibernate-orm.

Source

Thrown at hibernate-core/src/main/java/org/hibernate/boot/cfgxml/internal/JaxbCfgProcessor.java:133

							+ ". Message: " + handler.getMessage(), e
			);
		}
	}

	private static XMLEvent xmlEvent(XMLEventReader staxEventReader) {
		try {
			XMLEvent event = staxEventReader.peek();
			while ( event != null && !event.isStartElement() ) {
				staxEventReader.nextEvent();
				event = staxEventReader.peek();
			}
			if ( event == null ) {
				throw new HibernateException( "Could not locate root element" );
			}
			return event;
		}
		catch ( Exception e ) {
			throw new HibernateException( "Error accessing StAX stream", e );
		}
	}

	private boolean isNamespaced(StartElement startElement) {
		return isNotEmpty( startElement.getName().getNamespaceURI() );
	}

	private Schema schema;

	private Schema schema() {
		if ( schema == null ) {
			schema = resolveLocalSchema( "org/hibernate/hibernate-configuration-4.0.xsd" );
		}
		return schema;
	}

	private Schema resolveLocalSchema(String schemaName) {
		return resolveLocalSchema( schemaName, W3C_XML_SCHEMA_NS_URI );

View on GitHub (pinned to fad1729dce)

Solutions

  1. Inspect the wrapped XMLStreamException cause; it usually reports the underlying I/O or syntax problem.
  2. Make sure the input stream for the XML resource stays open for the duration of parsing.
  3. Verify a compatible StAX parser is on the classpath and not corrupted by dependency shading.

When it happens

Trigger: The JDK StAX parser fails while reading a Hibernate XML configuration file.

Common situations: Malformed XML in hibernate.cfg.xml, or XML parser/dependency conflicts on the classpath.


AI-assisted analysis of hibernate/hibernate-orm@fad1729dce (2026-08-22). Data as JSON: /api/errors/1d401894aa6f0a0f. Report an issue: GitHub.