I'm creating a JSF Web Application using Eclipse and suddenly i got a java.lang.ClassNotFoundException when i deployed my app on the Tomcat Server. I was confused why this happened because all my build path libraries that i had added worked without any problem.
But then i checked the deployed .war file to see whether all my .jar's were there. And to my surprise it wasn't there. And it was the case for java.lang.ClassNotFoundException i received. Then i tried adding other libraries. Non of them were copied to the deploying .war file source. But i could use them in my workspace.
Then i created a new project and copied all the sources from my previous. And then it worked fine. It copied everything to the .war file.
But then i had to use another library and i added it to the build path. Then the same issue was raised. That jar file was not copied to the .war file. And anything i added or if i remove something that already worked and add it again, it stops working because those files will also no be copied to the deploying war.
Is this a an Eclipse bug or is there a Configuration that limits the use of libraries? Any JSF configurations? Can anyone help me on this?
I'm using Tomcat 8, JSF 2.2 with Primefaces 5.1
Related
I'm trying to add JSTL support to an spring boot application, but I'm getting this error message when running it from within eclipse:
The absolute uri: [http://java.sun.com/jsp/jstl/core] cannot be resolved in either web.xml or the jar files deployed with this application
If i generare an executable war and run it, JSTL works correclty.
I've tried almost all the solutions described in the other questions but none of it seems to focus on running it from eclipse.
I've created this tiny repo to demostrate it:
https://github.com/rroman-encora/brokenjstl
This is my setup:
Spring Boot 1.5.7
Eclipse Version: 2021-03 (4.19.0)
JDK 11.0.11
The project runs with source and target java 1.8
Thankyou
If another poor soul finds him self in this situation, may this be the answer:
Just copy all the *.tld files from the jstl jar inside your WEB-INF directory and this should work.
Obviously there's a "proper" way to do this, maybe it's just a setting on spring boot, maybe you need to configure the embedded tomcat/jasper TLD Scanner, but today I'm so tired to keep looking for the perfect aswer.
BTW this also keeps working if you deploy your application as an excecutable war.
i have written an application on my pc using CDI as the backing bean for jsf, the application works completely fine.
Now i setup everything on a new pc, installed glassfish 4.1, setup eclipse kepler by putting the installed jre as jdk7 from the glassfish folder.
when i make a war for the application on my pc and deploy it onto the glassfish server on the other pc everything works fine.
now i tried taking the project from my pc and imported it onto the new pc. the eclipse on the new pc wont recognize import javax.enterprise.context.SessionScoped; giving compiler error that this annotation is not available.
The import javax.enterprise.context cannot be resolved
it doesnt recognize javax.enterprise.context.* at all. like CDI is not available. i am using JDK 7 which contains JSR 346, so i am completely confused what the issue could be.
if i deploy the application directly through the glassfish admin console using the war file it works perfectly fine but if i try to publish it through eclipse, it gives me unresolved compilation errors
Eclipse did not import ALL glassfish jars, so you need to:
Right Click on the project name, Build Path, Configure build path, under Libraries Click Add External Jars, go to where you have extracted Glassfish and import all jars that exists in:
glassfish4\glassfish\modules
and all sub directories two, like endoresed.
This will fix the problem for CDI and other stuff lik JAX-RS
If I had to guess, your .project and .classpath files are pointing to JAR locations that are specific to your old computer.
This is why people like build tools such as maven, or gradle, you can pick up and reimport a project; it'll resolve all dependencies for you.
Do you happen to use the GlassFish Tools plugin for Eclipse? I found that the GlassFish System Libraries classpath container, which is created implicitly by that plugin and which is added to all projects that specify a GlassFish server as their runtime, misses cdi-api.jar. This is where the javax.enterprise.context.* package is located (and many others).
So I could fix this by adding cdi-api.jar as an External Jar to the build path. After that, you may get a warning like Classpath entry [...]/cdi-api.jar will not be exported or published. Runtime ClassNotFoundExceptions may result., which can be eliminated by using the Quick Fix to Exclude the associated raw classpath entry from the set of potential publish/export dependencies. That JAR file is already contained in the modules folder of GlassFish, obviously.
Maybe this problem only occurs with the GlassFish Web Profile, at least that's what I use.
I got the error NoClassDefFoundError when trying to deploy the EJBCA API in my JSF project. When I deploy it in a simple java project, all goes fine with simple classes and JARs imported in the Java Build Path, but in the JSF that not happens.
I tried to copy the jars that I want from EJBCA folder and put in MyProject\WebContent\WEB-INF\lib and nothing happened.
What must I do?
I'm trying to build a hello world application utilising GCM for Android notifications. When developing the server part, I'm not entirely sure how to get the gcm-server.jar file into the project. I've added it to the build path and Eclipse finds it perfectly fine, but when I build and deploy the project to a tomcat server (from within eclipse) it's throwing the following error at runtime:
java.lang.NoClassDefFoundError: com/google/android/gcm/server/Sender
I'm assuming I'm doing something wrong when importing the jar. What exactly is the procedure for getting a jar into a dynamic web project using Eclipse?
Going to answer my own question because I just got it working.
Turns out adding the .jar's to the Java build path is not enough. Tomcat has a seperate classpath for each project, and won't see the classes in the jar unless you dump the jar files into the WEB-INF/lib folder (which Eclipse does not do automatically).
You need to include the jar file for json. This question seems to have been repeated a few times.
http://code.google.com/p/json-simple/downloads/detail?name=json-simple-1.1.1.jar
I'm serious when I say have been all over the internet and on google for past few hours trying to find an answer to this question. Ok, I have already coded and compiled a working wicket in Eclipse. It runs in Eclipse just fine but I now need to export this to my webserver. How do I do this!? It's such a simple concept and yet no one has talked about it. I know I need tomcat, but they don't say how to export the files. If a JAR file works. If I need to configure Tomcat is some way. How to get this to work with an already running web apache server. My guess is that tomcat has to be running to execute the java portion of the wicket and then you can just point a link to your index.html. But I have no idea. Enlighten me please with a step-by-step tutorial? I'm a slight beginner with Eclipse and started using Tomcat and Wicket only 2 days ago.
Its preferable to pack your project into a war file distribution.
An easy approach to do that, is to use Apache Maven for building it.
For Maven there are plenty of plugins available, one of them is a "war" plugin, which helps you creating your war / web archive.
The war file you have simply to put into the webapp of a fresh downloaded tomcat.
There's a couple ways but one way is you can compile to a .war file and deploy from the admin console in tomcat. See here for the tomcat documentation.
In Eclipse, right click your web application project, select Export -> War File and follow the wizard.
When you have your .war file ready you can then upload it to a Tomcat or Glassfish installation.