简体   繁体   中英

java.lang.ClassNotFoundException: com.ibm.ejs.ras.hpel.HpelHelper

Good day,

I have a simple http post java main function as follow:

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.impl.client.DefaultHttpClient;


public class Test {

    public static void main(String[] args) {
        try {
            System.out.println("java version: " + System.getProperty("java.version"));
            HttpClient httpclient = new DefaultHttpClient( );
            HttpPost post = new HttpPost("http://www.google.com");
            HttpResponse response = httpclient.execute( post );
            System.out.println("response is " + response);
            } 
        catch ( HttpHostConnectException ce ) {
                System.out.println("Service is not available. Please try again later." );
            } 
        catch ( Exception e ) {
                System.out.println("e is " + e);
            }
    }
}

I have some java project in IBM RAD, when I run this code in 1 of the project, I will get http 200 response. However, in another project, I run the same code, I will get error as follow: Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception:

java.lang.NoClassDefFoundError: com.ibm.ejs.ras.hpel.HpelHelper
    at com.ibm.ejs.ras.RasHelper.getThreadId(RasHelper.java:1735)
    at com.ibm.ejs.ras.RasEvent6$1.initialValue(RasEvent6.java:101)
    at java.lang.ThreadLocal.setInitialValue(ThreadLocal.java:152)
    at java.lang.ThreadLocal.get(ThreadLocal.java:142)
    at com.ibm.ejs.ras.RasEvent6.<init>(RasEvent6.java:292)
    at com.ibm.ejs.ras.MessageEvent6.<init>(MessageEvent6.java:203)
    at com.ibm.ejs.ras.Tr.fireMessageEvent(Tr.java:1558)
    at com.ibm.ejs.ras.Tr.error(Tr.java:728)
    at com.ibm.ws.naming.java.javaURLContextFactory.isNameSpaceAccessable(javaURLContextFactory.java:108)
    at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:85)
    at javax.naming.spi.NamingManager.getURLContext(NamingManager.java:702)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:422)
    at javax.naming.InitialContext.lookup(InitialContext.java:436)
    at ch.qos.logback.classic.util.JNDIUtil.lookup(JNDIUtil.java:38)
    at ch.qos.logback.classic.joran.action.InsertFromJNDIAction.begin(InsertFromJNDIAction.java:62)
    at ch.qos.logback.core.joran.spi.Interpreter.callBeginAction(Interpreter.java:277)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:149)
    at ch.qos.logback.core.joran.spi.Interpreter.startElement(Interpreter.java:131)
    at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:50)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:148)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:134)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:97)
    at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:56)
    at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:77)
    at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:150)
    at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
    at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
    at java.lang.J9VMInternals.initializeImpl(Native Method)
    at java.lang.J9VMInternals.initialize(J9VMInternals.java:228)
    at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)
    at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279)
    at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:156)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.apache.http.impl.client.AbstractHttpClient.<init>(AbstractHttpClient.java:159)
    at org.apache.http.impl.client.DefaultHttpClient.<init>(DefaultHttpClient.java:178)
    at com.ibs.ui.customer.action.Test.main(Test.java:15)
Caused by: java.lang.ClassNotFoundException: com.ibm.ejs.ras.hpel.HpelHelper
    at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:665)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:644)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:627)
    ... 39 more

Both of the project include the same com.ibm.ws.runtime.jar .

Both project is java 1.6.

Please advise. Appreciate your help.

Please, add

<dependency>
  <groupId>com.ibm.jaxws</groupId>
  <artifactId>thinclient</artifactId>
  <version>8.0.0<version>
  <scope>provided</scope>
</dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM