This article explains the issue observed when the Resync with Network is performed and the solution that fixed the issue.
When attempting to resync the affected device in Security Director, the following error message is observed from the SD UI:
“Error while reading config from device: <DeviceName>
Error while reading config from device: <DeviceName>
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement”
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement
Below error messages are generated in /var/log/jboss/servers/server1/server.log:
2025-09-10 13:42:22,249 WARN [net.juniper.jmp.cmp.deviceManager.ejb.DeviceServiceBean] (m-resync-393216) Create a new lsys Root device: <DeviceName>
2025-09-10 13:42:22,250 ERROR [net.juniper.jmp.cmp.deviceManager.ejb.DeviceServiceBean] (m-resync-383216) lsysName is null or empty string, Can't create lsys record
2025-09-10 13:42:22,261 ERROR [org.jboss.as.ejb3.invocation] (m-resync-393216) WFLYEJB0034: EJB Invocation failed on component ImportConfigServiceEJB for method public abstract void net.juniper.jmp.cems.configManager.ejb.ImportConfigService.persisOrMergeDevices(net.juniper.jmp.metadata.CommonResourceInfoEntityInterface,net.juniper.jmp.cmp.deviceManager.DeviceDO): javax.ejb.EJBTransactionRolledbackException: For input string: ""
2025-09-10 13:42:22,287 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (m-resync-383216) SQL Error: 0, SQLState: null
2025-09-10 13:42:22,287 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (m-resync-383216) IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK
2025-09-10 13:42:22,295 WARN [net.juniper.jmp.cmp.search.indexer.global.ejb.SearchServiceManager] (m-resync-383216) Enabling search server delta start time: Wed Sep 10 13:42:22 UTC 2025
2025-09-10 13:42:22,297 ERROR [org.jboss.as.ejb3.invocation] (m-resync-393216) WFLYEJB0034: EJB Invocation failed on component ImportConfigServiceEJB for method public abstract java.util.List net.juniper.jmp.cems.configManager.ejb.ImportConfigService.persistDeviceConfiguration(net.juniper.jmp.cmp.deviceManager.DeviceDO,java.util.HashMap,net.juniper.jmp.cems.configManager.DeviceImportConfigDO,net.juniper.jmp.cmp.deviceChange.NotificationMetadata): javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement
…
Caused by: org.hibernate.exception.GenericJDBCException: could not prepare statement
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) [hibernate-core-5.3.20.Final.jar:5.3.20.Final]
...
at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1566) [hibernate-core-5.3.20.Final.jar:5.3.20.Final]
... 525 more
Caused by: java.sql.SQLException: IJ031070: Transaction cannot proceed: STATUS_MARKED_ROLLBACK
at org.jboss.jca.adapters.jdbc.WrapperDataSource.checkTransactionActive(WrapperDataSource.java:272)
2025-09-10 13:42:22,359 WARN [net.juniper.jmp.utils.DeviceStatusNotificationUtil] (m-resync-383216) Publish 'Device Status Change' notification for device <DeviceName>
2025-09-10 13:42:22,361 WARN [net.juniper.jnap.sm.device.ejb.SecurityDeviceManagerBean] (Thread-51 (ActiveMQ-client-global-threads)) No entity found for update with deviceIdnet.juniper.jmp.jpa.LogicalDevice:383216
2025-09-10 13:42:22,367 ERROR [ResyncDevicesManagerBean] (m-resync-1234) Resync failed for device 192.168.1.1 id:383216 reason: Error while reading config from device: <DeviceName>
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not prepare statement
Follow these steps to resolve the issue:
1. Login to the primary Junos Space CLI and run the following commands:
# cd /var/log/space-debug/debug-utilities/deviceImport/
# sh cleanupDeviceImportTables.sh <deviceName>
Note:
Example:
# sh cleanupDeviceImportTables.sh <device-name-0>
# sh cleanupDeviceImportTables.sh <device-name-1>
2. Resync Devices
Perform "Resynchronize with Network" for all devices where the cleanup command was executed.
3. If the issue persists, execute the following script:
# sh /var/www/cgi-bin/cleanUpDeviceInvStaleEntries.sh
Example output:
=============================================================================
No stale entries found in the Device Inventories. No devices are in Sync Failed state at the moment..
4. After running the cleanup script, perform "Resynchronize with Network" again for the affected devices.
5. If the issue persists, try deleting and re-discovering the device in Junos Space
Note: If the device uses LSYS, re-discover all associated LSYS as well.
If the issue persists, please contact HPE Juniper support for further investigation and assistance.