This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version: NetBeans IDE 7.0.1 (Build 201107282000) Java: 1.6.0_25; Java HotSpot(TM) Client VM 20.0-b11 How to reproduce: File|New Project|Samples|Java Web|Servlet Stateless (Java EE 6)|Next|Finish Server is GlassFish 3.x Project Window|ServletStateless|Run This works ok. File|New Project|Java|Java Class Library|Next|JavaLibrary1|Finish Project Window|JavaLibrary1|Source Packages|new|Java Package|test Project Window|JavaLibrary1|Source Packages|test|New|Java Class|TestClass public static String getString(){ return "TestString"; } Project Window|JavaLibrary1|Build Menu|Tools|Libraries|New Library|TestLibrary Classpath|Add Jar/Folder|<your project folder>JavaLibrary1\build\classes|OK Project Window|ServletStateless|Properties|Libraries|Add Library|Test Library|Add Library|OK In project ServletStateless, edit StatelessSessionBean Replace return "Hello, " + name + "!\n"; with return TestClass.getString() + ", Hello, " + name + "!\n"; Fix imports. Project Window|ServletStateless|Run java.lang.ClassNotFoundException: test.TestClass
I created a web app/library project that I targeted at tomcat using similar steps. I ran into the same result. So, it probably isn't a server-plugin/run-time issue. I think the web app project's build breaks an assumption about the content of a web-apps WEB-INF/lib directory. There are supposed to be jars under WEB-INF/lib... I see a directories and class files under PROJECT/build/web/WEB-INF/lib when I follow these steps. So, it seems like it is a web-app project issue. The fix is to create the library based on the JAR resulting from the build of JavaLibrary1 project instead of build directory of the javaLibrary1 project. The problem seems to be the result of poor error checking when the web-app project is building. There is a work-around... so this really isn't a p1.
The library manager tool lets me build a library with either jar files or class file directories. A web project lets me attach a library that by extension has either jar files or class file directories. So if the convention for the lib directory of the web project is that it must contain only jar files not class directories then the build process for a web project could create the jar files and print a warning that it does this because it slows down the build process.
Alternatively, classes from libraries could be copied to the WEB-INF/classes directory, which I think happens if simple jar files are added to the project libraries.
A more detailed description of a scenario where classes in Libraries are not found: In project ServletStateless, create a directory " classes" in the project directory. Extract into the classes directory the jar file from the NetBeans installation: C:\Program Files\NetBeans 7.0.1\enterprise\modules\ext\jsf-1_2\commons-collections.jar Add the classes directory to libraries: Project Window|ServletStateless|Properties|Libraries|Add JAR/Folder|Add classes directory Add to StatelessSessionBean: ArrayStack arrayStack = new ArrayStack(); Run the project, submit query. java.lang.NoClassDefFoundError: org/apache/commons/collections/ArrayStack In the Files window, expand the project. In my case, there are only empty directories (see attached gif file) Deploy the project. In my case, this copies the classes and submit works.
Created attachment 110541 [details] Empty classes package tree
Thanks. Valid issue. Workaround is to add directly classes folder to classpath instead of using library. f2d4a7403ef9
Integrated into 'main-golden' Changeset: http://hg.netbeans.org/main-golden/rev/f2d4a7403ef9 User: David Konecny <dkonecny@netbeans.org> Log: #201785 - Web App does not find Library Classes