Article View: borland.public.jbuilder.java.api
Article #108Re: NoClassDefFoundError ... wrong name
From: Scott
Date: Tue, 06 Apr 2004 03:43
Date: Tue, 06 Apr 2004 03:43
151 lines
5790 bytes
5790 bytes
Recompiling all of the .java files seems to have fixed it.
Thank god for the GUI tool's ability to compile everything in a project --
compiling one by one from the command line wasn't working.
"Scott" <scotthpowell@yahoo.com> wrote in message
news:4071b87d$1@newsgroups.borland.com...
> I am having a problem trying to use a third-party Java class library.
>
> Although it works from within a Java application, I am getting this error
> message when I try to use it from within Cold Fusion (Oh how I wish
Borland
> had bought Allaire! May not be too late.).
>
> I am trying to instantiate the object with this line:
> <cfset mp3x = createObject("java", "de.vdheide.mp3.MP3File").init()>
>
> And I get this error message:
> java.lang.NoClassDefFoundError: de/vdheide/mp3/MP3File (wrong name:
> mp3/de/vdheide/mp3/MP3File)
>
> I want to point out there is a difference in the two references here. The
> first says "de/vdheide" and the second says "mp3/de/vdheide". I have no
idea
> where that initial mp3 reference is coming from in the "wrong name"
clause.
>
> I've thought of these problems:
> * Mistake in my CF code? But the same syntax works on other classes (see
> below).
> * Mistake in the MP3File library? But it works in regular Java apps.
> * Mistake in the JVM's classpath? So I wrote the ClassPathManager class
at
> the bottom of this and it confirms that the file is in the classpath (and
> that the CF syntax works).
> * A mistake in the MP3File import or package reference? I included it
> below.
>
> Does anyone know what might cause this or how to resolve it? I'm
especially
> confused by the fact that "wrong name" reference is different from the
> other.
>
> Thanks
> Scott
>
> / **********************************************************************
> * Here is the heading for the MP3File definition.
> * The class works when I use it within a regular Java application. It is
> downloaded from
> * http://www.vdheide.de/projects.html.
> *
> * I am putting this file here:
> * C:\Program Files\Java\_jvm\lib\de\vdheide\mp3\MP3File.class
> *
> * Note that de.vdheide.mp3 appears in both.
> * My classpath is set to include c:\program files\java\_jvm\lib
> * The Java class I've included below does list th MP3File in that
directory
> as available within
> * the JVM context for my app server.
> ********************************************************************** /
> package de.vdheide.mp3;
>
> import java.io.File;
> import java.io.IOException;
>
> public class MP3File extends java.io.File
> {
> /* stuff goes here */
> }
>
>
>
>
> / **********************************************************************
> * Here is the ClassPathManager source code, which I compiled and put in
the
> classpath for CF.
> * Calling this class from within Cold Fusion, shows that the MP3File.class
> file is available in
> * the JVM's classpath. Here is how to call it from within CF:
> * <cfset cpm = createObject("java", "ClassPathManager").init()>
> * <cfset classes = cpm.getClasses()>
> * <cfdump var="#classes#">
> *
> * Feel free to use this wherever you need to double check class
> availability.
> * It returns a string array to make it as easy as possible to use in
> different environments.
> ********************************************************************** /
> import java.io.*;
> import java.util.*;
> public class ClassPathManager {
> private StringTokenizer classpath;
> private TreeSet fileHashSet;
>
>
> public ClassPathManager () {
> super();
> classpath = new StringTokenizer(System.getProperty("java.class.path"),
> ";" );
> fileHashSet = new TreeSet();
> }
>
> public String[] getClasses() {
> while (classpath.hasMoreTokens()){
> listDirectory(new File(classpath.nextToken()));
> }
>
> String[] arrayOfFiles = new String[0];
> arrayOfFiles = (String[]) fileHashSet.toArray(arrayOfFiles);
> return arrayOfFiles;
> }
>
> public void listClasses(){
> String[] fileNameArray = getClasses();
>
> for (int x=0; x<fileNameArray.length; x++){
> System.out.println(fileNameArray[x]);
> }
> }
>
>
>
> public void listDirectory(File entry){
> try {
> if (!entry.exists()){
> return;
> }
>
> if (entry.isFile()){
> fileHashSet.add((String) entry.getCanonicalPath());
> }else if (entry.isDirectory()){
> String [] fileName = entry.list();
> if (fileName == null) return;
> for (int i = 0; ifileName.length; i++){
> File item = new File(entry.getPath(), fileName[i]);
> listDirectory(item);
> }
> }
> } catch (IOException e) {
> System.err.println ("Error: " + e.getMessage() + " on " +
> entry.getName());
> }
> }
> }
>
>
>
Technical Details
Message-ID:
<407227be$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4071b87d$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,dd62b34d7378143 X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2004-04-05 21:06:45 PST Reply-To: "Scott" <scotthpowell@yahoo.com> From: "Scott" <scotthpowell@yahoo.com> Newsgroups: borland.public.jbuilder.java.api References: <4071b87d$1@newsgroups.borland.com> Subject: Re: NoClassDefFoundError ... wrong name Date: Mon, 5 Apr 2004 23:43:34 -0400 Lines: 153 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 24.239.150.17 Message-ID: <407227be$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081223102 24.239.150.17 (5 Apr 2004 20:45:02 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail