2016-04-22 5 views
4

Ich erstelle ein einfaches Projekt, das eine jms-Warteschlange aufruft und eine Nachricht eingibt.Weblogic 12.1.3 PrivilegedActions Klasse nicht gefunden

Hier den Code:

public class QueueSend 
{ 
// Defines the JNDI context factory. 
public final static String JNDI_FACTORY="weblogic.jndi.WLInitialContextFactory"; 

// Defines the JMS context factory. 
public final static String JMS_FACTORY="jms/MyConnectionFactory"; 

// Defines the queue. 
public final static String QUEUE="jms/MyTestQueue"; 

private QueueConnectionFactory qconFactory; 
private QueueConnection qcon; 
private QueueSession qsession; 
private QueueSender qsender; 
private Queue queue; 
private TextMessage msg; 

/** 
    * Creates all the necessary objects for sending 
    * messages to a JMS queue. 
    * 
    * @param ctx JNDI initial context 
    * @param queueName name of queue 
    * @exception NamingException if operation cannot be performed 
    * @exception JMSException if JMS fails to initialize due to internal error 
    */ 
public void init(Context ctx, String queueName) 
    throws NamingException, JMSException 
{ 
    qconFactory = (QueueConnectionFactory) ctx.lookup(JMS_FACTORY); 
    qcon = qconFactory.createQueueConnection(); 
    qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); 
    queue = (Queue) ctx.lookup(queueName); 
    qsender = qsession.createSender(queue); 
    msg = qsession.createTextMessage(); 
    qcon.start(); 
} 

/** 
    * Sends a message to a JMS queue. 
    * 
    * @param message message to be sent 
    * @exception JMSException if JMS fails to send message due to internal error 
    */ 
public void send(String message) throws JMSException { 
    msg.setText(message); 
    qsender.send(msg); 
} 

/** 
    * Closes JMS objects. 
    * @exception JMSException if JMS fails to close objects due to internal error 
    */ 
public void close() throws JMSException { 
    qsender.close(); 
    qsession.close(); 
    qcon.close(); 
} 
/** main() method. 
* 
* @param args WebLogic Server URL 
* @exception Exception if operation fails 
*/ 
public static void main(String[] args) throws Exception { 

    Context ic = getInitialContext("t3://localhost:7001"); 
    QueueSend qs = new QueueSend(); 
    qs.init(ic, QUEUE); 
    readAndSend(qs); 
    qs.close(); 
} 

private static void readAndSend(QueueSend qs) 
    throws IOException, JMSException 
{ 

     qs.send("ciao"); 
     System.out.println("JMS Message Sent: ciao \n"); 


} 

private static InitialContext getInitialContext(String url) 
    throws NamingException 
{ 
    Hashtable<String, String> env = new Hashtable<String, String>(); 
    env.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_FACTORY); 
    env.put(Context.PROVIDER_URL, url); 
    return new InitialContext(env); 
} 
} 

Wenn ich die Haupt starten, ich habe diesen Fehler:

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/security/service/PrivilegedActions 
    at weblogic.jndi.WLSJNDIEnvironmentImpl.<clinit>(WLSJNDIEnvironmentImpl.java:57) 
    at java.lang.Class.forName0(Native Method) 
    at java.lang.Class.forName(Class.java:264) 
    at weblogic.jndi.internal.JNDIEnvironment.getJNDIEnvironment(JNDIEnvironment.java:37) 
    at weblogic.jndi.Environment.<clinit>(Environment.java:92) 
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117) 
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684) 
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313) 
    at javax.naming.InitialContext.init(InitialContext.java:244) 
    at javax.naming.InitialContext.<init>(InitialContext.java:216) 
    at test.QueueSend.getInitialContext(QueueSend.java:109) 
    at test.QueueSend.main(QueueSend.java:86) 

ich gegründet habe, mit Google, dass die PrivilegedActions in der WebLogic ist. security.service (weblogic-api.jar; ich habe dieses jar in mein Projekt aufgenommen, aber intern hat es nicht diese Klasse) aber ist nur ein Problem der 12.1.3 Version?

Danke für die Antwort

+0

dasselbe Problem mit Weblogic 12.2.1 – Alex

+0

Ich habe ein gleiches Problem mit Weblogic 12.1.3. Welche JAR-Dateien haben Sie genau zu Ihrem Projekt hinzugefügt? Ich konnte weblogic-api.jar nicht finden. Es gibt nur ein wls-api.jar. Ich habe wls-api.jar und weblogic.jar zu meinem Klassenpfad hinzugefügt, aber das Problem existiert noch. – AliReza19330

+0

Ich benutze Weblogic 12.1.3 Ich habe endlich die gewünschte JAR-Datei gefunden. Es befindet sich hier: 'wlserver \ modules \ com.oracle.css.weblogic.security.wls_7.1.0.0.jar' – AliReza19330

Antwort

1

Ich habe eine Lösung gefunden.

Ich habe auf 12.2.1 aktualisiert und eine wlfullclient.jar generiert. Ich habe es zu Build Library Path hinzugefügt und die WebLogic-Bibliotheken entfernt.