ClassNotFoundException on app run

Using : Build 944
OS: Windows XP Professional

Problem: Unable to run my application from within IDEA. However, the same
command is successful from a DOS window.

When I try to run my application from within IDEA, I get a
ClassNotFoundException on the main class. Since all paths in the execution
command were fully qualified, I simply copied the command IDEA was trying to
execute to a plain old DOS window (with no special settings) and the program
executed correctly.

Do you have any idea what might cause this behavior? I am trying to debug
the application and so it would be helpful to be run it from within IDEA.

Sri


11 comments
Comment actions Permalink

I tried to apply the suggestion

Following summarizes my results:

Both JNIWrap.dll & breakgen.dll removed

Run app: NoClassDefFoundError
Debug app: NoClassDefFoundError

breakgen.dll removed:

Run app: NoClassDefFoundError
Debug app: NoClassDefFoundError

JNIWrap.dll removed

Run app: ClassNotFoundException
Debug app: NoClassDefFoundError

Neither removed -- i.e. out-of-the-box configuration

Run app: ClassNotFoundException
Debug app: NoClassDefFoundError



0
Comment actions Permalink

Could you post the whole stacktrace?

--

Best regards,
Eugene Zhuravlev
JetBrains, Inc, http://www.intellij.com
"Develop with pleasure!"

"Sri Sankaran" <sri.sankaran@sas.com> wrote in message news:bmeukq$j9g$1@is.intellij.net...

I tried to apply the suggestion

>

Following summarizes my results:

>

Both JNIWrap.dll & breakgen.dll removed

>

Run app: NoClassDefFoundError
Debug app: NoClassDefFoundError

>

breakgen.dll removed:

>

Run app: NoClassDefFoundError
Debug app: NoClassDefFoundError

>

JNIWrap.dll removed

>

Run app: ClassNotFoundException
Debug app: NoClassDefFoundError

>

Neither removed -- i.e. out-of-the-box configuration

>

Run app: ClassNotFoundException
Debug app: NoClassDefFoundError

>
>
>


0
Comment actions Permalink

The case of ClassNotFoundException:

java.lang.ClassNotFoundException: com.werken.forehead.Forehead
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:75)
Exception in thread "main" Process terminated with exit code 1


When I try to debug the application I get a NoClassDefFoundError -- with no
stack trace:

java.lang.NoClassDefFoundError: com/werken/forehead/Forehead
Exception in thread "main" Process terminated with exit code 1


0
Comment actions Permalink

Does any jar path contain spaces (i.e. ...\My Project\some.jar)?

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com

"Develop with pleasure!"
"Sri Sankaran" <sri.sankaran@sas.com> wrote in message
news:bmgtfl$ptt$1@is.intellij.net...

The case of ClassNotFoundException:

>

java.lang.ClassNotFoundException: com.werken.forehead.Forehead
at java.net.URLClassLoader$1.run(URLClassLoader.java:198)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:140)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:75)
Exception in thread "main" Process terminated with exit code 1

>
>

When I try to debug the application I get a NoClassDefFoundError -- with

no

stack trace:

>

java.lang.NoClassDefFoundError: com/werken/forehead/Forehead
Exception in thread "main" Process terminated with exit code 1

>
>


0
Comment actions Permalink

I've had it do this to me before when a class is already in the startup
command. I wasn't sure if it was me.

Usually this happens to me with Tomcat. If I have a file in my project
path, and I start Tomcat up, it won't recognize the file. This is
especially true with Struts jar files.

What's happening is that Tomcat is not loading, or honoring not sure
which, the jar files in the classpath specified at startup, and you have
to put the class in your ]]>/WEB-INF/lib dir.

The other thing that doesn't seem to work is that if you put the lib in
the Tomcat/commons/lib directory, when the plugin starts up for IDEA it
doesn't load those libs, so you can't have one nice set of libs in one
directory, you have to have them all over the WEB-INF dir.

Why did I not report this before? Because I only noticed it in 9xx
builds and can't work with 9xx long enough to determine if it's
something wrong that I'm doing.

Hope this helps.

R

0
Comment actions Permalink

That was my first hunch. Didn't pan out. There are no spaces anywhere.
Here is the actual command that gets executed

C:\j2sdk1.4.1_02\bin\java -Djavax.xml.parsers.DocumentBuilderFactory=org.apa
che.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFact
ory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dmaven.home=%MAVEN_HOME% -D
tools.jar=%JAVA_HOME%\lib\tools.jar -Dforehead.conf.file=%MAVEN_HOME%\bin\fo
rehead.conf -Djava.endorsed.dirs=%JAVA_HOME%\lib\endorsed;%MAVEN_HOME%\lib\e
ndorsed -Xmx160m -Dfile.encoding=windows-1252 -classpath
%MAVEN_HOME%\lib\forehead-1.0-beta-5.jar;C:\idea944\lib\idea_rt.jar -Didea.l
auncher.port=7532 -Didea.launcher.library=C:\idea944\bin\breakgen.dll
com.intellij.rt.execution.application.AppMain com.werken.forehead.Forehead
mis-util

where
MAVEN_HOME=c:\apache\maven-1.0-rc1 and
JAVA_HOME=c:\j2sdk1.4.1_02

Again, I can cut and paste this command in a DOS window -- AS IS -- and it
works.

Sri


0
Comment actions Permalink

Sri Sankaran wrote:

That was my first hunch. Didn't pan out. There are no spaces anywhere.
Here is the actual command that gets executed

C:\j2sdk1.4.1_02\bin\java -Djavax.xml.parsers.DocumentBuilderFactory=org.apa
che.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFact
ory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dmaven.home=%MAVEN_HOME% -D
tools.jar=%JAVA_HOME%\lib\tools.jar -Dforehead.conf.file=%MAVEN_HOME%\bin\fo
rehead.conf -Djava.endorsed.dirs=%JAVA_HOME%\lib\endorsed;%MAVEN_HOME%\lib\e
ndorsed -Xmx160m -Dfile.encoding=windows-1252 -classpath
%MAVEN_HOME%\lib\forehead-1.0-beta-5.jar;C:\idea944\lib\idea_rt.jar -Didea.l
auncher.port=7532 -Didea.launcher.library=C:\idea944\bin\breakgen.dll
com.intellij.rt.execution.application.AppMain com.werken.forehead.Forehead
mis-util

where
MAVEN_HOME=c:\apache\maven-1.0-rc1 and
JAVA_HOME=c:\j2sdk1.4.1_02

Again, I can cut and paste this command in a DOS window -- AS IS -- and it
works.

Sri

Sri, try my suggestion and see if it works.

R

0
Comment actions Permalink

Environment variables aren't supported. So jar forehead-1.0-beta-5.jar will
not be found in classpath:
-classpath
%MAVEN_HOME%\lib\forehead-1.0-beta-5.jar;C:\idea944\lib\idea_rt.jar

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com

"Develop with pleasure!"
"Sri Sankaran" <sri.sankaran@sas.com> wrote in message
news:bmh03j$2l4$1@is.intellij.net...

That was my first hunch. Didn't pan out. There are no spaces anywhere.
Here is the actual command that gets executed

>
>
C:\j2sdk1.4.1_02\bin\java -Djavax.xml.parsers.DocumentBuilderFactory=org.apa
>
che.xerces.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.parsers.SAXParserFact
>
ory=org.apache.xerces.jaxp.SAXParserFactoryImpl -Dmaven.home=%MAVEN_HOME% -D
>
tools.jar=%JAVA_HOME%\lib\tools.jar -Dforehead.conf.file=%MAVEN_HOME%\bin\fo
>
rehead.conf -Djava.endorsed.dirs=%JAVA_HOME%\lib\endorsed;%MAVEN_HOME%\lib\e

ndorsed -Xmx160m -Dfile.encoding=windows-1252 -classpath

>
%MAVEN_HOME%\lib\forehead-1.0-beta-5.jar;C:\idea944\lib\idea_rt.jar -Didea.l

auncher.port=7532 -Didea.launcher.library=C:\idea944\bin\breakgen.dll
com.intellij.rt.execution.application.AppMain com.werken.forehead.Forehead
mis-util

>

where
MAVEN_HOME=c:\apache\maven-1.0-rc1 and
JAVA_HOME=c:\j2sdk1.4.1_02

>

Again, I can cut and paste this command in a DOS window -- AS IS -- and it
works.

>

Sri

>
>


0
Comment actions Permalink

Robert:

If I understsand your suggestion you are recommending placing the application class/jar files in webapp/WEB-INF/classes (or lib).

However, this is not a web application. So, no WEB-INF etc are involved. I am trying to debug a Jelly tag library that is being invoked by Maven. Every class that is needed is directly specified through the classpath.

Sri

0
Comment actions Permalink

That was it! Thank you very much.

Sri

0

Please sign in to leave a comment.