ClassNotFoundException: com.itextpdf.text.Element - eclipse

Situation: I have a Java file in my project that uses the features of the iTextPDF library. The project compiles properly. I use JDK 1.7, Tomcat 7.45 and Eclipse Neon.3 Release (4.6.3).
Problem: While starting the server via Eclipse, I get an error:
java.lang.ClassNotFoundException: com.itextpdf.text.Element
What I've tried so far:
Ensured that only 1 version of iTextPdf 5.4.jar is available in the entire project. It's there in WEB-INF/lib folder. It's not there in any of the externally referenced libraries.
I updated my Eclipse.
Any help will be greatly appreciated.

Well, as a starting point- try and expanding the JAR, and see if you can search for or manually find com.itextpdf.text.Element class.
if it's not found there, you know there's nothing wrong with your eclipse or project settings, and nothing wrong with your jar imports.
You should then determine between 3 options:
Is the JAR even on the classpath? it's possible everything is present there, but the project does not even consider looking in it.
Should this class be in the JAR? is it available on other versions of this JAR?
Is this class neccesasry for you application? why is eclipse looking for it, where in the code it is referecened? can you live without it? or, can you manullay replace it with a class file you can find online? (this will take some debug time, and some more research on your part)

Related

Define a Java 9 multi-moduled project in Eclipse

I'm trying out Java 9 Jigsaw module system (no module experience yet) and would like to use it for capsuling the classes within my project, but it's confusing.
According to this article it should be possible to have multiple modules within ONE project. I made a new project in Eclipse Oxygen (Java 9 is supported) with the same structure as shown in the article. But Eclipse keeps telling me that I must not have more than one module-info.java in a project.
I really don't know how to tell Eclipse that it should use the "multi-module-mode". And I really would appreciate not having to create a new project for every single module.
This works:
This not:
But according to this article something like that should work:
And how about deployment of a modularized project with Eclipse? There is nothing to see about the new jmod extension. Do I still export it as a runnable JAR file like before?
Notice that my questions refer to working with the IDE (no command line, I mean with an IDE that should be possible, right?) Thank you for enlightening me.
Currently, Eclipse requires you to create a separate project for each module (e. g. because each module has its own Java Build Path).
To understand this design decision, consider that Java modules correspond to OSGi bundles / Eclipse plug-ins and it has always been to have a separate project for each bundle/plug-in. If you come from the Maven world, you would probably expect a deeper folder structure instead. But modules are self-contained and combining several modules into one project would only add an additional folder level without meaning. However, Eclipse supports nested projects and so-called working sets if you need an additional folder level.
Exporting modules as images is planned for Eclipse 2019-03 (4.11), on March 20, 2019 (see Eclipse bug 518445). Exporting modules as JARs that can be used on the modulepath (-m) already works (see my video).
I don't know if this question is still open for an answer, but you can solve this problem by simply removing all source folders on the build path. At least this works for Eclipse 2021-12 version.
As you can see this is a demo project from the Official Gradle Guide Book and it has multiple modules. Each module has its own module-info.java.
project structure in IntelliJ IDEA
If I open this project in Eclipse it will give me the 'duplicated entries on module-info.java' error.
Eclipse shows the error
But if I delete all the source folders on the build path, the error is gone and the project can be built and run without problem.
project properties: Java build path
The only problem is that you have to build the project with Gradle so that it will produce the .jar of each module and you have to include them in the libraries later.
include all the .jar in libraries
I think this is probably the same solution mentioned by howlger above.

Kotlin And Java In The Same Project Using Eclipse IDE

I posted a similar question regarding gradle but this question is without gradle or maven.
I can not get Kotlin working properly using Eclipse IDE. This works great using IntelliJ, however many developers still use Eclipse. I have installed the Kotlin Eclipse plugin and does not work. I have downloaded the Kotlin standard library and runtime library and added them into the project. Still not working. All I get in eclipse when I have Java and Kotlin is cannot be resolve to a specified type.
I'm not using maven or gradle because I couldn't get it working with those two either.
If I mix Java and Kotlin in the same source folder I get this error.
"The type error.NonExistentClass cannot be resolved. It is indirectly referenced from required .class files"
I'm using Eclipse Neon. If anyone can help me that would be awesome, I've been trying for quite some time now and not getting anywhere. :(
Add Kotlin Nature fixes the issue. Click on your project and Configure
Kotlin -> Add Kotlin nature
This partially fixes the issue, though eclipse plugin is still buggy and auto import function still doesn't work for me.
If you're having any issue, make sure you have kotlin_bin folder added in your project. Also make sure that ALL kotlin files have the correct package name sometimes when you rename packages or move files around kotlin classes may not get updated.
Got similar issue solved by adding a new Kotlin file to a Kotlin/Java mixed project. Adding the file caused Eclipse 2018-09 (4.9.0) to add kotlin-stdlib.jar and kotlin-reflect.jar to classpath and everything started working.
Add Kotlin Nature fixes the issue. Click on your project and Configure Kotlin -> Add Kotlin nature
As of the current Eclipse version (2019-09):
You can't add Kotlin to a Java project, but you can add Java to a Kotlin project.
The procedure to accomplish a mixed Kotlin/Java project was roughly:
Install Kotlin plug-in
Create empty Kotlin project
Move the Java code into the Kotlin project
Delete the original project
Fix project references
I'm working on a project with Spring Boot and Kotlin (some controllers/mappers/classes in Java and others in Kotlin) and after trying a lot of approaches, the only that worked was to use Eclipse 03-2020 and Kotlin Plugin for Eclipse V0.8.19.
https://dl.bintray.com/jetbrains/kotlin/eclipse-plugin/0.8.19/
Before everything, close your project and uninstall the previous version of Kotlin Plugin for Eclipse.
Go to Help/Install New Software.
Copy the link of Eclipse Plugin and continue with the installation (do not forget to check all the options to install).
After the installation restart the IDE and try compile again.
If your project was like mine, it has .kt files in /src/main/kotlin, some missing references in Java. I tried compiling them but nothing worked. It turns out that my project didn't have an Eclipse Source Folder associated with the kotlin code. There were the usual ones for "src/main/java", "src/main/resources" but not one for "src/main/kotlin".
So, I created a source folder for the kotlin files.
Right click the project
New "Source Folder"
Specify folder name: "/src/main/kotlin"
This doesn't create anything in the file system but just creates a logical container for Eclipse to work with the contents. In this case, Eclipse recognized the .kt files, compiled them and all the missing references issues all cleared up.

Vaadin on Netbeans -- which jar?

i'm looking to use Vaadin on Netbeans 8.
I installed the Vaadin plug-in on Netbeans.
Followed the instructions on https://vaadin.com/wiki/-/wiki/Main/Getting+Started+on+NetBeans.
The jar i'm using is vaadin-all-7.3.8.
I assigned Tomcat to the project.
However - com.vaadin isn't recognized for all what it has in the environment-- com.vaadin.ui and com.vaadin.Application aren't seen.
I'm getting checked errors to
import com.vaadin.Application;
and
import com.vaadin.ui.*;
, but not to
import com.vaadin.*;
What more do i need for Vaadin on Netbeans??
TIA.
//=======================
EDIT:
Pls note: Saw Using Vaadin on NetBeans WITHOUT Maven along with some other discussions.
Also note: We're looking to avoid Vaadin-on-Maven. have already had issues with that one as well.
Be sure to read the readme in the zip file that tells you which jar files you need to include in your project:
Copy all vaadin-* files except vaadin-client and vaadin-client-compiler to WEB-INF/lib in your project
Copy lib/*.jar to WEB-INF/lib in your project
Copy vaadin-client and vaadin-client-compiler to a lib folder which is on your classpath but will not be deployed. These files are only needed when compiling a module (widget set) to Javascript.
What issues did you have with maven? Typically I would recommend using a dependency management tool to make upgrades easier in the future.

Eclipse + JBoss - some JAR files not deployed

I have an Eclipse Indigo installation with a JBoss 6 server managed by it. I have a Maven project with a few modules. These modules all build just fine from the command line.
One of the modules is an EAR. This is dependent on two JAR modules and a couple of WAR modules. When I package the EAR from the command line (mvn clean package), the EAR contains all the necessary JAR and WAR files. However, when I deploy it from Eclipse, the two module JAR files are missing from JBoss. The WAR files are just fine. Inside the "Add and Remove..." dialog the JAR files are also present, but not when deployed. I've checked JBoss' deployments folder and there they are indeed missing. The strange thing is, with the exact same POMs and code, all of my colleagues with the same(?) setup don't have this problem.
The two JAR modules are listed in the dependency management part of the parent POM. They are also listed as dependencies in the EAR POM. Still, Eclipse refuses to deploy them with the EAR.
Does anybody have any idea how I can solve this issue? I can manually package and deploy the EAR, but 1) that takes longer, and 2) I can't use Eclipse's debugging functionality this way.
Note: previously asked at http://www.coderanch.com/t/580959/vc/Eclipse-JBoss-some-JAR-files
Right mouse button on project -> Maven -> Update project
I experienced the exact same issue, different eclipse (Eclipse Mars, WildFly 8.1 ).
The unsettling part was that I didn't change anything in the code or in the IDE (that I am aware of) and it started malfunctioning.
I suspect it has something to do with the cached memory of eclipse for it's plugins, anyway, after many hours of trying different things we fixed it by deleting the folder .eclipse under your user in windows.
Seems silly, but we tried everything except that, and that thing did the trick
I'm encountering a similar issue, however my environment is much, much simpler - being a web project, with a utility project. Not using maven at all and deploying to tomcat7.
The class file is not being deployed to the web-inf as expected, although the utility project is referenced, and marked as to be exported.
However with your issue, I came across this post:
http://blog.frankel.ch/better-maven-integration-leads-to-unforeseen-consequences-bugs#comments
which might provide a clue. Hope this helps.
I had the same issue. I didn't modify my code at all, I deleted all the projects from the work space, closed eclipse and reopened it. Then I did a clean and build of the project (which took much longer than before). This time when I went to add the EAR project, it had all the dependencies listed and actually worked.

Where to put the User Library for Eclipse-Dali-Hibernate integration?

I am struggling with the configuration of the Eclipse Dali plugin and Hibernate. The version I'm using is as recommended:
Eclipse 3.6.1 (Helios SR1) IDE for Java EE Developers (including Dali 2.3)
JBoss Tools 3.2 (for the Hibernate Tools plugin)
When configuring the Java Persistence properties for my project, I created a user library named "Hibernate JPA" and included the following JARs:
hibernate-distribution-3.6.1.Final\hibernate3.jar
hibernate-distribution-3.6.1.Final\lib\jpa\hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-distribution-3.6.1.Final\lib\required\dom4j-1.6.1.jar
hibernate-distribution-3.6.1.Final\lib\required\slf4j-api-1.6.1.jar
hibernate-distribution-3.6.1.Final\lib\required\javassist-3.12.0.GA.jar
hibernate-distribution-3.6.1.Final\lib\required\commons-collections-3.1.jar
hibernate-distribution-3.6.1.Final\lib\required\antlr-2.7.6.jar
hibernate-distribution-3.6.1.Final\lib\required\jta-1.1.jar
As long as the hibernate-distribution-3.6.1.Final folder is outside of my project directory, everything works fine. However, if I put the Hibernate folder into the project directory, I get an error saying "Required class org.hibernate.SessionFactory does not exist in selected libraries":
The error text is wrong, the required class is definitely included in hibernate3.jar, and everything works as expected when I move the JARs outside of my project directory.
I have two questions about that:
I do not understand why the User Library behaves differently depending on whether the JARs are placed inside or outside of my project directory. Could anybody explain what's happening here?
I would like to have my project in SVN, including all the required libraries. Is there any way to configure Dali to accept User Libraries within the project directory?
Thank you very much.
I was having the same problem cos I forgot to add hibernate-jpa-2.0-api-1.0.0.Final.jar.
The only difference is that I'm using 3.5.1-Final cos 3.6.x seems not stable at the moment.
Actually, I'd prefer EclipseLink: everything works fine as a charm. I've wasted many hours with environment configuration :( Last time I've used Hibernate was years ago and looks like troubles to configure still are the same :(