You really do not have to open the netbeans project. However you can. Does anyone know why when I comple the jsp's can not find the bean because the class file is in the build/classes file and not the src file. Does it not need to be there? Or I need to have it put there . Any Help ?
Thanks

Dani AI

Generated

Short answer: the JSP/servlet container does not load classes out of your IDE's internal build folder — it loads them from the webapp runtime classpath: WEB-INF/classes (for loose .class files) and WEB-INF/lib (for JARs). NetBeans compiles sources into build/classes during development, then copies those into the exploded webapp or WAR when you Run/Clean+Build. If the deployed webapp does not contain your bean under WEB-INF/classes (or in a JAR under WEB-INF/lib), the JSP will throw ClassNotFoundException.

Concrete checklist to fix the bean-not-found problem:

  • Always give beans a package (avoid the default package). The package declaration dictates the directory under WEB-INF/classes.

  • Verify the deployed layout. After building or deploying, confirm a path like:

    WEB-INF/classes/com/example/beans/MyBean.class

    and that your JSP refers to the fully qualified class name:

    <jsp:useBean id="b" class="com.example.beans.MyBean" scope="page" />
  • If you prefer jars, package the classes into my-beans.jar and place that jar in WEB-INF/lib.

  • Let NetBeans do the deployment (Run Project) or deploy the generated WAR; copying .class into the IDE src is wrong and will be overwritten.

Troubleshooting tips: do a Clean and Build, then inspect build/web/WEB-INF/classes or the WAR in dist/. Check server logs for the exact ClassNotFoundException, confirm package and case-sensitivity, and restart the servlet container after changing classes. As observed, seeing .class in build/classes is normal — just ensure those compiled files end up in the deployed WEB-INF/classes (or inside a JAR in WEB-INF/lib). pointed toward placing compiled output where the webapp classloader can see it; the correct locations are WEB-INF/classes (for classes) or WEB-INF/lib (for jars).

Recommended Answers

All 3 Replies

Member Avatar for Member #46692

Why should we download a zip file that may contain anything from someone with only one post?

Try posting your source codes...

Why should we download a zip file that may contain anything from someone with only one post?

Try posting your source codes...

Is there someone that can show me what I need to do to get the classpath set to put compiled classes in a certain place?

Drop the compiled classes in the /WEB_INF/lib folder. If they have a package structure you will need to duplicate that under the lib folder.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.