ClassNotFound

I am drastically trying to figure out how to use Class.forName. Even when I put
Class.forName( "java.lang.Thread" );
in the Main constructor Java returns a ClassNotFound exception. That is a class right out of the java help file for Class.forName.
Please someone can you give me a working example of using Class.forName?! Thank you!!

I see what you are saying. That may be the solution. I should just throws the exception and compile anyway. While I am still learning java, I would appreciate greatly if someone could explain why java forces me to do this.
Seems like a misreporting of an error. The only way I have seen this code work is by throwing the expection anyway. I really don't know why it would be blinded from finding the class and report the error.

Similar Messages

  • Difference in ClassNotFound and NoClassDefFound

    Hi. At work we have run into ClassNotFound and NoClassDefFound exceptions numerous times while setting up new environments (who hasn't?). However, nobody here seems to understand the different between the exceptions. The javadoc isn't much help.
    Here is part of the javadoc for the two:
    NoClassDefFoundException:
    "Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found."
    ClassNotFoundException:
    "Thrown when an application tries to load in a class through its string name using:
    * The forName method in class Class.
    * The findSystemClass method in class ClassLoader .
    * The loadClass method in class ClassLoader.
    but no definition for the class with the specified name could be found."
    Could someone please educate us in the difference? When we get one type of exception, what should we look for as opposed to the other type? Thanks for your help :)
    Michael.

    I think it's like it saye. NoClassDefFound is when the JVM tries to follow up a reference to another class contained in the java code itself, and the required class isn't there. It almost always means that you've missed a library from the runtime class path which was there when you compiled, or your compilation is out of date and a class has been removed.
    ClassNotFoundException happens when you generate a class name at run time and try to load it explicitly, and it turns out not to be there.

  • Classnotfound when loading report

    Post Author: Codeamazon
    CA Forum: Deployment
    &#91;I've searched and don't see an answer to this...be happy to be proven wrong.  Also not sure if this should go here, or to the Java forum.&#93;I'm trying to get the Java Reporting Component working.  My environment is OpenVMS, and we've installed Tomcat specifically for this project.  I do have JSPs working with beans with database connections, so the underlying Java side seems to be functional, however I get a classnotfound error when I try to load a report.Here is basic.jsp, the sample JSP that I got from online documentation : http://www.businessobjects.com/pdf/dev_zone/crxi_java_startup_guide.pdf , along with the error it generates.  I have debugged the report path by commenting out the CRConfig.xml report-path option and using an absolute approach.  REPORT1.RPT is in the web-inf/classes directory of my app.  Here is my code:  &#91;HTML STUFF HERE&#93;<%@page import="com.crystaldecisions.reports.sdk." %><%@page import="com.crystaldecisions.sdk.occa.report.reportsource." %><%@page import="com.crystaldecisions.sdk.report.lib.*" %><%    String reportName="REPORT1.RPT";    try    {      //check to see if report source already exists      Object reportSource = session.getAttribute("reportSource");      //if not yet opened      if (reportSource == null)      {        ReportClientDocument oReportClientDocument = new ReportClientDocument();        oReportClientDocument.open(reportName, 0);======more stuff, but the code fails on this line==========Error:root cause java.lang.NoClassDefFoundError     java.lang.Class.forName0(Native Method)     java.lang.Class.forName(Class.java:141)     com.crystaldecisions.proxy.remoteagent.z.a(Unknown Source)     com.crystaldecisions.sdk.occa.report.application.ReportAppSession.int(Unknown Source)     com.crystaldecisions.sdk.occa.report.application.ReportAppSession.initialize(Unknown Source)     com.crystaldecisions.sdk.occa.report.application.ClientDocument.for(Unknown Source)     com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.for(Unknown Source)     com.crystaldecisions.sdk.occa.report.application.ClientDocument.open(Unknown Source)     com.crystaldecisions.reports.sdk.ReportClientDocument.open(Unknown Source)     org.apache.jsp.basic_jsp._jspService(org.apache.jsp.basic_jsp:79)     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)     javax.servlet.http.HttpServlet.service(HttpServlet.java:802) Looks to me like somewhere in the report loader, it isn't finding a class it needs, which suggests a missing .jar, but I can't find one missing based on the documentation.  I've installed these .jars in the apps' web-inf/lib directory:
    CONCURRENT.JAR;2  
    CrystalCharting.jar;1                  
    CRYSTALCOMMON.JAR;1
    CRYSTALCONTENTMODELS.JAR;1             
    CrystalExporters.jar;1
    CrystalExportingBase.jar;1             
    CRYSTALFORMULAS.JAR;1
    CRYSTALQUERYENGINE.JAR;1               
    CRYSTALREPORTENGINE.JAR;1
    CRYSTALREPORTINGCOMMON.JAR;1           
    ICU4J.JAR;2        
    ICU4J.JAR;1
    JRCEROM.JAR;1      
    KEYCODEDECODER.JAR;1                   
    LOG4J.JAR;2
    LOG4J.JAR;1        
    METAFILERENDERER.JAR;1                 
    RASAPP.JAR;1
    RASCORE.JAR;1      
    RPOIFS.JAR;1       
    SERIALIZATION.JAR;1
    URIUtil.jar;1
    webreporting-jsf.jar;1                 
    webreporting.jar;1
    XERCESIMPL.JAR;1
    XML-APIS.JAR;2     
    XML-APIS.JAR;1
    I based this list on Crystal Reports 11/Developer
    Files/Help/chs/JavaReportingComponent_docs/reference/default.htm ,
    "required components" list.  Can anyone help me solve this or suggest how I can debug it or get more information about what it's not finding?Thanks,Shasta 

    Thanks for helping me! I'm starting the rmiregistry in
    a clean environment (according to the Sun tutorial)
    by:
    set CLASSPATH=; //Just to make sure all paths are
    viped out
    rmiregistry -J-Dsun.rmi.loader.logLevel=VERBOSE
    If I echo the current CLASSPATH, I can see it's empty.
    However, I'm starting the registry in the root
    directory of the RMI-server application. Bad idea? As
    I understand it, the registry shall be started in an
    environment without any references to stub-files or
    anything else involving the RMI-server. Still
    confused...Looking at your explanation you could run it in two ways
    1) Run it in an environrmrnt where classpath is not null and where the java.rmi.codebase property is set appropriately.
    2) Run it in an environment where the applications classes are not on the classpath.
    The requirements for 2) are
    a) CLASSPATH is not null and doesnot include any entry of the your application classes.
    b) CLASSPATH is null and working directory (".") is not the root your applications packages structure. The reason being that the null CLASSPATH is interpreted as "."
    Or else in case you dont wanna set the codebase property u can acquire a required class via RMIClassLoader.loadClass method.

  • ClassNotFound exception, when load own Customizer

    I have own BooleanCustomizer that implements DescriptorCustomizer, it's packed in the same jar as entity classes. It's registered in persistence.xml:
    <property
         name="toplink.descriptor.customizer.MyEntityClass"
         value="jpa.util.BooleanCustomizer"/>
    Customizer works fine out of container - JUnit tests from Eclipse and Swing app. But in JSF app running on Tomcat, I get exception:
    oracle.toplink.essentials.exceptions.EntityManagerSetupException Exception Description: ClassNotFound: [jpa.util.BooleanCustomizer]
    It looks similar as:
    class not found exception - where to put custom session customizer?
    Any solution ?

    Which version are you using? A change was made recently to TopLink essentials to correct a classloader issue on session customizers.
    Cheers,
    Guy

  • Classnotfound exception in Studio

    I have this entity bean that I have deployed in weblogic. I am now trying to use
    the studio to create a business operation from one of the Bean methods. When I
    click on Configuration->Business Operations, I get a Classnotfound exception for
    the beans remote class.
    To get around this, I placed the bean jar file in the classpath in startweblogic.cmd
    for the domain. After this the problem went away and I was able to create the operation.
    Question is, is this the right way to have WLI find the class? Since I have deployed
    this in weblogic, shouldn't it be able to find the class files? What is the recommended
    way or am I doing something wrong.
    Thanks,
    --Krish.

    Use
    Class.forName("com.mysql.jdbc.Driver");Is the MySQL JDBC JAR file listed in project path.?

  • RMI & Web Start Client (ClassNotFound)

    Hi,
    I've been using RMI with a client application and it works find but now I have tried to run the same application via web start I'm getting RMI issues. I've fixed all sorts of other issues but Im stuck on the RMI one. I get a ClassNotFound exception when Register.lookup() is called.
    The code in the client is :
    Registry registry = LocateRegistry.getRegistry("localhost", 1234);
    // lookup the factory
    universe = (IMyFactory) registry.lookup("rmi:///MyFactory");
    The exception is thrown on the lookup. It can't find IMyFactory_stub. If I put the following line in after the Register creation :
    register.list()
    and dump the contents it has one entry
    rmi:///MyFactory
    I take it this implies that the web start client has talked to the server to get hold of the classes that have been bound. This appears to match exactly what I am looking up. So its not getting the interface file ! Im know RMI expert to why would this be the case with Web Start but not standalone ?
    The MyFactory class is contained in a jar file declared in the jnlp file and available to the client. The IMyFactory and MyFactory_stub classes are in a jar file available to the server. MyFactory implements IMyFactory which is a Remote.
    Oh also the jnlp file has all permisions set.
    As I say it works fine as a stand alone client.
    Any idea's what this could be ? Some setting unique to web start, different format for the url required (I tried using Naming.lookup() but this failed also).
    The app seems to hang for a few seconds before the exceptions is thrown. If I give it a url to the wrong box it blows up str8 away.
    The exception is :
    java.rmi.UnmarshalException: error unmarshalling return; nested
    exception is:
    java.lang.ClassNotFoundException: com.me.MyFactory_Stub
    at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
    at com.me.getMyServer(getMyServer.java:116)
    at com.me.main(agentsupport.java:6825)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.sun.javaws.Launcher.executeApplication(Unknown Source)
    at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
    at com.sun.javaws.Launcher.continueLaunch(Unknown Source)
    at com.sun.javaws.Launcher.handleApplicationDesc(Unknown Source)
    at com.sun.javaws.Launcher.handleLaunchFile(Unknown Source)
    at com.sun.javaws.Launcher.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.lang.ClassNotFoundException: com.me.MyFactory_Stub
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
    at sun.rmi.server.LoaderHandler.loadClass(Unknown Source)
    at java.rmi.server.RMIClassLoader$2.loadClass(Unknown Source)
    at java.rmi.server.RMIClassLoader.loadClass(Unknown Source)
    at sun.rmi.server.MarshalInputStream.resolveClass(Unknown Source)
    at java.io.ObjectInputStream.readNonProxyDesc(Unknown Source)
    at java.io.ObjectInputStream.readClassDesc(Unknown Source)
    at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    ... 21 more
    Thanks for any help, I'm out of idea's and totally stuck.
    Steve

    Hi Kal,
    since we're currently evaluating the software and haven't acquired a license, we cannot contact support.
    I only need to know if this is a solved bug or not. Does it have to do with the classloading process (I cannot think of anything else)?
    Thank you again very very much!
    Cheers,
    Paul.

  • ClassNotFound while narrowing JNDI ref to ejb home interface

    Hello everybody
    I'm quite new to BEA WebLogic. I deployed Jasmine application on Bea WLS7 (example
    app from Mastering EJB 2). But when i tried to use login servlet, it threw an
    exception ClassNotFound when narrowing ejb home interface (obtained via JNDI).
    EJBs are in .jar file, and web files are in the .war file, maybe this is the problem.
    Should I copy ejb classes to .war file, or make some tricks with CLASSPATH, or
    maybe there is better way to make it work (maybe via J2EE references or something
    like this).
    Thanks in advance

    Strange. And you do not have any application classes in the system
    classpath?
    Konrad R. <[email protected]> wrote:
    "Dimitri I. Rakitine" <[email protected]> wrote:
    Did you deploy ejbs and war in the same ear?
    Yes, both were packed up into one .ear archive>>
    Konrad R. <[email protected]> wrote:
    Hello everybody
    I'm quite new to BEA WebLogic. I deployed Jasmine application on BeaWLS7 (example
    app from Mastering EJB 2). But when i tried to use login servlet, itthrew an
    exception ClassNotFound when narrowing ejb home interface (obtainedvia JNDI).
    EJBs are in .jar file, and web files are in the .war file, maybe thisis the problem.
    Should I copy ejb classes to .war file, or make some tricks with CLASSPATH,or
    maybe there is better way to make it work (maybe via J2EE referencesor something
    like this).
    Thanks in advance--
    Dimitri

  • Java.lang.ClassNotFound Exception whenever I include .send()

    Everything runs fine, but when I add the .send(message); [it is in bold] I get a java.lang.ClassNotFound Exception.
    It still compiles, it just won't allow me to launch the program in the emulator. If I take that one piece of code out, everything runs fine again. I've been messing with it, and searching for a long time in an attempt to solve the problem but I've yet to come across a solution.
    I'm also using Bluej
    import java.io.*;
    import java.lang.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;//Add SMS text, Map selection (upload image/altitude-scale)
    import javax.microedition.lcdui.Font;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.game.GameCanvas;
    import javax.wireless.messaging.*;
       public class cardcanvas extends GameCanvas implements Runnable, CommandListener {
        Image i, Mortar, Target, paintballcharleston, selectimg, Cursor;
        SendSMS sendtext;
        Thread t = new Thread(this);
        Command cmdfire=new Command("Fire", Command.BACK, 1 );
        Command cmdreset=new Command("Reset", Command.ITEM, 2 );
        String text, message;
        static Image Map;
        MessageConnection messageConnection;
        TextMessage textMessage;
        int mortarX=5500, mortarY=5500, targetX=5500, targetY=5500, distanceX, distanceY, delay, mapx=-250, mapy=-250, xvel=115, yvel=130, gameAction=0, timer=0;
        double A, B, C, b, degreeX, degreeY, degreeV, voltageX, voltageY, scale=1.4235, findDegree=90;//get scale of pixel:realtime feet
        boolean paintdown=false, paintup=false, paintright=false, paintleft=false, left, finish, firemor, initiate, click, bottom=true, noYdegree, reset, sms=false;
        public cardcanvas(){
            super(false);
            this.addCommand(cmdfire);
            this.addCommand(cmdreset);
            this.setCommandListener(this);
        public void intit() {}
        public void start() {
            t.start() {}
        public void run()
            try{
                while(true)
                    if(paintright) {
                        timer++;
                        if(timer>1&&timer<4) xvel=xvel+5;
                        if(timer>=4&&timer<6) xvel=xvel+10;
                        if(timer>=6) xvel=xvel+20;
                    if(paintleft) {
                        timer++;
                        if(timer>1&&timer<4) xvel=xvel-5;
                        if(timer>=4&&timer<6) xvel=xvel-10;
                        if(timer>=6) xvel=xvel-20;
                    if(paintup) {
                        timer++;
                        if(timer>1&&timer<4) yvel=yvel-5;
                        if(timer>=4&&timer<6) yvel=yvel-10;
                        if(timer>=6) yvel=yvel-20;
                    if(paintdown) {
                        timer++;
                        if(timer>1&&timer<4) yvel=yvel+5;
                        if(timer>=4&&timer<6) yvel=yvel+10;
                        if(timer>=6) yvel=yvel+20;
                    if(mapy<-320) mapy=-320;
                    if(mapx>0) mapx=0;
                    if(mapy>0) mapy=0;
                    if(mapx>197) mapx=197;
                    if(xvel>225)
                        mapx=mapx-5;
                        targetX=targetX-5;
                        mortarX=mortarX-5;
                        xvel=225;
                    if(xvel<5)
                        mapx=mapx+5;
                        targetX=targetX+5;
                        mortarX=mortarX+5;
                        xvel=5;
                    if(yvel>260)
                        mapy=mapy-5;
                        targetY=targetY-5;
                        mortarY=mortarY-5;
                        yvel=260;
                    if(yvel<5)
                        mapy=mapy+5;
                        targetY=targetY+5;
                        mortarY=mortarY+5;
                        yvel=5;
                        if(reset) {
                            mapx=-250;
                            mapy=-250;
                            xvel=115;
                            yvel=130;
                            left=false;
                            firemor=false;
                            finish=false;
                            initiate=false;
                            click=false;
                            bottom=true;
                            noYdegree=false;
                            reset=false;
                            targetX=5500;
                            targetY=5500;
                            mortarX=5500;
                            mortarY=5500;
                            A=0;
                            B=0;
                            C=0;
                            b=0;
                            degreeX=0;
                        if(initiate) {
                           distanceX=targetX-mortarX;
                           distanceY=targetY-mortarY;
                           A=distanceY;
                           B=distanceX;
                               if(distanceY<0)
                                    A=distanceY*-1;
                                    bottom=false;
                               if(distanceX<0)
                                    B=distanceX*-1;
                                    left=true;
                            A=A*scale;
                            B=B*scale;
                            C=Math.sqrt((A*A)+(B*B));
                                while(((A*(Math.tan(b)))<B+.00002))
                                    b=b+.0001;
                            b=b*180/3.1415926535897932384626435;
                            degreeX=b;
                                if(bottom)
                                    b=90-b;
                                    b=b+90;
                                    degreeX=b;
                                if(left)
                                    degreeX=360-b;
                            initiate=false;
                            text=("DegreeX is "+degreeX+" Range is "+C);
                             sendTextMessage();
                     verifyGameState();
                     paint(getGraphics());
                     Thread.currentThread().sleep(1);
                catch (Exception E) {}
        private void verifyGameState() {}
        public void sendTextMessage()
            try
                String message = " ";
                MessageConnection messageConnection = (MessageConnection)Connector.open("sms://18433036060");
                TextMessage textMessage = (TextMessage)messageConnection.newMessage(
                        MessageConnection.TEXT_MESSAGE, "18433036060");
                textMessage.setPayloadText(message);
                *messageConnection.send(textMessage);*
            catch (Exception e) {}
    }If I remove messageConnection.send(texstMessage); the error is gone.
    Thanks in advance for your time

    cardmidlet:
    import javax.microedition.lcdui.*;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    import java.io.IOException;
    import java.lang.*;
    public class cardmidlet extends MIDlet implements CommandListener {
        private Display display; Display map;
        cardmidlet midlet;
        private Form form; Form mapselection;
        private List menuList ;
        String[] elements=new String[]{"Initiate Program","Select Map","Help","About"};
        private Command selectCommand;
        Alert alert;
            private Command fnext=new Command("NEXT",Command.ITEM,1);
            private Command fback=new Command("BACK",Command.BACK,1);
            private Command mapnext=new Command("Next",Command.ITEM,1);
        private TextField uname; TextField mapchoice;
        public String nname, nmap;
        cardcanvas cd;
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
        protected void pauseApp() {
        public cardmidlet() {
             menuList();
             cd = new cardcanvas();
        public void menuList(){
             display = Display.getDisplay(this);
             menuList = new List("Menu", List.IMPLICIT, elements, null);
             selectCommand=new Command("open",Command.ITEM,1);
             menuList.setSelectCommand(selectCommand);
             menuList.setCommandListener(this);  
        protected void startApp() throws MIDletStateChangeException {
            display.setCurrent(menuList);
        public void about(){
            alert = new Alert("Option Selected", "This program is created by"+"\n"+" Chris Furlong.", null, null);
              alert.setTimeout(Alert.FOREVER);
              alert.setType(AlertType.INFO);
              display.setCurrent(alert);
        public void help() {
            alert = new Alert("Option Selected", "Use the 4 d-pad keys to move the cursor. Press the center button once to select the mortar position, and a second time to select the target position. When both the mortar and the target are on screen, press the upper left key to begin the firing process. If you place one on the map by mistake, simply reset the program with the upper right key and start over.", null, null);
            alert.setTimeout(Alert.FOREVER);
            alert.setType(AlertType.INFO);
            display.setCurrent(alert);
        public void InitiateProgram(){
            display=Display.getDisplay(this);
            uname=new TextField("Enter your name","",50,TextField.ANY);
            form =new Form("New User");
            form.append(uname);
            form.addCommand(fnext);
            form.addCommand(fback);
            form.setCommandListener(this);
            display.setCurrent(form);
        public void selectmap()
           /* display=map.getDisplay(this);
            mapchoice=new TextField("Enter Map Name","",50,TextField.ANY);
            mapselection=new Form("Map Selection");
            mapselection.append(mapchoice);
            mapselection.addCommand(mapnext);
            mapselection.addCommand(fback);
            mapselection.setCommandListener(this);
            display.setCurrent(mapselection);*/
            display = map.getDisplay(this);
            map choose=new map();
        public String name(){
            nname=uname.getString();
            return nname;
    /*   public String mapname() {
            nmap=mapchoice.getString();
            return nmap;
        public void commandAction(Command com, Displayable arg1) {
             if(com==selectCommand)
                if(menuList.getSelectedIndex()==3)
                    about();
                if(menuList.getSelectedIndex()==2)
                    help();
                if(menuList.getSelectedIndex()==1)
                    selectmap();
                if(menuList.getSelectedIndex()==0)
                    InitiateProgram();
            if(com==fback)
                display.setCurrent(menuList);
            if(com==fnext){
                display = Display.getDisplay(this);
                cd.start();
                display.setCurrent(cd);
            if(com==mapnext)
                display = map.getDisplay(this);
                map choose=new map();
                display.setCurrent(choose);
    }

  • ClassNotFound (class is there in EAR file)

    I have an EAR file. It gives me ClassNotFound error even though I have checked
    that the class is there in the EAR at right place. This happens with one particular
    server. Same EAR file when deployed on another instance gives no problem.
    Can it happen if a class is fould at two different locations in classpath at runtime?
    Thanks in advance

    SquareBox wrote:
    user8483670 wrote:
    To handle String data like you said the one "Hello world" we can use string Buffer or StringBuilder for that purpose? why only String?I'm NOT 100% sure about this but I'm pretty sure. Anytime you create a String, the Java compiler uses StringBuilder.No, that's definitely not the case.
    Perhaps what you're thinking of is that when you concatenate non-compile-time-constant Strings, the compiler generates StringBuilder.append() calls.
    That is why when you want to use an array to create Strings for each element, it is better to explicitly call the StringBuilder because otherwise Java will create a new StringBuilder for every single element. In this case if you create a StringBuilder explicitly, then Java would only have to do it once rather than for each element of the array. This would slow down the program for large arrays.Sort of. Arrays don't specifically have anything to do with it. They're just one specific case. The real issue is when doing a lot of concatenations in a loop, you want to explicitly user StringBuilder, to avoid creating (and having to GC) large numbers of temporary String and StringBuilder objects.
    String s1 = "abc" + x "def" + y + "zzz";The above is fine, because the compiler can insert the creation of a single StringBuilder.
    String s1 = "";
    loop {
      s1 += something;
    }The above is not good, because for every pass through the loop, there will be a StringBuilder and a String created, and eligible for GC.
    StringBuilder sb = new StringBuilder();
    loop {
      sb.append(something);
    }The above is the preferred way to do it. Although in practice, in the majority of cases you probably won't even notice the difference.
    Edited by: jverd on Mar 8, 2011 9:44 AM

  • Custom Login Module - ClassNotFound

    Hello all
    I developed a custom login module following the instructions I found here: http://help.sap.com/saphelp_nw04/helpdata/en/46/3ce9402f3f8031e10000000a1550b0/frameset.htm
    The general purpose of my module is to "filter" the username and look for (using the UMFactory) the corresponding uniqueUserID.
    The problem is that my LoginModule cannot be loaded due to "ClassNotFound" Error which I see in the defaultTrace.
    My steps were:
    1. Create my LoginModuleImplementation
    2. Create a Library as stated in the tutorial. Additionally I added some more references to the Library (Logging, webservices_lib) and successfully deplyed it to the J2EE-Server. I can see the file in one folder (...../j2ee/cluster/server0/bin/ext/MyModuleLib/MyModule.jar) so I think it's been correctly deployed.
    3. I configured its usage in the securtiy provider-UserManagementPolicies and with security provider-policy-ticket.
    4. I also ran the configtool to added it to the ClassLoader property there
    I double- no, fourth-checked everything and it's spelled correctly and exactly (case-sensitive) as in NWDS.
    So, do you have any idea please?
    By the way: Do you know where I can set the Severity-Level for the LoginModul-Stack, so I get more informational messages?
    Regards
    Michael

    Hi,
    The problem was solved by using the name customer.com~com.customer.portal.login.IPRuleLibrary for the library (so basically look at the name of your library folder under cluster\j2ee\serverx\bin\ext , not the name reported by visual admin).
    Also I was able to modify the properties of the login module runtime, which made me very happy
    Dagfinn

  • ClassNotFound error when loading applet from a NTLM authenticated  site

    Hi,
    I wrote a Java applet and put it into a JAR file and signed the JAR file. It works fine if the user doesn't need to be authenticated. However, when I place the same JAR to a site that uses NTLM (NT challenging) authentication. The applet failed to load and returns ClassNotFound exception. Does anyone know why?
    The following is the complete error message:
    java.io.IOException: Server returned HTTP response code: 401 for URL: http://unibox.MySite.com/fileupload/FileUpload.jar
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:697)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:369)
         at sun.net.www.protocol.http.HttpURLConnection.getHeaderFields(HttpURLConnection.java:1139)
         at sun.plugin.net.protocol.http.HttpURLConnection.checkCookieHeader(HttpURLConnection.java:330)
         at sun.plugin.net.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:367)
         at sun.plugin.net.protocol.http.HttpUtils.followRedirects(HttpUtils.java:39)
         at sun.plugin.cache.CachedJarLoader.download(CachedJarLoader.java:311)
         at sun.plugin.cache.CachedJarLoader.load(CachedJarLoader.java:131)
         at sun.plugin.cache.JarCache.get(JarCache.java:177)
         at sun.plugin.net.protocol.jar.CachedJarURLConnection.connect(CachedJarURLConnection.java:71)
         at sun.plugin.net.protocol.jar.CachedJarURLConnection.getJarFile(CachedJarURLConnection.java:56)
         at sun.misc.URLClassPath$JarLoader.getJarFile(URLClassPath.java:498)
         at sun.misc.URLClassPath$JarLoader.<init>(URLClassPath.java:459)
         at sun.misc.URLClassPath$2.run(URLClassPath.java:255)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:244)
         at sun.misc.URLClassPath.getLoader(URLClassPath.java:221)
         at sun.misc.URLClassPath.getResource(URLClassPath.java:134)
         at java.net.URLClassLoader$1.run(URLClassLoader.java:190)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
         at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:132)
         at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:189)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:112)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
         at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:473)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1621)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
         at sun.applet.AppletPanel.run(AppletPanel.java:290)
         at java.lang.Thread.run(Thread.java:536)
    load: class FileUpload.class not found.
    java.lang.ClassNotFoundException: FileUpload.class
         at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:151)
         at sun.plugin.security.PluginClassLoader.findClass(PluginClassLoader.java:189)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at sun.applet.AppletClassLoader.loadClass(AppletClassLoader.java:112)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
         at sun.applet.AppletClassLoader.loadCode(AppletClassLoader.java:478)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:548)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1621)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:477)
         at sun.applet.AppletPanel.run(AppletPanel.java:290)
         at java.lang.Thread.run(Thread.java:536)
    Caused by: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(AppletClassLoader.java:224)
         at sun.applet.AppletClassLoader.access$100(AppletClassLoader.java:40)
         at sun.applet.AppletClassLoader$1.run(AppletClassLoader.java:141)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.applet.AppletClassLoader.findClass(AppletClassLoader.java:138)
         ... 10 more

    It appears that the latest jvm plugins use java to get the archive files instead of using the browser to download the archive files.
    In addition sun does not support NTLM authentication, because of this the latest jvms are unable to download the jar file containing the applet.
    I have been working on finding a way to replace suns http Handler, but have had no luck with setting the java.protocol.handler.pkgs for the plugin and having it retain the setting.
    I have achieved partial results using the appletviewer with -J-Djava.protocol.handler=com.nogoop
    you might try taking a look at http://www.nogoop.com

  • Classnotfound from brouser.

    Hello!
    i'm using a JApplet and JTable in it.
    when i try to run html i have saw classNotFound
    in appletviewer all work...

    Hi,
    Check whether you have set the JApplet class name in code and codebase correctly in html file. Also check whether you have installed Java Plug-in to run your JApplet through browser.
    Anil.
    Developer Technical Support
    Sun Microsystems Inc
    http://www.sun.com/developers/support

  • ClassNotFound error in HttpServletRequest.

              I am using Weblogic 5.1.
              Our application is basically Servlets based .
              We are setting up a cluster with weblogic(as App Server) on NT and Apache (as
              Web Server) on Solaris.
              All the setup was done as per the documentation.
              But after the Cluster Setup, the application runs fine when there is only one
              primary weblogic server , but when any of the other weblogic servers are added
              into the cluster, the application fails with ClassNotFound error in HttpServletRequest.
              the following is the Error
              Sun May 06 15:51:11 GMT+05:30 2001:<E> <Kernel> ExecuteRequest failed.
              java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getDeclaredMethods(Class.java:996)
              at java.io.ObjectStreamClass.computeSerialVersionUID(ObjectStreamClass.j
              ava:739)
              at java.io.ObjectStreamClass.access$4(ObjectStreamClass.java:716)
              at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:343)
              at java.security.AccessController.doPrivileged(Native Method)
              at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:331)
              at java.io.ObjectStreamClass.lookupInternal(ObjectStreamClass.java:111)
              at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:481)
              at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
              :785)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java, Compiled
              Code)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:978)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java, Compiled
              Code)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              at java.util.Hashtable.readObject(Hashtable.java:773)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:1
              685)
              at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1165)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java, Compiled
              Code)
              at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              at weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectI
              nputStreamBase.java:76)
              at weblogic.servlet.internal.session.ReplicatedSession.readExternal(Repl
              icatedSession.java:63)
              at weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializab
              le(WLObjectInputStreamBase.java, Compiled Code)
              at weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjec
              tInputStreamBase.java, Compiled Code)
              at weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObj
              ectInputStreamBase.java, Compiled Code)
              at weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectI
              nputStreamBase.java, Compiled Code)
              at weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjec
              tInputStreamBase.java, Compiled Code)
              at weblogic.rmi.extensions.AbstractInputStream2.readObject(AbstractInput
              Stream2.java:25)
              at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(Replica
              tionManager_WLSkel.java:49)
              at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerOb
              jectAdapter.java, Compiled Code)
              at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicReques
              tHandler.java:69)
              at weblogic.rmi.extensions.BasicRequestDispatcher.dispatch(BasicRequestD
              ispatcher.java:80)
              at weblogic.rmi.internal.BasicRemoteInvokable.invoke(BasicRemoteInvokabl
              e.java:31)
              at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:657)
              at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerSer
              ver.java:123)
              at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:630)
              at weblogic.socket.JVMAbbrevSocket.dispatch(JVMAbbrevSocket.java:393)
              at weblogic.socket.JVMSocketT3.dispatch(JVMSocketT3.java, Compiled Code)
              at weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java, Comp
              iled Code)
              at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:
              23)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
              --------------- nested within: ------------------
              weblogic.rmi.ServerError: A RemoteException occurred in the server method
              - with nested exception:
              [java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest]
              at weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
              ava:76)
              at weblogic.cluster.replication.ReplicationManager_WLStub.create(Replica
              tionManager_WLStub.java:100)
              at weblogic.cluster.replication.ReplicationManager.createSecondary(Repli
              cationManager.java:457)
              at weblogic.cluster.replication.ReplicationManager.checkHosts(Replicatio
              nManager.java:523)
              at weblogic.cluster.replication.ReplicationManager.clusterMembersChanged
              (ReplicationManager.java:548)
              at weblogic.cluster.MemberStash$ClusterMembersChangeDeliverer.execute(Me
              mberStash.java:209)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              --------------- nested within: ------------------
              weblogic.rmi.extensions.RemoteRuntimeException: Undeclared checked exception -
              w
              ith nested exception:
              [weblogic.rmi.ServerError: A RemoteException occurred in the server method
               - with nested exception:
              [java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest]]
              at weblogic.cluster.replication.ReplicationManager_WLStub.create(Replica
              tionManager_WLStub.java:108)
              at weblogic.cluster.replication.ReplicationManager.createSecondary(Repli
              cationManager.java:457)
              at weblogic.cluster.replication.ReplicationManager.checkHosts(Replicatio
              nManager.java:523)
              at weblogic.cluster.replication.ReplicationManager.clusterMembersChanged
              (ReplicationManager.java:548)
              at weblogic.cluster.MemberStash$ClusterMembersChangeDeliverer.execute(Me
              mberStash.java:209)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

              The javax.* classes are in weblogicaux.jar.
              You do not have weblogicaux.jar in your classpath.
              Mike
              "Ajith Manohar" <[email protected]> wrote:
              >
              >I am using Weblogic 5.1.
              >Our application is basically Servlets based .
              >
              >We are setting up a cluster with weblogic(as App Server) on NT and Apache
              >(as
              >Web Server) on Solaris.
              >
              >All the setup was done as per the documentation.
              >
              >But after the Cluster Setup, the application runs fine when there is
              >only one
              >primary weblogic server , but when any of the other weblogic servers
              >are added
              >into the cluster, the application fails with ClassNotFound error in HttpServletRequest.
              >
              >the following is the Error
              >-----------------------------------------------------------------
              >Sun May 06 15:51:11 GMT+05:30 2001:<E> <Kernel> ExecuteRequest failed.
              >java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest
              > at java.lang.Class.getMethods0(Native Method)
              > at java.lang.Class.getDeclaredMethods(Class.java:996)
              > at java.io.ObjectStreamClass.computeSerialVersionUID(ObjectStreamClass.j
              >ava:739)
              > at java.io.ObjectStreamClass.access$4(ObjectStreamClass.java:716)
              > at java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:343)
              > at java.security.AccessController.doPrivileged(Native Method)
              > at java.io.ObjectStreamClass.<init>(ObjectStreamClass.java:331)
              > at java.io.ObjectStreamClass.lookupInternal(ObjectStreamClass.java:111)
              > at java.io.ObjectStreamClass.setClass(ObjectStreamClass.java:481)
              > at java.io.ObjectInputStream.inputClassDescriptor(ObjectInputStream.java
              >:785)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java,
              >Compiled
              > Code)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              > at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:978)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java,
              >Compiled
              > Code)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              > at java.util.Hashtable.readObject(Hashtable.java:773)
              > at java.lang.reflect.Method.invoke(Native Method)
              > at java.io.ObjectInputStream.invokeObjectReader(ObjectInputStream.java:1
              >685)
              > at java.io.ObjectInputStream.inputObject(ObjectInputStream.java:1165)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java,
              >Compiled
              > Code)
              > at java.io.ObjectInputStream.readObject(ObjectInputStream.java:232)
              > at weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectI
              >nputStreamBase.java:76)
              > at weblogic.servlet.internal.session.ReplicatedSession.readExternal(Repl
              >icatedSession.java:63)
              > at weblogic.common.internal.WLObjectInputStreamBase.readPublicSerializab
              >le(WLObjectInputStreamBase.java, Compiled Code)
              > at weblogic.common.internal.WLObjectInputStreamBase.readLeftover(WLObjec
              >tInputStreamBase.java, Compiled Code)
              > at weblogic.common.internal.WLObjectInputStreamBase.readObjectBody(WLObj
              >ectInputStreamBase.java, Compiled Code)
              > at weblogic.common.internal.WLObjectInputStreamBase.readObject(WLObjectI
              >nputStreamBase.java, Compiled Code)
              > at weblogic.common.internal.WLObjectInputStreamBase.readObjectWL(WLObjec
              >tInputStreamBase.java, Compiled Code)
              > at weblogic.rmi.extensions.AbstractInputStream2.readObject(AbstractInput
              >Stream2.java:25)
              > at weblogic.cluster.replication.ReplicationManager_WLSkel.invoke(Replica
              >tionManager_WLSkel.java:49)
              > at weblogic.rmi.extensions.BasicServerObjectAdapter.invoke(BasicServerOb
              >jectAdapter.java, Compiled Code)
              > at weblogic.rmi.extensions.BasicRequestHandler.handleRequest(BasicReques
              >tHandler.java:69)
              > at weblogic.rmi.extensions.BasicRequestDispatcher.dispatch(BasicRequestD
              >ispatcher.java:80)
              > at weblogic.rmi.internal.BasicRemoteInvokable.invoke(BasicRemoteInvokabl
              >e.java:31)
              > at weblogic.rjvm.RJVMImpl.dispatch(RJVMImpl.java:657)
              > at weblogic.rjvm.ConnectionManagerServer.handleRJVM(ConnectionManagerSer
              >ver.java:123)
              > at weblogic.rjvm.ConnectionManager.dispatch(ConnectionManager.java:630)
              > at weblogic.socket.JVMAbbrevSocket.dispatch(JVMAbbrevSocket.java:393)
              > at weblogic.socket.JVMSocketT3.dispatch(JVMSocketT3.java, Compiled
              >Code)
              >
              > at weblogic.socket.NTSocketMuxer.processSockets(NTSocketMuxer.java,
              >Comp
              >iled Code)
              > at weblogic.socket.SocketReaderRequest.execute(SocketReaderRequest.java:
              >23)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
              >Code)
              >
              >--------------- nested within: ------------------
              >weblogic.rmi.ServerError: A RemoteException occurred in the server method
              > - with nested exception:
              >[java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest]
              > at weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.j
              >ava:76)
              > at weblogic.cluster.replication.ReplicationManager_WLStub.create(Replica
              >tionManager_WLStub.java:100)
              > at weblogic.cluster.replication.ReplicationManager.createSecondary(Repli
              >cationManager.java:457)
              > at weblogic.cluster.replication.ReplicationManager.checkHosts(Replicatio
              >nManager.java:523)
              > at weblogic.cluster.replication.ReplicationManager.clusterMembersChanged
              >(ReplicationManager.java:548)
              > at weblogic.cluster.MemberStash$ClusterMembersChangeDeliverer.execute(Me
              >mberStash.java:209)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              >--------------- nested within: ------------------
              >weblogic.rmi.extensions.RemoteRuntimeException: Undeclared checked exception
              >-
              >w
              >ith nested exception:
              >[weblogic.rmi.ServerError: A RemoteException occurred in the server method
              > - with nested exception:
              >[java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletRequest]]
              > at weblogic.cluster.replication.ReplicationManager_WLStub.create(Replica
              >tionManager_WLStub.java:108)
              > at weblogic.cluster.replication.ReplicationManager.createSecondary(Repli
              >cationManager.java:457)
              > at weblogic.cluster.replication.ReplicationManager.checkHosts(Replicatio
              >nManager.java:523)
              > at weblogic.cluster.replication.ReplicationManager.clusterMembersChanged
              >(ReplicationManager.java:548)
              > at weblogic.cluster.MemberStash$ClusterMembersChangeDeliverer.execute(Me
              >mberStash.java:209)
              > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)
              

  • Serialization - ClassNotFound Exception ?!

    First hallo every one :
    Second:
    i have a problem with deserialization , i have here 3 machines talk to each others through objects (Called MessageX) this happen through sockets and Object Input & Output Streams .
    now class MessageX is inside the package of each program of the 3 machines , but once one of them receive an object at casting it back to the MessageX type i get a nice Exception saying that ClassNotFound Exception .
    so now does that mean that i cant talk through objects [i guess not] , and if i can how i can overcome the class not found exception ?!
    thanks in advance for each replay .

    so now does that mean that i cant talk through objectsNo, of course it doesn't.
    if i can how i can overcome the class not found exception ?!The machine where you got the exception doesn't have the class named in the exception available in its classpath. It's as simple as that.

  • ClassNotFound for com.sap.dictionary.designtime.generation.TemplateHelper

    Just installed app server and developer studio.  Completed first web dynpro application, but it will not run. Get "Page cannot be displayed" in browser.  Get ClassNotFound for com.sap.dictionary.designtime.generation.TemplateHelper.  You can only see this by the way, when running the tool in "console" mode.  I don't see the file in the files that I downloaded.  There is no com.sap.dictionary.designtime.generation.  Do others have this library?

    Hi,
    check your Jco destination in the content administrator http://hostname:port/webdynpro/dispatcher/sap.com/tcwdtools/Explorer, goto Maintain Jco Destinations and look for jco SAP_R3_HumanResources and SAP_R3_HumanResources_MetaData.
    The first one should use SSO/ticket and other one should use a system user that is used to sync metaData.
    regards,
    sangeeta

Maybe you are looking for