I'm getting the following errors:
javax.servlet.ServletException: Error instantiating servlet class auth.Login
and
java.lang.NoClassDefFoundError: javax/persistence/Persistence
How do I ensure my project's configuration is properly setup?
To me, this look correct.
I assume that java.lang.NoClassDefFoundError: javax/persistence/Persistence is the root cause of the servlet instantiation error, so we can just ignore the servlet instantiation error for now. A NoClassDefFoundError means that the class mentioned in the message was present in the webapp's compile time classpath, but not in the webapp's runtime classpath.
Those JARs which you have there in /lib folder should actually go in /WEB-INF/lib. This is part of the webapp's runtime classpath. Further you should also remove those three jsp* and servlet* JAR files. They do not belong in the webapp library. They belong in the servletcontainer library. If you did this to fix compile errors, it has to be fixed differently.
I think runtime classpath does not have servlet-api.jar and that is causing java.lang.NoClassDefFoundError: javax/persistence/Persistence
Secondly as said earlier your libraries should be under WEB-INF/lib folder to fix the errors
Related
The projet work fine in tomcat localhost but when I upload it in a remote tomcat I get this bug :/ , I have the jar that contain the ImageReaderFactory class in classpath, I didn't understand what can be the problem,
I cleared the /tomcat/work/Catalina/localhost folder but always the same bug : java.lang.NoClassDefFoundError
07-Oct-2019 23:06:25.584 SEVERE [http-apr-8080-exec-267] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [UploadServlet] in context with path [/MyServer] threw exception [Servlet execution threw an exception] with root cause
java.lang.NoClassDefFoundError: org/dcm4che3/imageio/codec/ImageReaderFactory
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.setMetadata(DicomImageReader.java:794)
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.readMetadata(DicomImageReader.java:713)
at org.dcm4che3.imageio.plugins.dcm.DicomImageReader.read(DicomImageReader.java:452)
at com.project.dicomserver.UploadServlet.getFrameIcon(UploadServlet.java:86)
....
Does anyone have any ideas?
image
There is a bunch of things that could be go wrong in your specific case. So answering with the best of my knowledge. Make amendments, by adding as much details as possible, to the question and we can help you further.
Every application in tomcat needs to have a specific folder structure. The folder structure is documented here. In short, war files must be deployed into $CATALINA_BASE/webapps/ directory.
So if your application is "myapp", then there must be a $CATALINA_BASE/webapps/myapp directory.
Inside $CATALINA_BASE/webapps/myapp directory, we need to have WEB-INF. Not $CATALINA_BASE/webapps/myapp/WebContent/WEB-INF, but $CATALINA_BASE/webapps/myapp/WEB-INF ! And the case matters.
If this is not how your application is deployed into a vanilla tomcat, it will not work properly. Read the official documentation
Now about your development environment, see whether your eclipse configurations have been modified. The Export As War options can be modified at multiple locations and all of them can have impact on the war file you have generated. When in doubt, I look at this link
Use a build tool like maven or gradle. These tools bring standards for compiling, archiving, testing and deploying applications and makes you worry less on environment related issues.
EAR package is deployed to WAS8.5.5.7. UI can display. However, when UI tries to trigger Java function, I get below response.
Error 404: javax.servlet.UnavailableException: SRVE0203E: Servlet [rrbapp]: org.springframework.web.servlet.DispatcherServlet was found, but is missing another required class.
SRVE0206E: This error typically implies that the servlet was originally compiled with classes which cannot be located by the server.
SRVE0187E: Check your class path to ensure that all classes required by the servlet are present.SRVE0210I: This problem can be debugged by recompiling the servlet using only the classes in the application's runtime class path
SRVE0234I: Application class path=[/opt/WebSphere85/profiles/appprofile/installedApps/wascell/abcapp.ear/cn-abc-web-app-1.0.0.war/WEB-INF/classes:
/opt/WebSphere85/profiles/appprofile/installedApps/wascell/rrbapp.ear/cn-abc-web-app-1.0.0.war/WEB-INF/lib/cn-abc-domain-1.0.0.jar:
/opt/WebSphere85/profiles/appprofile/installedApps/wascell/rrbapp.ear/cn-abc-web-app-1.0.0.war/WEB-INF/lib/cn-abc-db-object-1.0.0.jar:
/opt/WebSphere85/profiles/appprofile/installedApps/wascell/rrbapp.ear/cn-abc-web-app-1.0.0.war/WEB-INF/lib/cn-abc-web-1.0.0.jar:
/opt/WebSphere85/profiles/appprofile/installedApps/wascell/rrbapp.ear/cn-abc-web-app-1.0.0.war/WEB-INF/lib/commons-logging-1.2.jar:
....
It looks to be a Jar dependency error, have you tried running mvn clean install, it should resolve your issue.
Run this command and try redeploying again
After adding "slf4j-log4j12" jar in my package, it can work without this error. I think the reason is, log can not print without this jar in server, so the program stop at the beginning.
2 jars in WEB-INF/lib of Websphere 8.5.5.5 are having same directory structure
org.json.* .
json.jar Compiled withJDK 1.6
commonlib.jar compiled with JDK 1.7
Iam receiving below exception during the JVM startup in one environment while another environment has same jars and same classpath but there its working properly. WAS is running Java 1.6 due to which getting UnsupportedClassVersionError
6/23/16 15:59:32:091 CDT] 0000005e InjectionProc W CWNEN0047W: Resource annotations on the fields of the jmaki.xhp.XmlHttpProxyServlet class will be ignored. The annotations could not be obtained because of the exception : java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=org/json/JSONObject, offset=6
When i specifically add the second jar to the class path of the second environment it gives the above error, otherwise it works properly Is it due to the classpath order?
class load: org.json.JSONException from: file:/hosting/configs/WebSphereD24/AppServer/installedApps/nodea/sear/swar/WEB-INF/lib/json.jar
class load: org.json.JSONObject$Null from: file:/hosting/configs/WebSphereD24/AppServer/installedApps/nodea/sear/swar/WEB-INF/lib/json.jar
How does WebSphere decide the jar to load the class=org/json/JSONException from . This class is present in both the jars... How come its loading from json.jar in one and common.jar in another.
The order of WEB-INF/lib JARs is unspecified, so the order will typically be defined by the file system. You should remove duplicate classes rather than trying to rely on any particular order.
While running the application I was getting the following errors.
java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis2.description.AxisService
AxisService class is in axis2-kernel-1.6.2.jar file. Some of the classes from this jar are working fine without any issues, but some classes are throwing NoClassDefFoundError from this jar file at runtime. AxisService class is present in axis2-kernel-1.6.2.jar, even it throws error.
This is working fine in local machine. But error getting in Oracle r12 server.I have already set the class path for the jar file.
I am Using Java version is 1.6 and Apache axis2.1.6.2.
Had the same issue. I had included only jars that I needed to compile the application.
When I included everything from \axis2-1.6.2\lib\ folder, this exception were gone.
I had a similar problem using Tomcat and Axis2 and after a week finding out the error I realized there was a axis configuration problem. especifically my aplication can't instantiate the class which accedded to persistence layer. I include this parameter line:
<parameter name="ServiceTCCL">composite</parameter>
in services.xml file which is used by axis2 to work.
For more information see the comments in http://wso2.com/node/1131
When I login in facebook using code as shown in Facesbook API Example in a servlet then get the following exception:
javax.servlet.ServletException: Servlet execution threw an exception
root cause
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
com.google.code.facebookapi.FacebookXmlRestClientBase.<clinit>(FacebookXmlRestClientBase.java:26)
FaceBookCrawl.FacebookUserFilter.doFilter(FacebookUserFilter.java:85)
FaceBookCrawl.FacebookUserFilter.doPost(FacebookUserFilter.java:161)
javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
How can I solve this?
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
This means that the particular class is missing in the runtime classpath.
To fix this, you just need to put the particular class (or actually, the JAR file with the particular class) in the runtime classpath. As the package name already hints, you can download the JAR file at http://commons.apache.org/logging. Put the JAR file in webapp's /WEB-INF/lib folder, it's part of the webapp's runtime classpath.