0

I am still trying hard with my project for my internship and I have another problem this time, and since I am pressed with time (I haven't finished the work but no time left) I can't help but ask for your help here, again. Thank you. So, I have two projects, one to make an electronic certification of a file and the other is a web project that uploads the file. In this one (the web project) 1 upload jsp page, 1 servlet and 1 message page. I want to use the classes of the first project in the servlet, I have added the proper imports and I added the project 1 in the "project references" of the web project and the two projects worked greatly separately (I made simple tests of uploading and certificating and they both worked fine). It's just that after uploading the file successfully I want to sign it using the 1st project but I get an exception:

exception 

javax.servlet.ServletException: L''exécution de la servlet a lancé une exception

cause mère 

java.lang.NoClassDefFoundError: tn/ance/signature/chargement_fichierp12
    servlets.UploadServlet.doPost(UploadServlet.java:197)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

Any help would be greatly appreciated! thank you so much ^^

here is my configuration for both projects (project 2 which is a web project uses project 1 (signature_) in its servlet)

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

TaoRin VVHL
  • 51
  • 1
  • 8
  • 1
    The servlet can't find the 'chargement_fichierp12' class. Make sure that that class is in your [classpath](https://docs.oracle.com/javase/tutorial/essential/environment/paths.html) and the servlet uses the right name for the class. Also make sure the class exists before you try to use it. – F. Stephen Q Aug 30 '15 at 23:01
  • @FSQ that class is in the 1st project and I made the proper imports of all that project (import tn.ance.signature.chargement_fichierp12; import tn.ance.signature.signature_doc;) it exists and it works (I made some tests and used the same code in the servlet, but when I use the same code in the servlet it doesn't work) – TaoRin VVHL Aug 30 '15 at 23:21
  • 1
    @TaoRinVVHL Just to clarify, @FSQ specifically mentioned the class path which is not the same thing as an `import` statement. Did you modify the class path to run your program? – fdsa Aug 30 '15 at 23:35
  • @fdsa you mean in the project properties? if yes I added it :/ – TaoRin VVHL Aug 30 '15 at 23:58
  • what is project 1 and project 2, are they both **.war** or is project 1 a **.jar** – sgpalit Aug 31 '15 at 09:25
  • @sgpalit they are both simple projects under eclipse no war or jar, except that project 2 is a web project – TaoRin VVHL Aug 31 '15 at 09:41
  • If you export project2 as a war, (open with archiver like 7zip) exists there in WEB-INF/lib directory project1 as a jar? If not then it means that you did not successfully set your project build path where you add project reference. Can you check it? – sgpalit Aug 31 '15 at 09:46
  • @sgpalit project 2 is not exported as a war :/ (i thought war is for web projects (?)) under WEB-INF/lib there's only web.xml. as for the project 1 that i want to use in project 2, it does not have WEB-INF/lib folder since it's not a web project – TaoRin VVHL Aug 31 '15 at 10:02
  • I think your environment is not set correctly, you schould provide in the question your project structures and the IDE you are working with. Every web application can be exported as .war, which is the final output that you will deploy on production. – sgpalit Aug 31 '15 at 10:33
  • @sgpalit I screen capped everything and edited my answer! Isn't the .war file only created after the whole project is complete? The web project still needs to use the 1st project so I can't make a .war right now. btw thank you for being patient and answering my questions. – TaoRin VVHL Aug 31 '15 at 10:53

1 Answers1

0

Eclipse exporting JAR in WAR

Here is explained how you can add the project to your deployment assembly.

Right-click on the root node of the dynamic web project, and select Properties, and select Deployment assembly. Here you can add projects (which are jarred up and added to WEB-INF/lib) and individual jars in the project.

Community
  • 1
  • 1
sgpalit
  • 2,676
  • 2
  • 16
  • 22
  • I did exactly as you said but it didn't work :/ I put the jar of the Signature_ project under WEB-INF/lib of Web project, and added the project in Deployment assembly. (under Deployment assembly, when I add it doesn't look like a jar file but only a simple project Signature_ appears, so I put the jar file under WEB-INF/lib manually) – TaoRin VVHL Aug 31 '15 at 11:38
  • You do not need to add the jar manually, please remove it and just add it from deployment assembly. I think you have to add **lib.zip** manually to your lib folder inorder to let signature work in the webapp. – sgpalit Aug 31 '15 at 11:39
  • so I removed it (to create the jar file i only need to right click on the project then export then runnable jar file right? cause 'jar file' only didn't work previously) umm what is lib.zib where do i find it? :/ I am really really thankful for your patience and sorry for bothering you T.T – TaoRin VVHL Aug 31 '15 at 11:45
  • you have added it to your Signature_ project, under T:\Stage exists your lib.zip... – sgpalit Aug 31 '15 at 11:47
  • also, not adding the jar manually won't add it just by the Deployment assembly method :/ – TaoRin VVHL Aug 31 '15 at 11:48