Classnotfoundexception eventhough the class is inside jar

Hi guys,
I encountered weird problem where sometimes it throws classnotfoundexception eventhough the class is inside jar. I terminate the program and start it again then it works fine. I compiled the jar using ant
     <target name="compile" depends="clean" description="">
           <echo message="using java version    : ${java.version}"/>
           <echo message="using ant.java.version: ${ant.java.version}" />          
             <javac srcdir="${src.dir}"
                    destdir="${build.dir}"
                    debug="on"
                    source="1.5"
                          excludes="com/csg/cs/mud/junit/*"
             />
            <jar destfile="${mmd.jar}"
                 basedir="${build.dir}"
                 excludes="org/css/cs/mmd/juni*,org/css/cs/mmd/utility/MDDClient.class"
            />          
     </target> it shows :
*[echo] using java version : 1.5.0_04*
*[echo] using ant.java.version: 1.5*
and I deployed this jar to sun solaris (SunOS sg123-456 5.8 Generic_117350-44 sun4u sparc SUNW,Ultra-80) and sun solaris box is using jre1.5.0_06.
Appreciate any advice please. thanks in advance!
Cheers,
Mark
Edited by: kmthien on Aug 2, 2010 3:05 AM

Is it public?
Is it spelt correctly, and the same, in the jar file and the code?
Is it in its correct package in the jar file?
Why are you excluding a class from the jar file?

Similar Messages

  • How to protect the class files inside jar file.

    Hi Group,
    pls help me.
    my need is i created a executable jar file with certain classes.
    and i'm supposed to send it to my client.
    but if the client needs he can extract the class files from the jar and with the
    help of some decompilers he can convert class file to .java source code and read the whole
    stuff.
    how can i protect my jar file from these.
    is there any security mechanism for that
    pls help me.
    Regards,
    Ranjith.M

    In order to protect my jar file I tried the jar signer technology but it only protects the jar from modification so I need to know how to protect jar file from decoding of the contents inside.

  • Invisible class files inside jar archives

    Hi!
    After developing an application with J2SE 1.4.1_05, under Windows 98, using some packages archived in jar files, I cannot launch the application with the J2RE 1.4.2_02 or J2SE 1.4.2_02 (in the same Windows 98) because the class files in the jars are not 'visible', even if the CLASSPATH is set up correctly. The only classes that work right are the unpacked ones. But it still does work in Windows 2000.
    What might be wrong?

    Thank you for your answer, and excuse me if my question was kind of confusing.
    The issue here is that the files ARE in the jar files (without './' on the front), but in the environment (Windows 98 + J2RE 1.4.2_02) the application does not work, unless I unpack the jars and use the packages in the same manner I did during the development stage (for example, all classes of package 'myutils' in the folder 'myutils').
    The weird thing is that this DOES NOT happen in the environment (Windows 2000 + J2RE 1.4.2_02)!!! Just after installing the J2RE 1.4.2_02 under Win2K, the app does work OK! That is why it seems that ONLY in the first case (Windows 98 + J2RE 1.4.2_02) the class files inside the jars seem to be 'invisible' to the environment.
    As I have mentioned in my question, the app was developed in the environment (Windows 98 + J2RE 1.4.1_05), and it did still work with the jar files, so I wonder if there might be some compatibility between Windows 98 and the J2RE 1.4.2_02.
    Except my own jars, the same thing does happen with the jai_core.jar file coming with JAI 1.1.2. But this does not happen when it comes about rt.jar, in ..\jre\bin!!!
    All in all, the question still is: what might be wrong?

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • How to combine the classes from 2 jar files into 1?

    Hi there
    I have got 2 jar files with the same name but the classes that they contain are different. So, I want to combine those 2 files into 1. Could anyone please tell me how to add the classes in a jar file to another jar file?
    Thanks for your help!
    From
    Edmund

    The jar utility allows you to extract files as well as put them into a jar. This is in the java docs.
    You might have to hand modify the manifest file if it was hand modified in the first place. All you should have to do is copy the text from one file to another. The manifest will have the same name so you will have to extract to different dirs so it isn't overwritten.
    Steps:
    -Create dir1 and dir2
    -Extract jar1 into dir1, Extract jar2 into dir2.
    -Manually examine manifests and combine if needed.
    -Copy files from one dir to another.
    -Use jar tool to create new jar.

  • How to load all the classes in a JAR file at runtime?

    Any clues o:
    "How can I force JVM to load all the classes in a specified JAR at once?"
    Thanx!
    -Rajeev

    Well I was thinking may be there exists an option with "java", when I
    am starting an application from a jar file, I could force it to load all
    the classes in the JAR. I don't want to do it programically. Is there such
    an option available?? Or in other words can I ask JVM to not do the dynamic
    loading for the JAR??
    Thanx.
    List all JarEntries and convert the paths to fully
    qualified class files
    e.g file in jar
    [1] /com/mycompany/proj/X.class
    should become
    [2] com.mycompany.proj.X
    then for each entry issue
    Class.forName( [2] );

  • Trying to use the classes in casStubs.jar and get crawl metrics

    I was going through the class files available in casStubs.jar and was trying to come up with a script in AppConfig.xml to connect to the CAS server and obtain the crawl status and metrics. I was trying this option because the class com.endeca.eac.toolkit.component.cas.ContentAcquisitionServerComponent does not provide me these features.
    +<script id="CheckCrawlStatus">+
    +<bean-shell-script><![CDATA[+
    import javax.xml.namespace.QName;
    import com.endeca.cas.wsdl.*;
    final String wsdlUrl = "http://" "${cas.host}" + ":" + "${cas.port}" + "/cas?wsdl";+
    final QName name = new QName("http://endeca.com/itl/cas/2010-07", "CasCrawlerService");
    CasCrawlerServiceLocator service =  new CasCrawlerServiceLocator(wsdlUrl, name);
    CasCrawler crawler = service.getCasCrawlerPort();
    String crawlName = "myFirstCrawl";
    CrawlId crawlId = new CrawlId(crawlName);
    Metric[] metricArray = crawler.getMetrics(crawlId);
    + // rest of the code to retrieve crawl metrics +
    +]]></bean-shell-script>+
    +</script>+
    Unfortunately, I am always getting connection refused exception - "java.net.ConnectException: Connection refused". My cas wsdl is loading fine in my browser.
    Any ideas about the shortcomings in the code or missing configuration in CAS or DT or platformservices?
    Thanks
    Dev

    Hey Brett,
    Awesome, it works now. I went through the source code by de-compiling the class files and figured out why you referred to this extra line of code; great that it didn't miss your "laser eyes". It was really helpful.
    Another question for you; a stupid one maybe -
    I was also trying to call the web-services through the browser -
    http://{cas-host}:{cas-port}/cas/listCrawls - this one works great; gives me the list of all the crawls
    http://{cas-host}:{cas-port}/cas/getAllMetrics - this one work great too
    But when I try to pass a parameter my service call fails with an exception
    http://{cas-host}:{cas-port}/cas/getMetrics?crawlId={crawl-id}
    <soap:Body>
    <soap:Fault>
    <faultcode>soap:Server</faultcode>
    <faultstring>java.lang.ClassCastException@1b3bf979 while invoking public java.util.List com.endeca.itl.service.CasCrawlerImpl.getMetrics(com.endeca.itl.cas.api.CrawlId) throws com.endeca.itl.cas.api.CrawlNotFoundException with params {crawl-id}.</faultstring>
    </soap:Fault>
    </soap:Body>
    Note : {cas-host}, {cas-port} and {crawl-id} are placeholders for actual values.
    Any idea where I am going wrong?
    Thanks
    Dev
    Edited by: 950423 on Sep 4, 2012 3:13 PM

  • Adding all the classes and external jars in webservice WAR using servicegen

    Hi,
    Can someone please tell me how do I include all the classes and my external jar files to the ear/war file that is created using servicegen. I don't see any option in servicegen tag where I can include my classes and jar files to the ear/war file. The war it creates only contains the web service implementation class but I want to all the classes in the service code and jars in the same war. Any ideas on how to do that instead of putting in the classpath.
    here is the snippet of my build file
    <servicegen
           destEar="${deploy}/myservice.ear"
           warName="myservice.war">
           <service
             javaClassComponents="com.ws.service.TestService"
             targetNamespace="http://xmlns.test.com/tool/myservice"
             serviceName="myservice"
             serviceURI="/myservice"
             style="document"
             protocol="http"
             expandMethods="True">
           </service>
          <classpath>
            <pathelement path="${classes}"/>
            <pathelement path="${lib}/*.jar"/>
         <pathelement path="C:/bea/weblogic92/server/lib/webserviceclient.jar"/>
          </classpath>      
    </servicegen>
    ..........................Thanks

    Hi,
    The work around I am using to overcome this problem is Unzipping th ear/war file created by servicegen task and including all the classes. Then creating the ear file again by creating a new ant target.
    I know this is not a neater way, but this works for me.

  • How to access all the classes in a jar file

    hai
    i have a custom built JAR file which has many classes(Translets) in it . i want to access the classes inthe JAR file in a JSP page or an servlet. I have tried setting the classpaths etc , but nothing has happened.
    Where should the jar file be Palced - i am using Tomcat Server.
    How Can i Access the class files .. Very Urgent .. Please Help me ..
    Peter Iyer

    What is showing a file not found error? The web browser? if so, that's probably not a problem with the jar file.
    Also, have you expanded your jar file to make sure that you jarred it up correctly?

  • Classes in added jar on classpath not found

    Hi there,
    The javafx compiler seems to have trouble finding classes from a jar that was added to the lib directory of a javafx project. I experience this trouble when working with the Netbeans 6.5.1 IDE and javafx version 1.2.
    When trying to import a single class in a javafx file from a manually added jar, a compiler error occurs stating that the class cannot be found. Package names, however, do get recognized when importing classes, and therefore star import are possible. The actual classes from a package that was imported by means of a star import, don't get recognized.
    Does anyone have an idea what causes this problem and how to resolve it?
    Kind regards and thanks in advance,
    Rienk

    Can I refer classes in embedded jar's? I thought that did not work. It wasn't working so I tried putting the same jars into the same directory as the main class.
    Let me try again with less information.
    My jar with the main class is: testpojo.jar
    The class path inside the manifest is
    Class-Path: swing-layout-1.0.03.jar AbsoluteLayout.jar
    The directory with the external jar is:
    Directory of C:\DOCUME~1\MDARR\WORKSP~1\TESTPO~1\TARGET
    9/11/2008 10:44 PM <DIR> .
    9/11/2008 10:44 PM <DIR> ..
    9/11/2008 10:44 PM 2,850 AbsoluteLayout.jar
    9/11/2008 10:44 PM 118,103 swing-layout-1.0.3.jar
    9/11/2008 10:56 PM 51,660 testpojo.jar
    Unless I've missed something the the swing-layout-1.0.3.jar jar file is in the same relative directory as testpojo.jar.
    When I execute the main class should be able to reference classes in that file.
    But it gets,
    Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/layout/GroupLayout$Group
    What's happening? It's a little confusing because the same jar is also stored inside testpojo.jar. I read that Java can't load from embedded jar's so I tried putting them in the same directory as testpojo.jar and setting the class path inside the manifest.
    And yes, I understand about the main class name. That was just me goofing around trying to label things. At this I'm a rookie.
    Tia,
    Maurice

  • Using System.err.println() from within the classes of WAS ?

    hi,
    I am using admin.jar,a jar file which is being used by Web Application Server in my own class.
    I am referencing some of the classes from admin.jar from my class.
    I tried to print some trace statements,using System.err.println() from within the classes in admin.jar but they did not reflect in defaulttrace0.trc.
    I made these changes in the admin.jar being used by WAS.
    I restarted the server and even restarted the machine but without success.
    I want to know how to print System.out.println() statements from within the classes in admin.jar.
    Also, am i looking for these statements in the right file for eg. defaulttrace0.trc. or is it some other file that i need to look into.
    I need urgent help on this.
    Reward points assured.
    thanks a lot.
    Saurav

    thanks craig,
    ur answer has helped me a lot.but it didnt quite help me.
    nevertheless i am trying to set different levels of severity.
    Is there anything else that i can do.
    Also,i commented out a line of code today in one of the class DataSourceManagerImpl.java in sapj2eenginedeploy.jar
    for eg. temp.delete in it deploy method.Buth that line still executed.
    I m totally lost as to wht to do.
    I m trying to create a datasource from my application in WAS.For that i m using the WAS APIs.But its not working completely.
    I am using the above jar and its method createdatasource.
    I am callin it from my application's class.
    It creates a datasource and i can see it in JDBC Connector list in Visual Administrator.But it appears with red sign meaning its not started.When i start it from the tool then it starts.
    But in defaulttrace.trc file it shows an error "FileNotFindException". This happens,and i am very much sure, in the deploy() of DataSourceManagerImpl.java class of sapj2eenginedeploy.jar.
    i want to apply println inside this method so i may know where exactly i ma getting the error and get so more info so i may solve my problem.
    pls help me.
    its really urgent.
    thanks again
    saurav

  • Best practice to handle the class definitions among storage enabled nodes

    We have a common set of cache servers that are shared among various applications. A common problem that we face upon deployment is with the missing class definition newly introduced by one of the application node. Any practical approach / best practices to address this problem?
    Edited by: Mahesh Kamath on Feb 3, 2010 10:17 PM

    Is it the cache servers themselves or your application servers that are having problems with loading classes?
    In order to dynamically add classes (in our case scripts that compile to Java byte code) we are considering to use a class loader that picks up classes from a coherence cache. I am however not so sure how/if this would work for the cache servers themselves if that is your problem!?
    Anyhow a simplistic cache class loader may look something like this:
    import com.tangosol.net.CacheFactory;
    * This trivial class loader searches a specified Coherence cache for classes to load. The classes are assumed
    * to be stored as arrays of bytes keyed with the "binary name" of the class (com.zzz.xxx).
    * It is probably a good idea to decide on some convention for how binary names are structured when stored in the
    * cache. For example the first tree parts of the binary name (com.scania.xxxx in the example) could be the
    * "application name" and this could be used as by a partitioning strategy to ensure that all classes associated with
    * a specific application are stored in the same partition and this way can be updated atomically by a processor or
    * transaction! This kind of partitioning policy also turns class loading into a "scalable" query since each
    * application will only involve one cache node!
    public class CacheClassLoader extends ClassLoader {
        public static final String DEFAULT_CLASS_CACHE_NAME = "ClassCache";
        private final String classCacheName;
        public CacheClassLoader() {
            this(DEFAULT_CLASS_CACHE_NAME);
        public CacheClassLoader(String classCacheName) {
            this.classCacheName = classCacheName;
        public CacheClassLoader(ClassLoader parent, String classCacheName) {
            super(parent);
            this.classCacheName = classCacheName;
        @Override
        public Class<?> loadClass(String className) throws ClassNotFoundException {
            byte[] bytes = (byte[]) CacheFactory.getCache(classCacheName).get(className);
            return defineClass(className, bytes, 0, bytes.length);
    }And a simple "loader" that put the classes in a JAR file into the cache may look like this:
    * This class loads classes from a JAR-files to a code cache
    public class JarToCacheLoader {
        private final String classCacheName;
        public JarToCacheLoader(String classCacheName) {
            this.classCacheName = classCacheName;
        public JarToCacheLoader() {
            this(CacheClassLoader.DEFAULT_CLASS_CACHE_NAME);
        public void loadClassFiles(String jarFileName) throws IOException {
            JarFile jarFile = new JarFile(jarFileName);
            System.out.println("Cache size = " + CacheFactory.getCache(classCacheName).size());
            for (Enumeration<JarEntry> entries = jarFile.entries(); entries.hasMoreElements();) {
                final JarEntry entry = entries.nextElement();
                if (!entry.isDirectory() && entry.getName().endsWith(".class")) {
                    final InputStream inputStream = jarFile.getInputStream(entry);
                    final long size = entry.getSize();
                    int totalRead = 0;
                    int read = 0;
                    byte[] bytes = new byte[(int) size];
                    do {
                        read = inputStream.read(bytes, totalRead, bytes.length - totalRead);
                        totalRead += read;
                    } while (read > 0);
                    if (totalRead != size)
                        System.out.println(entry.getName() + " failed to load completely, " + size + " ," + read);
                    else
                        System.out.println(entry.getName().replace('/', '.'));
                        CacheFactory.getCache(classCacheName).put(entry.getName() + entry, bytes);
                    inputStream.close();
        public static void main(String[] args) {
            JarToCacheLoader loader = new JarToCacheLoader();
            for (String jarFileName : args)
                try {
                    loader.loadClassFiles(jarFileName);
                } catch (IOException e) {
                    e.printStackTrace();
    }Standard disclaimer - this is prototype code use on your own risk :-)
    /Magnus

  • Is it possible to load classes from a jar file

    Using ClassLoader is it possible to load the classes from a jar file?

    URL[] u = new URL[1] ;
    u[0] = new URL( "file://" + jarLocation + jarFileName + "/" );
    URLClassLoader jLoader = new URLClassLoader( u );
    Object clsName = jLoader.loadClass( clsList.elementAt(i).toString() ).newInstance();
    I get this error message.
    java.lang.ClassNotFoundException: ExceptionTestCase
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:297)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:253)
    // "file://" + fileLocation + fileName + "/" This works fine from a browser.
    Is there anything I am missing? Thanks for the reply.

  • Configure weblogic startup class in deployment jar

    We need to invoke a class during weblogic startup that is part of application deployment jar...
    It works if startup class is added to server classpath ( Weblogic documentation also insists that). But our startup class uses application logic and needs to be part of application jar..
    We are getting java.lang.ClassNotFoundException for the class during start up. setting LoadBeforeAppDeployments to false also does not help...
    Is there any other way to invoke a application class during weblogic startup...?
    Any help would be appreciated.
    Thanks,
    Rajasekar.

    here is the solution to this:
    in the conventional method of implementing a startup class, one needs to impletent the T3STartupDef interface and register the class as a startup class in the console / config.xml
    in this method, the startup class need not implement the T3STartupDef interface, it just needs to have a "main" method that will be called. the process of registeration is also simple, if you have an application ear.
    while making the application ear, add a weblogic-application.xml along with the application.xml. the weblogic-application.xml should contain :
    <startup>
    <startup-class>myStartup</startup-class>
    <startup-uri>myStartupArchive.jar</startup-uri>
    </startup>
    the myStartupArchive.jar should contain the startup class and all classes used by it
    also, use a "manifest" file to point to other library jars within the ear
    hope this helps someone !
    going, going, ... gone.

  • Accessing classes in external jar files

    I have a jar file called main. I want it to be able to acces the classes in another jar file say test.jar how do i do this.
    Thank you

    ok, if i have this right...
    you have 2 directories that hold 2 .jars, right?
    plugins/ -------- build/plugins .jar
    systemModuals/ ------- DiaryUI and Loader .jar
    Your main JAR is diary?
    Diary.jar
    you want Diary to run with the jars inside plugins and systemmoduals?
    you set the "class-path:" tag like this....
    write this manifest file. save it as Manifest.txt and put it in your home dir.
    Main-Class: YourMainClass
    Class-Path: Diary.jar plugins/this.jar systemmoduals/diaryui.jar
    <make sure to hit enter, go to the next line>
    command line to your parent directory.
    jar cmf Manifest.txt Diary.jar build/main/*.class
    you should be set to go.
    use
    jar xf META-INF/MANIFEST.MF
    to read the present manifest that netbeans has created
    if necessary

Maybe you are looking for

  • After updating to 10.8.1 i can not connect to wifi   no hardware installed , it says

    When I installed the update to 10.8.1 there comes a message that there was a problem by installing. Now i can not connect to a wifi network, when i click on the wifi at the bottom No hardware is installed Why is there no hardware installed? Under 10.

  • Adding value to List and Reading the list on submit

    Hi all, I want to create a page where it would have two region. Region 1 --> Contain the list of employee (report region) This will have a search box with java script enabled to perform search without submitting the page. And a link on the employee n

  • Environment variable setup

    I am using WIN XP PRO and installed jdk1.5.0_07 as ADMIN. Added jdk1.5.0_07\bin to the right end of lines of both CLASSPATH and path. In the cmd prompt window the javac is not recognized as an internal or external command, operable program or batch f

  • Email recipient as VIP?

    Hello All, I have an iPhone 5 that is running IOS 8 and I have a mail question. I am currently using Exchange server for mail and would like to assign a recipient as a VIP. Everything I have been reading talks about adding a sender as a VIP. Here is

  • Webworkers working, but errors in log

    Hi all, I have an issue on all web workers (both shared and reserved). The workers are running (and showing OK in the admin portal), but when I open the Role Log of any of them I see the following error: Failed to run method 'Microsoft.Web.Farm.Avail