I am trying to deploy a WAR file on weblogic server.
This is a simple java application.
I am new to this and experimenting.
JRE: 1.5.0_41, OS: redhat 5.8, Weblogic: WebLogic Server 10.0 MP2
The contents just include a jsp file and a java file (jsp inside jsp folder and java class inside WEB-INF\classes folder and correct package structure). I am using this java util file inside the jsp for some common utility methods.
However, when I deploy the WAR, it gives me NoClassDefinitionFoundError for this java utility class.
I have searched the threads and found that this exception points to some other inherent issue in the deployment. It also mentioned class path conflicts etc. I can understand this issue when it comes to using a class from an external JAR file, but could not understand how it fails to locate a file in the same context as that of the jsp.
How come the import statements in the jsp worked and the jsp got compiled and rendered and failed only when the part of accessing this object came into picture? (runtime problem maybe?)
Please educate me on this. My debugging efforts are still on. Thanks a lot, folks!!
[P.S.: Could it be because i compiled and built my source using eclipse setting 1.7 compliance and used it on a lesser JRE?]
For a war file classes is normally packaged inside WEB-INF/classes, not classes.
Related
I'm developing an enterprise project with Liferay 6.1 EE and tomcat 6. Coding is in local PC, but deploy to a CentOS virtual machine.
There's a custom .jar file to handle some special logic with URL redirecting. After I modified a Java class, recompile and built the new .jar, replaced the existing .jar file on the vm. (located in {$tomcat}/lib/ext and {$tomcat}/webapps/ROOT/WEB-INF/lib) and restarted tomcat, I found it was still using the previous code logic. I'm sure that the .jar file was updated on VM (grabbed from VM, and decompiled the .class, the code was there)
This class is instantiated by Class.forName().newInstance method, and put to a static final map in another custom filter.
Clearing {$tomcat}/temp and {$tomcat}/work folders didn't help, is it possible that this stale class is cached in JVM ? If yes how can I remove the stale content ?
Any insight is appreciated.
I am trying to use opencv 2.4.9. in a Java Servlet with NetBeans, i have two files - the first one is a Servlet java file Login.java which is called by index.html , and the second one is CamCap.java a java file with all the opencv imports but this file is in the same package, am calling a function of second java file from the first one. The two files run fine separately as java project but when I try to run the complete servlet project it throws this Error - (java.lang.NoClassDefFoundError: org/opencv/core/Core)
How to resolve this!!?
You need to make your OpenCV jar available to both the IDE as well as the application server. I believe you've already made it available to your IDE by adding it to your web project's classpath.
Now to satisfy the dependency when running on the application server too, just copy the jar to your web project's /WEB-INF/lib directory, build your war and deploy it again.
I suggest you to always copy your dependency to /WEB-INF/lib first, and then adding it to your project's classpath. This takes care of such errors and also makes sure that both the IDE and the application server are using the same version of the jar.
I'm having trouble getting a simple Java servlet to run under tomcat7 (fresh install from ubuntu repository).
It is a single .java file with #WebServlet("/TestServlet"). I put it into /var/lib/tomcat7/webapps/TestServlet/WEB-INF and would like Tomcat to recognize and automatically compile it (also, when I change the source file). How do I set this up in a simple way?
You have to compile your code using java compiler (or IDE). Then deploy *.class file(s) under servlet container (Tomcat in your case).
The class file must be under your WEB-INF/classes directory. If you class belongs to package like com.myservlet and its name is HellowServlet put it into file /var/lib/tomcat7/webapps/TestServlet/WEB-INF/com/myservlet/HelloServlet.class
EDIT:
if you indeed want make tomcat to compile your servlet, write JSP. This is a key feature of JSP: it can be deployed as a source code and is compiled automatically to servlet by container.
Use Eclipse IDE and click "Add Server" to add TomCat server. It will work directly
I have IVR -Java application deployed on caucho Resin server
Web App is not in server but directory outside on same system. Also Jsp are getting compiled in external directory.
In eclipse I have source code when I launch debugger I am able to connect and I am able to debug through java classes but when control goes to jsp file it is not able to find source
Any idea how i can fix it.??
Maybe that's because eclipse can't find the source. Have you tried adding that to the build path? Project -> properties search for build path.
If the source requires a different language to run, Jsp (i've never dealt with that), then perhaps you can get a plugin for eclipse for that language (jsp) and then add the jsp source to a (eclipse) project that houses the jsp section of the whole project.
Edit: seems like since I haven't messed with JSP much, I gave the wrong advice. Follow the link in the comment below.
As we know, when the jsp got complied it will get converted to servet.
I have installed weblogic server 9.2, and i deployed a struts project which has jsp files.
And in the browser i am able to see the application.
Now I want to see the servelt file of jsp which I ran.
Can anybody please tel me where I can find it
or do i need to do some configurations for this because I searched whole weblogic directory there is no java file with the jsp file name.
If WebLogic is compiling JSP (i.e. if you are not precompiling them), they should be located under domain_name/servers/server-name-1/tmp/_WL_user.
See also
Using JSP Precompilation in WebLogic
I was struggling with this today and found another option. If you deploy your application via eclipse (and not via EAR file using the weblogic console) the compiled JSPs will be in <workspace>\.metadata\.plugins\org.eclipse.wst.server.core\tmp<some digit>\<domain name>\work\<app name>\jsp_servlet.
For Weblogic 10.3.6, the folder is this.
C:\oracle\MIDDLEWARE\user_projects\domains\APPNAME\servers\myserver\tmp_WL_user_appsdir_APPNAME_dir\\jsp_servlet_jsp_content
You can also check the <working-dir></working-dir> section in the weblogic.xml file to check for the location of jsp_servlets folder where the .java and .class files can be found.
You can trick the weblogic into recompiling the jsp files by deleting the existing ones, and try and access the jsp page from browser (in case lazy initialization is being followed).