Description

This article explains the issue observed when the Resync with Network is performed and the solution that fixed the issue.

Symptoms

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>

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:&nbsp;org.hibernate.exception.GenericJDBCException:&nbsp;could&nbsp;not&nbsp;prepare&nbsp;statement

Solution

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:

  • Replace <deviceName> with the name of the device in Junos Space
  • If the device is an SRX cluster. This command MUST be run on both members of the cluster
  • If the device is an SRX LSYS. Run this command on the root device only

 

Example:

 

# cd /var/log/space-debug/debug-utilities/deviceImport/

# 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:

# sh /var/www/cgi-bin/cleanUpDeviceInvStaleEntries.sh

=============================================================================

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

 

  1. Before deleting the device, ensure it doesn't have VPNs created from Space/SD.
  2. Un-assign it from the policy (FW, NAT or IPS)
  3. Delete it and then Re-discover it in Security Director. Ensure that the option "Import policies automatically after device(s) being discovered successfully" is NOT checked.
  4. Assign the device to the old policy (FW, NAT or IPS) and check if the issue persists. ​

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.

Modification History

2025-09-12 : Article Created