adding a Main JSF project's Classes to another JSF project's Properties/Libraries

543 Views Asked by At

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 . . .

1

There are 1 best solutions below

0
On

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>