У меня было приложение Java на Java 17, которое использует протокол IIOP CORBA для прослушивателя соединений JMS-сообщений и их дальнейшей обработки.
После обновления с Java 17 до Java25 я получаю сообщение об ошибке ниже: "Exception java.lang.NoClassDefFoundError: sun/security/action/GetPropertyAction".
Я не хочу понижать версию системе на Java 21 или ниже, я хочу оставить систему с Java 25.
Я хочу прослушивать сообщение/событие JMS с сервера, который поддерживает только протокол IIOP CORBA. Как мне этого добиться в Java 25? Я слышал, что IBM удалила эту поддержку из Java 25.
import java.util.Properties;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.ibm.ws.sib.api.jms.impl.JmsObjectMessageImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import com.aa.oss.dd.access.notification.Event;
@Component
public class NasdaNotificationListener
implements MessageListener
{
private static final Logger LOGGER = LogManager.getLogger( NasdaNotificationListener.class );
private static final int MAX_RECONNECT_BACKOFF_MS = 60000; // 1 minute max backoff
private static final int INITIAL_RECONNECT_DELAY_MS = 2000; // 2 seconds initial delay
private final ReentrantLock lock = new ReentrantLock();
@Value( "${java-naming-provider-url}" )
private String javaNamingProviderUrl;
private TopicConnection connection = null;
private TopicSession subSession = null;
private TopicSubscriber subscriber = null;
private volatile boolean isConnected = false;
private final AtomicInteger consecutiveFailures = new AtomicInteger( 0 );
public void startConnection()
{
lock.lock();
try
{
// If already connected, skip
if( isConnected )
{
LOGGER.info( "NotificationListener already connected, skipping startConnection" );
return;
}
String methodName = "startConnection";
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " Trust store: " + System.getProperty(
"javax.net.ssl.trustStore" ) );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " Key store: " + System.getProperty(
"javax.net.ssl.keyStore" ) );
Properties properties = new Properties();
properties.put( Context.INITIAL_CONTEXT_FACTORY,
NWConstants.NASDA_INITIAL_CONTEXT_FACTORY );
properties.put( Context.PROVIDER_URL, javaNamingProviderUrl );
InitialContext jndi = new InitialContext( properties );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " got initial context" );
TopicConnectionFactory conFactory = (TopicConnectionFactory)jndi.lookup(
NWConstants.NASDA_TCF_NAME );
connection = conFactory.createTopicConnection();
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " creating sub session" );
subSession = connection.createTopicSession( false, Session.AUTO_ACKNOWLEDGE );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " creating topic" );
// Look up a JMS topic
Topic nasdaTopic = (Topic)jndi.lookup( NWConstants.NASDA_TOPIC_NAME );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " creating subscriber" );
subscriber = subSession.createSubscriber( nasdaTopic );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " creating message listener" );
// Set a JMS message listener
subscriber.setMessageListener( this );
LOGGER.info( NWConstants.SE_NAME + " " + methodName + " starting consumer" );
// Start the JMS connection; allows messages to be delivered
connection.start();
isConnected = true;
consecutiveFailures.set( 0 ); // Reset backoff counter on success
Message msg = new JmsObjectMessageImpl(
new Event( NWConstants.NASDA_EVENT_CLIENT_START, null ) );
msg.setJMSMessageID( NWConstants.NASDA_START_NOTIFICATION_MESSAGE_ID );
NotificationQueue.getInstance().offerMessage( msg );
connection.setExceptionListener( jmsexception -> {
LOGGER.warn( NWConstants.SE_NAME + " connection exception handler: " + jmsexception.getMessage(),
jmsexception );
silentStopConnection();
} );
LOGGER.info( "NasdaNotificationListener startConnection end" );
}
catch( Exception e )
{
isConnected = false;
int failures = consecutiveFailures.incrementAndGet();
LOGGER.error( NWConstants.SE_NAME + " Starting connection failed (attempt {}): {}",
failures, e.getMessage(), e );
// Clean up partially created resources to avoid resource leaks
silentStopConnection();
}
finally
{
lock.unlock();
}
}
public final void stopConnection()
{
lock.lock();
try
{
silentClose( subscriber, "subscriber" );
subscriber = null;
silentClose( subSession, "subSession" );
subSession = null;
if( connection != null )
{
try
{
connection.close();
LOGGER.info( NWConstants.SE_NAME + " Closed connection" );
}
catch( Exception e )
{
LOGGER.debug( "Error closing JMS connection (may already be closed): {}", e.getMessage() );
}
connection = null;
}
try
{
Message msg = new JmsObjectMessageImpl(
new Event( NWConstants.NASDA_EVENT_CLIENT_STOP, null ) );
msg.setJMSMessageID( NWConstants.NASDA_STOP_NOTIFICATION_MESSAGE_ID );
NotificationQueue.getInstance().offerMessage( msg );
}
catch( Exception e )
{
LOGGER.debug( "Error sending stop notification message: {}", e.getMessage() );
}
}
finally
{
isConnected = false;
lock.unlock();
}
}
/**
* Stop connection silently without acquiring lock (used from exception listener
* which may be called while lock is not held by this thread).
*/
private void silentStopConnection()
{
try
{
silentClose( subscriber, "subscriber" );
subscriber = null;
silentClose( subSession, "subSession" );
subSession = null;
if( connection != null )
{
try
{
connection.close();
}
catch( Exception ignored )
{
// Already broken
}
connection = null;
}
}
catch( Exception e )
{
LOGGER.debug( "Error during silent stop: {}", e.getMessage() );
}
finally
{
isConnected = false;
}
}
/**
* Safely close a JMS resource, ignoring any exceptions.
*/
private void silentClose( AutoCloseable resource, String name )
{
if( resource != null )
{
try
{
if( resource instanceof TopicSubscriber )
{
( (TopicSubscriber)resource ).setMessageListener( null );
}
resource.close();
}
catch( Exception e )
{
LOGGER.debug( "Error closing {} (may already be closed): {}", name, e.getMessage() );
}
}
}
@Override
public final void onMessage( Message msg )
{
try
{
LOGGER.debug( NWConstants.SE_NAME + " Recieved message from topic: " + msg );
}
catch( Exception e )
{
LOGGER.error( NWConstants.SE_NAME + "Invalid notifiaction from Nasda.", e );
}
}
}
Ошибка ниже:
Failed to initialize the ORB
javax.naming.NamingException: Failed to initialize the ORB
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:517)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:478)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
at com.nokia.oss.mediation.ne3sws.nasda.NasdaNotificationListener.startConnection(NasdaNotificationListener.java:62)
at com.nokia.oss.mediation.ne3sws.NE3SWSApplicationRunner.run(NE3SWSApplicationRunner.java:59)
at org.springframework.boot.SpringApplication.lambda$callRunner$0(SpringApplication.java:788)
at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:82)
at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60)
at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:86)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:800)
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:788)
at org.springframework.boot.SpringApplication.lambda$callRunners$0(SpringApplication.java:776)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:186)
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:571)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:153)
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:176)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:632)
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:776)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:328)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1365)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354)
at com.nokia.oss.mediation.ne3sws.NE3SWSMediationApp.main(NE3SWSMediationApp.java:36)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:106)
at org.springframework.boot.loader.launch.Launcher.launch(Launcher.java:64)
at org.springframework.boot.loader.launch.JarLauncher.main(JarLauncher.java:40)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:508)
... 33 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class javax.rmi.CORBA.Util
at com.ibm.rmi.corba.PluginRegistry.instantiatePlugins(PluginRegistry.java:116)
at com.ibm.rmi.corba.ORB.instantiatePlugins(ORB.java:1525)
at com.ibm.rmi.corba.ORB.orbParameters(ORB.java:1430)
at com.ibm.rmi.corba.ORB.set_parameters(ORB.java:1356)
at com.ibm.CORBA.iiop.ORB.set_parameters(ORB.java:1697)
at org.omg.CORBA.ORB.init(ORB.java:473)
at com.ibm.ws.orb.GlobalORBFactory.init(GlobalORBFactory.java:95)
at com.ibm.ejs.oa.EJSORBImpl.initializeORB(EJSORBImpl.java:169)
at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:64)
at com.ibm.ejs.oa.EJSClientORBImpl.(EJSClientORBImpl.java:44)
at com.ibm.ejs.oa.EJSORB.init(EJSORB.java:85)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 35 more
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoClassDefFoundError: s u n / s e c u r i t y / a c t i o n / G e t P r o p e r t y A c t i o n [ i n t h r e a d & q u o t ; P = 2 8 6 5 1 9 : O = 0 : C T & q u o t ; ] < b r / > a t j a v a x . r m i . C O R B A . U t i l . c r e a t e D e l e g a t e ( U t i l . j a v a : 3 3 8 ) < b r / > a t j a v a x . r m i . C O R B A . U t i l . & l t ; c l i n i t & g t ; ( U t i l . j a v a : 6 5 ) < b r / > a t c o m . i b m . r m i . c o r b a . P l u g i n R e g i s t r y . i n s t a n t i a t e P l u g i n s ( P l u g i n R e g i s t r y . j a v a : 1 1 6 ) < b r / > a t c o m . i b m . r m i . c o r b a . O R B . i n s t a n t i a t e P l u g i n s ( O R B . j a v a : 1 5 2 5 ) < b r / > a t c o m . i b m . r m i . c o r b a . O R B . o r b P a r a m e t e r s ( O R B . j a v a : 1 4 3 0 ) < b r / > a t c o m . i b m . r m i . c o r b a . O R B . s e t _ p a r a m e t e r s ( O R B . j a v a : 1 3 5 6 ) < b r / > a t c o m . i b m . C O R B A . i i o p . O R B . s e t _ p a r a m e t e r s ( O R B . j a v a : 1 6 9 7 ) < b r / > a t o r g . o m g . C O R B A . O R B . i n i t ( O R B . j a v a : 4 7 3 ) < b r / > a t c o m . i b m . w s . o r b . G l o b a l O R B F a c t o r y . i n i t ( G l o b a l O R B F a c t o r y . j a v a : 9 5 ) < b r / > a t c o m . i b m . e j s . o a . E J S O R B I m p l . i n i t i a l i z e O R B ( E J S O R B I m p l . j a v a : 1 6 9 ) < b r / > a t c o m . i b m . e j s . o a . E J S C l i e n t O R B I m p l . & l t ; i n i t & g t ; ( E J S C l i e n t O R B I m p l . j a v a : 6 4 ) < b r / > a t c o m . i b m . e j s . o a . E J S C l i e n t O R B I m p l . & l t ; i n i t & g t ; ( E J S C l i e n t O R B I m p l . j a v a : 4 4 ) < b r / > a t c o m . i b m . e j s . o a . E J S O R B . i n i t ( E J S O R B . j a v a : 8 5 ) < b r / > a t j a v a . b a s e / j d k . i n t e r n a l . r e f l e c t . D i r e c t M e t h o d H a n d l e A c c e s s o r . i n v o k e ( D i r e c t M e t h o d H a n dleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at com.ibm.ws.naming.util.Helpers.getOrb(Helpers.java:508)
at com.ibm.ws.naming.util.WsnInitCtxFactory.getInitialContextInternal(WsnInitCtxFactory.java:478)
at com.ibm.ws.naming.util.WsnInitCtx.getContext(WsnInitCtx.java:128)
at com.ibm.ws.naming.util.WsnInitCtx.getContextIfNull(WsnInitCtx.java:765)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:164)
at com.ibm.ws.naming.util.WsnInitCtx.lookup(WsnInitCtx.java:179)
at java.naming/javax.naming.InitialContext.lookup(InitialContext.java:409)
at org.springframework.jndi.JndiTemplate.lambda$lookup$0(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:89)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:154)
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:176)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:106)
at org.springframework.jndi.JndiLocatorDelegate.lookup(JndiLocatorDelegate.java:65)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:79)
at org.springframework.jndi.JndiLocatorDelegate.lookup(JndiLocatorDelegate.java:60)
at org.springframework.jndi.JndiPropertySource.getProperty(JndiPropertySource.java:93)
at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.getPropertySourceProperty(SpringConfigurationPropertySource.java:110)
at org.springframework.boot.context.properties.source.SpringConfigurationPropertySource.getConfigurationProperty(SpringConfigurationPropertySource.java:92)
at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource.findConfigurationProperty(ConfigurationPropertySourcesPropertySource.java:72)
at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertyResolver.findPropertyValue(ConfigurationPropertySourcesPropertyResolver.java:101)
at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertyResolver.getProperty(ConfigurationPropertySourcesPropertyResolver.java:78)
at org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertyResolver.getProperty(ConfigurationPropertySourcesPropertyResolver.java:64)
at org.springframework.core.env.AbstractEnvironment.getProperty(AbstractEnvironment.java:552)
at org.springframework.boot.cloud.CloudPlatform.isActive(CloudPlatform.java:191)
at org.springframework.boot.cloud.CloudFoundryVcapEnvironmentPostProcessor.postProcessEnvironment(CloudFoundryVcapEnvironmentPostProcessor.java:120)
at org.springframework.boot.support.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:137)
at org.springframework.boot.support.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:120)
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:180)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:173)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:151)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:133)
at org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:137)
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$0(SpringApplicationRunListeners.java:66)
at java.base/java.util.ImmutableCollections$List12.forEach(ImmutableCollections.java:681)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:123)
at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:65)
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:356)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:316)
... 8 more