MyEclipse Forums
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
optimad
Post subject: NoClassDefFoundError with test classes not in src/test  PostPosted: Apr 12, 2012 - 11:21 PM
Veteran Member
Veteran Member


Joined: May 04, 2005
Posts: 16

Hi,

Currently using MyEclipse 10.1. I've got a Maven project with a src/test source folder as well as another called src/scratch. This is designed for ad hoc helper classes and the like - not strictly 'test' classes.

I get compilation warnings when I deliberately introduce errors (which makes it look like it's working), but when I try and run the class as a java app, I get java.lang.NoClassDefFoundError.

My classpath is like this:

<classpath>
<classpathentry kind="src" path="src/main/java" including="**/*" output="target/classes" />
<classpathentry kind="src" path="src/main/resources" including="**/*" output="target/classes" />
<classpathentry kind="src" path="src/test/java" including="**/*" output="target/test-classes" />
<classpathentry kind="src" path="src/test/resources" including="**/*" output="target/test-classes" />
<classpathentry kind="src" path="src/scratch/java" including="**/*" output="target/test-classes" />
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

And the <build> section of my pom is like this:

<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes><include>**/*.*</include></includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes><include>**/*.*</include></includes>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/java</directory>
<includes><include>**/*.*</include></includes>
</testResource>
<testResource>
<directory>src/test/resources</directory>
<includes><include>**/*.*</include></includes>
</testResource>
<testResource>
<directory>src/scratch/java</directory>
<includes><include>**/*.*</include></includes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Why isn't it picking up the compiled class? I can see the java and class files in target/test-class, so it _looks_ to be working.

What am I missing?!?

Thanks in advance

Matt
 
 View user's profile Send private message  
Reply with quote Back to top
support-joy
Post subject:   PostPosted: Apr 13, 2012 - 12:07 PM
Registered Member
Registered Member


Joined: Feb 03, 2009
Posts: 3442

Matt,

Sorry to hear you are running into "java.lang.NoClassDefFoundError". This usually means that your classpath is not set correctly. Could you provide below details -
1. Open MyEclipse IDE, from menu options click on MyEclipse > Installation Summary > Installation Details > [Copy to Clipboard] and paste the same here
2. Clear your .log file located at [your workspace dir]/.metadata/.log, replicate the issue and attach file here.
3. Attach a screenshot of target/test-class
4. Check your deployment policies here - Window > preferences > MyEclipse > Java Enterprise Project > EAR/EJB/Web Project. Check the Library Deployment Policies(You could look under deployment tab).

_________________
Joy
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
optimad
Post subject:   PostPosted: Apr 13, 2012 - 02:15 PM
Veteran Member
Veteran Member


Joined: May 04, 2005
Posts: 16

Hi Joy,

Thanks for the reply:

2) Nothing additional went into the .log file once cleared
3) This contains a whole set of folders, including one which contains (a few levels down) my test and scratch java and class files
4) The workspace default is "Smart deployment" and all Library Deployment policies are ticked
1) Installation Details:
*** Date:
Friday, 13 April 2012 12:59:45 o'clock BST

*** System properties:
OS=WindowsVista
OS version=6.1.0
OS arch=x86
Profile arch=x86
Window system=win32
Java version=1.6.0_13
Workspace=file:/C:/dev/workspaces/10_1/
VM Args=-Xmx512m
-XX:MaxPermSize=256m
-XX:ReservedCodeCacheSize=64m
-Dosgi.nls.warnings=ignore
-Djava.class.path=C:\PROGRA~1\Genuitec\Profiles\MYECLI~1.1\../../Common/plugins/ORB7B5~1.JAR



*** Subscription information
Product Id: E3MP (MyEclipse Professional Subscription)
License version: 3.0
Full Maintenance Included
Subscription expiration date (YYYYMMDD): 20130201
Number of users: 2

*** Eclipse details:
MyEclipse Enterprise Workbench

Version: 10.1
Build id: 10.1-20120316


Blueprint: MyEclipse 10

com.genuitec.myeclipse.database - 10.1.0.me201203170059
com.genuitec.myeclipse.desktop - 10.1.0.me201203170059
com.genuitec.myeclipse.editor - 10.1.0.me201203170059
com.genuitec.myeclipse.enterprise.workbench - 10.1.0.me201203170059
com.genuitec.myeclipse.geronimo - 10.1.0.me201203170059
com.genuitec.myeclipse.glassfish - 10.1.0.me201203170059
com.genuitec.myeclipse.icefaces.feature - 10.1.0.me201203170059
com.genuitec.myeclipse.iedebugger - 10.1.0.me201203170059
com.genuitec.myeclipse.imageeditor - 10.1.0.me201203170059
com.genuitec.myeclipse.jboss - 10.1.0.me201203170059
com.genuitec.myeclipse.jetty - 10.1.0.me201203170059
com.genuitec.myeclipse.jonas - 10.1.0.me201203170059
com.genuitec.myeclipse.jrun - 10.1.0.me201203170059
com.genuitec.myeclipse.jsf - 10.1.0.me201203170059
com.genuitec.myeclipse.matisse - 10.1.0.me201203170059
com.genuitec.myeclipse.maven - 10.1.0.me201203170059
com.genuitec.myeclipse.oracle - 10.1.0.me201203170059
com.genuitec.myeclipse.orion - 10.1.0.me201203170059
com.genuitec.myeclipse.persistence - 10.1.0.me201203170059
com.genuitec.myeclipse.pulse - 10.1.0.me201203170059
com.genuitec.myeclipse.reports - 10.1.0.me201203170059
com.genuitec.myeclipse.resin - 10.1.0.me201203170059
com.genuitec.myeclipse.struts - 10.1.0.me201203170059
com.genuitec.myeclipse.sun - 10.1.0.me201203170059
com.genuitec.myeclipse.tomcat - 10.1.0.me201203170059
com.genuitec.myeclipse.uml2 - 10.1.0.me201203170059
com.genuitec.myeclipse.visualvm - 10.1.0.me201203170059
com.genuitec.myeclipse.visualvm.server - 10.1.0.me201203170059
com.genuitec.myeclipse.weblogic - 10.1.0.me201203170059
com.genuitec.myeclipse.websphere - 10.1.0.me201203170059
com.genuitec.myeclipse.ws - 10.1.0.me201203170059
org.eclipse.birt - 2.6.1.me201203170059
org.eclipse.datatools.connectivity.feature - 1.9.0.me201203170059
org.eclipse.datatools.enablement.feature - 1.9.0.me201203170059
org.eclipse.datatools.modelbase.feature - 1.9.0.v201106031100-77078CcNBHCBYKYEbNV
org.eclipse.datatools.sqldevtools.feature - 1.9.0.me201203170059
org.eclipse.emf - 2.7.0.v20110606-0949
org.eclipse.gef - 3.7.0.v20110425-2050-777D-81B2Bz0685C3A6E34272
org.eclipse.graphiti.feature - 0.8.0.v20110607-1252
org.eclipse.jpt.jpa.feature - 3.0.0.me201203170059
org.eclipse.jpt.jpadiagrameditor.feature - 1.0.0.me201203170059
org.eclipse.jst.common.fproj.enablement.jdt - 3.3.0.me201203170059
org.eclipse.jst.enterprise_ui.feature - 3.3.0.me201203170059
org.eclipse.jst.server_adapters.ext.feature - 3.3.0.me201203170059
org.eclipse.jst.server_adapters.feature - 3.2.100.me201203170059
org.eclipse.jst.server_ui.feature - 3.3.0.me201203170059
org.eclipse.jst.ws.axis2tools.feature - 1.1.200.me201203170059
org.eclipse.m2e.feature - 1.0.0.me201203170059
org.eclipse.wst.common.fproj - 3.3.0.me201203170059
org.eclipse.wst.server_adapters.feature - 3.2.100.me201203170059
org.eclipse.xsd - 2.7.0.v20110606-0949
org.springframework.ide.eclipse.feature - 2.7.1.me201203170059


com.thoughtworks.twist - 2.4.0.12641-3bffc171c71291
fr.obeo.acceleo.bridge.feature - 2.6.0.200906261742
org.eclipse.cvs - 1.3.100.v20110520-0800-7B78FHl9VF7BD7KBM4GP9C
org.eclipse.draw2d - 3.7.0.v20110425-2050-46-7w3122153603161
org.eclipse.equinox.p2.core.feature - 1.0.1.v20110906-1605-8290FZ9FVKHVRKtmx3fpNuo02129
org.eclipse.equinox.p2.extras.feature - 1.0.1.v20110906-1605-7A4FD4DiVOMap8cHSc6vPuny4gqO
org.eclipse.equinox.p2.rcp.feature - 1.0.1.v20110906-1605-782EqBqNKGVkiV-PUsgz-uny4gqO
org.eclipse.equinox.p2.user.ui - 2.1.2.R37x_v20110815-1155-6-Bk8pYWZz0qUTX5I15GZWwbXkrl
org.eclipse.help - 1.3.0.v20110530-0844-7i7uFFmFFl8nvqbDpEqTvx
org.eclipse.jdt - 3.7.2.v20120120-1414-7z8gFcuFMP7BW5XTz0jLTnz0l9B1
org.eclipse.jsf.feature - 3.3.0.me201203170059
org.eclipse.ocl - 3.1.0.v20110606-1427
org.eclipse.pde - 3.7.2.v20120120-1420-7b7rFUOFEx2Xnqafnpz0E--0
org.eclipse.platform - 3.7.2.v20120207-1839-9gF7UHPDFxGjd-PqDr2jX_4yKaumkoHTz04_q-q
org.eclipse.rcp - 3.7.2.v20120120-1424-9DB5FmnFq5JCf1UA38R-kz0S0272
org.infinitest.eclipse.feature - 5.1.101
org.tigris.subversion.clientadapter.feature - 1.6.12
org.tigris.subversion.clientadapter.javahl.feature - 1.6.17
org.tigris.subversion.subclipse - 1.6.18


Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-showsplash
-launcher
C:\Program Files\Genuitec\Profiles\MyEclipse 10.1\myeclipse.exe
-name
Myeclipse
--launcher.library
C:\Program Files\Genuitec\Profiles\MyEclipse 10.1\../../Common/plugins/org.eclipse.equinox.launcher.i18n.win32.win32.x86_4.2.0.v201201111650\eclipse_4201.dll
-startup
C:\Program Files\Genuitec\Profiles\MyEclipse 10.1\../../Common/plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
-install
C:\Program Files\Genuitec\Profiles\MyEclipse 10.1
-configuration
C:\Program Files\Genuitec\Profiles\MyEclipse 10.1\configuration
-vm
C:\Program Files\Genuitec\Common\binary\com.sun.java.jdk.win32.x86_1.6.0.013\jre\bin\client\jvm.dll
 
 View user's profile Send private message  
Reply with quote Back to top
optimad
Post subject:   PostPosted: Apr 14, 2012 - 09:47 AM
Veteran Member
Veteran Member


Joined: May 04, 2005
Posts: 16

Hi

I've created a mini-project to test this and have discovered that if I direct my src/scratch/java to "test-classes" in the classpath, it fails (NoClassDefFoundError). If I direct to the default ''classes", it works. If I direct to "scratch-classes" the compiled classes do go there, but I still get NoClassDefFoundError.

1) What is controlling this and is there any way around it?

2) Should I even care? We're using Maven to build our artefacts/deployments so the Eclipse compilation & deployment directories are probably irrelevant.

3) In that case, should I just direct my test/java and test/resources to "classes" too?

Thanks for your help.

Matt
 
 View user's profile Send private message  
Reply with quote Back to top
support-joy
Post subject:   PostPosted: Apr 17, 2012 - 08:32 AM
Registered Member
Registered Member


Joined: Feb 03, 2009
Posts: 3442

Matt,

I am afraid, we could not replicate your issue here. Please explain how are you trying to execute the application and which class has the static main method. I need to see the full stack trace message to investigate. Please copy and paste the same here.

_________________
Joy
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
optimad
Post subject:   PostPosted: Apr 17, 2012 - 08:43 AM
Veteran Member
Veteran Member


Joined: May 04, 2005
Posts: 16

Hi Joy,

I've posted the test project I created.

I was using Right-click (on the class), Run as, Java Application.

This then gives this in the console:

java.lang.NoClassDefFoundError: test/test/AppScratch
Exception in thread "main"

Matt
 
 View user's profile Send private message  
Reply with quote Back to top
optimad
Post subject:   PostPosted: Apr 24, 2012 - 07:47 AM
Veteran Member
Veteran Member


Joined: May 04, 2005
Posts: 16

Hi Joy,

Any news on this?

I'm not sure I can give you any more info. Is there anything missing that you need?

Regards

Matt
 
 View user's profile Send private message  
Reply with quote Back to top
support-tony
Post subject:   PostPosted: Apr 24, 2012 - 11:12 AM



Joined: Mar 09, 2011
Posts: 915

Matt,

Sorry for the delay in responding. We had been looking at this but didn't complete our investigation.

We could replicate the problem, with your test case (thanks). The problem also occurs with the m2eclipse plug-in, which provides the base functionality for our maven support. It seems that extra output folders are ignored for maven projects, though not for standard Java projects. I've raised a bug report for this.

However, in your case, as you use maven as your primary build tool, you can work around the issue in the way you suggest, by directing the output for scratch classes at the default output folder (target/classes, in the case of the test project you provided). You can also create a run configuration, for the class you wish to execute, and add the scratch-classes folder to the classpath, in that configuration.

I notice that the pom in your test project makes no reference to the extra source folder, though the first pom you posted did. I'm not sure that referencing it would make any difference but, presumably, you wouldn't normally include scratch classes in your production pom.

I hope this helps and sorry for the inconvenience.

_________________
Tony
MyEclipse Support
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits