Eclipse and Tomcat: Unable to start a War project - eclipse

My eclipse setup for web project worked before. But all of the sudden it stops working.
Eclipse version Build id: 20100218-1602
It is a very standard setup. I have a servers project setup in eclipse. I have defined an tomcat server in it. I was able to run my web project this way.
Suddenly for some reason today I saw this exception:
org.springframework.beans.factory.CannotLoadBeanClassException:
Error loading class [some.company.persistence.dao.hbm.ProductDaoImpl]
for bean with name 'productDao' defined in class path resource [SomeDB.xml]:
problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/orm/hibernate3/support
/HibernateDaoSupport
Based on the message above, can anyone suggest what may be broken?

Looks like the hibernate library is missing from the project's classpath. Figure out which one of the spring jars contains HibernateDaoSupport and add it to your project's classpath.

Related

Walkthrough the spring source code

I wanted to walkthrough the spring code. For that I cloned the code and built it using ./import-into-eclipse.sh command. There are some instructions given in README.md file for checking out source in eclipse.
After following above instructions I was able to see the spring code in my eclipse workspace. To refer the spring source from my project I added all of spring projects (like spring-beans, spring-aop etc) in my project's Java build path. I was able to use spring code in my project.
Now the issue is that whenever I run the test cases in my project, I get initialization error. I removed spring projects from my java build path and junit test started working.
I tried to dig into the issue. For that I tried to run some of the test cases of spring projects itself like BeanUtilsTests.
but I got:
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
I verified that classpath is set:
Don't know what is the issue. Can someone please tell me that what I did wrong.
Is there any better way to view/edit spring code?
Usually the below error,
Class not found org.springframework.beans.BeanUtilsTests
java.lang.ClassNotFoundException: org.springframework.beans.BeanUtilsTests
occurs when the corresponding jar is missing in the classpath. Since you have already added the spring-beans jar manually, I suspect you are using an incompatible version of the spring-beans jar with your spring-boot.
You can check the Maven repo Spring Beans to check the compatible version. But I would suggest using a dependency management tool like Gradle or Maven to include the required dependency jars. Spring-Boot Gradle file

Hibernate configuration with tomcat and eclipse

I'm creating a webApp in eclipse using tomcat & hibernate (for mysql). Ive unit tested by code and I am able to connect to the db and pull data, but I'm running into issues when trying it from the web app.
From the exception it looks like it isnt able to get to the hibernate.cfg.xml, but I've tried placing the file in the src folder, WEB-INF/lib & WEB-INF/classes but I still get the same error.
The line of code that it's failing on is:
Configuration configuration = new Configuration();
I would really really appreciate any help!
ClassPath References:
Project References:
Stacktrace:
java.lang.ExceptionInInitializerError
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
root cause
java.lang.NullPointerException
org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
org.hibernate.cfg.Environment.<clinit>(Environment.java:221)
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
SOLUTION
Thanks to #Engineer, I was able to solve this by removing the jars from WEF-INF/lib & from the class path of the run configuration. Then I added them back using the "Deployment Assembly" menu in eclipse. I also have my project references here.
From Ranga Reddy:
Problem: Because of adding the jars in user library class path.
Solution: Instead of adding the jar files using User Library add the jars using classpath.

JPA persistence.xml META-INF placement folder

I currently have my persistence.xml located in src/main/resources/META-INF/persistence.xml. Also I am using eclipselink 2.4 as my JPA 2.0 implementation.
After publishing to the server and trying to run the app in the browser I get the following error:
Exception: : java.lang.IllegalArgumentException: No persistence unit named 'X'
is available in scope Webapp. Available persistence units: [] at
This is ONLY when building in Eclipse. Leaving META-INF on the path src/main/resources/META-INF/persistence.xml and performing maven install to build the war file, the META-INF folder is correctly placed in WEB-INF/classes/META-INF/persistence.xml like it should be (inside the war). Seems that it is only and issue of when the webapp is built and ran locally in Eclipse. Can anyone explain this?
Can anyone explain what the problem is? Maybe someone has ran into this problem before?

Getting error while running the Web Application?

I am creating a Dynamic web project. I have made a home JSP file and kept a button on this JSP page. When I click on this page then it calls the HelloServlet where I am accessing the Cassandra DataBase. I have added all the required Jars file to the project . But when I click on the button on the JSP page some exception is coming which is given here
HTTP Status 500 - Error instantiating servlet class cassandra.HelloServlet
type:- Exception report
message:- Error instantiating servlet class cassandra.HelloServlet
description:- The server encountered an internal error that prevented it from fulfilling this request.
exception:-javax.servlet.ServletException: Error instantiating servlet class cassandra.HelloServlet
............
root cause:- java.lang.NoClassDefFoundError: org/apache/thrift/transport/TTransport
........................
root cause:- java.lang.ClassNotFoundException: org.apache.thrift.transport.TTransport
......... ............
Also , I am able to perform my job when I am creating a simple Java project using the same code and same Jars.
Looking for Help!
You have added the jar files in the project build path. This path is used to compile your application, but it's different from the runtime classpath. At runtime, the container looks for libraries in the WEB-INF/lib directory of the deployed webapp.
Under Eclipse, the libraries that must be present at runtime under WEB-INF/lib must simply be dropped in the folder WebContent/WEB-INF/lib of your web project. Eclipse automatically adds these to the build path and adds them to the WEB-INF/lib directory if the deployed app, so that they're available also at runtime.
So, remove all the cassandra jars from your build path, and drop them in WebContent/WEB-INF/lib. Once done, they will appear under the Web App Libraries node of your project.

JBPM workflow deployment into alfresco error

I'm getting the following error when deploying from JBPM eclipse interface to alfresco. This happens when I select 'classes and resources to include in process archive', like 'src/main/java' etc.
Exception happened while deploying
java.lang.NullPointerException
at org.jbpm.gd.jpdl.util.ProcessDeployer.addClassOrResource(Unknown Source)
It was working perfectly, just stopped working suddenly. Any clues?
Thanks.
You should try not selecting anything in the Java Classes and Resources pane. You should be able to deploy your process definition XML file. If you have Java classes specific to your process definition, just have your build script JAR those up alongside your other Alfresco related Java classes you may have and put those in WEB-INF/lib.