Tagged: myeclipse dependencies
- This topic has 9 replies, 2 voices, and was last updated 5 years, 2 months ago by Brian Fernandes.
-
AuthorPosts
-
rickhParticipantHi. My code dies. It can’t find the class it needs.
I don’t know Java all that well. Either the caller shouldn’t be looking for it at net.sf.ezmorph.Morpher, or I should supply Morpher at that location.
I have edited my library list, and re-inserted the ezmorph library. But it didn’t make any difference.
I thought MyEclipse was supposed to work out these details for me.
What am I doing wrong?
Oct 11, 2019 9:49:22 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [GetModels] in context with path [/EFM] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at com.aaa.rap.fleet.GetModels.doPost(GetModels.java:36)Rick
Brian FernandesModeratorRick,
It’s likely that the dependencies haven’t been added in the right way. However, before we can provide further assistance, we need to know more about what you are actually doing:
1) What sort of project is this – a Java EE Web project? Is it a Maven based project (are you managing dependencies through Maven)?
2) What sever are you deploying to? From the stack trace, I’m assuming Apache Tomcat – if so, which version?
3) When & where do you see this error? When the server is starting up, in the Console?
4) What version of MyEclipse are you using? Please see Help > About for the build Id.
5) Can you share details on how and where you’ve edited the library list – a screenshot would help as well.Thanks!
rickhParticipantHi, Brian. Answering in order.
1) What sort of project is this – a Java EE Web project? Is it a Maven based project (are you managing dependencies through Maven)?
I would say that’s exactly what it is. A Java EE Web project. A server runs at a port, and if you go to a certain localhost url, it shows you a Web page. The browser (Javascript) communicates with the server using Ajax. (My background is C++ servers and Javascript single-page applications.)
2) What sever are you deploying to? From the stack trace, I’m assuming Apache Tomcat – if so, which version?
It says “MyEclipse Tomcat v8.5”
3) When & where do you see this error? When the server is starting up, in the Console?
No. It runs fine, until I try to open a certain drop-down. Then, in the doPost method in the server, it tries to do this:
JSONObject responcedata = new JSONObject();
and that’s where it fails. I guess ezmorph must be involved in the JSONObject constructor.
4) What version of MyEclipse are you using? Please see Help > About for the build Id.
MyEclipse Enterprise Workbench
Version: CI 2018.9.0
Build id: 16.0.0-201809035) Can you share details on how and where you’ve edited the library list – a screenshot would help as well.
Ah. I am embarrassed by this part. There were some red x’s. We are constrained to use Java 5. I took two steps:
[1] I tried to activate the Maven dependencies piece, thinking Maven could sort it out for me. Still red x’s.
[2] I copied the .classpath from a project that didn’t have red x’s. That eliminated the red x’s.
But it failed at runtime.
I am including a screenshot of the project facets, as well as the java build path, because I have a feeling it might matter. Note that I have unchecked Maven Support – Dependencies Only.
Regards, Rick
- This reply was modified 5 years, 2 months ago by rickh. Reason: Mis-spelled .classpath as .classlist
Attachments:
You must be logged in to view attached files.
rickhParticipantMy colleague checked to make sure all the jars actually appear in the directory that tomcat uses. We made a couple corrections, but no joy.
Brian FernandesModeratorRick,
Thank you for the details. Maven can help, but you do need to know at least a bit of Maven and configure the project correctly.
Here’s a quick suggestion:
1) Shut down the server and undeploy the project.
2) Remove all the JAR files from the Libraries tab and apply this change.
3) In your project, there will be aWEB-INF/lib
folder. Physically copy all those library files into this folder. MyEclipse will automatically add them to the build path, so your project should compile fine. If you still see Red X’s … that would mean that you’re still missing some libraries and you shouldn’t bother with deployment until you resolve this.
The benefit of copying the JARs to thelib
folder is that this will also ensure that the libraries are deployed to the server correctly.
4) Deploy the project and start the server.Hopefully this will resolve the issues you are now facing, please let me know if this works!
rickhParticipant* * * * Making notes about what I did. * * * *
Brian Fernandes wrote:
Rick,
Thank you for the details. Maven can help, but you do need to know at least a bit of Maven and configure the project correctly.
Here’s a quick suggestion:
1) Shut down the server and undeploy the project.
“undeploy” Found an Add and Remove dialog. Removed EFM.
2) Remove all the JAR files from the Libraries tab and apply this change.
I left all the directories at the bottom untouched. I just removed the jar files, in the top level.
3) In your project, there will be a WEB-INF/lib folder. Physically copy all those library files into this folder. MyEclipse will automatically add them to the build path, so your project should compile fine. If you still see Red X’s … that would mean that you’re still missing some libraries and you shouldn’t bother with deployment until you resolve this.
Copied them. Will check dialog.
Dialog was empty. Shutting down and re-starting MyEclipse.
No. Jars are not there.
I will attach screenshots to this message.
Please advise.
The benefit of copying the JARs to the lib folder is that this will also ensure that the libraries are deployed to the server correctly.
* * * * * Didn’t get past this point. * * * * *
4) Deploy the project and start the server.
Hopefully this will resolve the issues you are now facing, please let me know if this works!
Attachments:
You must be logged in to view attached files.
Brian FernandesModeratorRick,
Looks like you copied them to the right location. In case you did this externally, could you right click the
WebRoot
folder and click Refresh to ensure MyEclipse sees them too? Inside the IDE, you should be seeing them under the lib folder.The JARs won’t appear at the top level like before, they should appear under the, “Web App Libraries” node which you have collapsed. After doing the above, do expand that node and see if they’re present.
rickhParticipantThat seems to have solved my problem. Thank you!
Now I have a problem with my other two projects. (Which were fine, but oh well.) I’ll apply the same technique.
Can you tell me what we did? :^) The internal records didn’t match the external reality, so we rebuilt the internal records?
Or did something else happen?
Thanks again, Rick
Brian FernandesModeratorRick,
Happy to know those steps helped!
I’m not sure what state your project was in, but essentially you had set up the project in a way that only the IDE knew that a number of JAR files (libraries) were required for the project to compile, and so you saw no errors in the IDE. On deployment though, when your project is transferred to the server, the libraries were not transferred over and so it would cause the application to fail at runtime.
The changes I suggested require you to copy the libraries into the project, in a location that’s specific to where libraries are expected for a Java EE web application. MyEclipse has smarts to detect these libraries and also make the corresponding build path changes so that the IDE is aware of them as well – fulfilling both the IDE as well as the server (or Java EE specification) requirements.
For small projects, one-off changes, and projects which do not share too many libraries, this is just fine. However, if you have a large number of project, a large number of JARs or shared libraries, you could look at Maven as essentially a ‘better’ way of doing things.
Hope this helps!
Brian FernandesModeratorCan you tell me what we did? :^) The internal records didn’t match the external reality, so we rebuilt the internal records?
I realize now you may have been talking about the explicit refresh actions. Yes, Eclipse has its own file system model and if you make changes outside Eclipse, you may need to tell Eclipse to refresh and see if there are new changes to be picked up. If you go to Preferences > General > Workspace, you can check the “Refresh using native hooks or polling” to avoid having to do this.
-
AuthorPosts