0

I am new with JSFUnit testing (with Netbeans7.3, JSF2.1, JDK7) and I was wondering if there a way where I can add the classes from my Main project into my JSFUnit project, well I was told to separate my JSFUnit project from the main one.

I have tried Properties/Libraries/Add Project, but it cause an error stating that the project cannot be added since it's not created using an Ant Script.

I have added the Main's classes into the properties->Libraries->Add Jar/Folder of JSFUnit project, but during the runtime the classes cannot be found which resulted to this error in the localhost ServletTestRun:

biz/dtit/geenie/controller/AccountController

java.lang.NoClassDefFoundError:
ebiz/dtit/geenie/controller/AccountController
.
.
.
Caused by: java.lang.ClassNotFoundException: biz.dtit.geenie.controller.AccountController
.
.
.

. . . Caused by: java.lang.ClassNotFoundException: biz.dtit.geenie.controller.AccountController . . .

van
  • 139
  • 2
  • 1
    I don't do Netbeans, but in Eclipse it's just called "Add project", not "Add JAR/Folder". Think about it, projects are not the same as JARs/Folders. They are very definitely not JARs and with Folders is usually meant a folder containing class files in their package hierarchy like the `/build` folder. – BalusC Jul 26 '13 at 11:35
  • Yes, I had also tried "Add Project" to my JSFUnit test Libraries but it shows error as: "This project cannot be added because it does not produce a jar file using an Ant script". Sorry, type error in my Question above. Instead of "Properties/Libraries/Add Folder", it should be "Properties/Libraries/Add Project" – van Jul 26 '13 at 18:08

1 Answers1

1

I have just found a way to add classes to another web project and it worked on my side. First, is to create a .jar file of your main project's classes and add it to your JSFUnit's project properties. You can't create a .jar file for a web project using netbeans IDE, so locate your build.xml from your project's folder and add this:

<target name="-post-compile">
<jar destfile="${basedir}/dist/my_web_app.jar">
    <fileset dir="${basedir}/build/web/WEB-INF/classes">

    </fileset>
</jar>

van
  • 139
  • 2