Suddenly a NoClassDefFoundError when running Glassfish from NetBeans - netbeans

I have been working on a demo project all day and everything went just fine.
Suddenly (and, as it seems, unrelated to any of my actions) my application fails with a NoClassDefFoundError somewhere in the CDI internals. Strangely it worked before but I just cannot get it to work again.
I am using a rather fresh NB 6.9.1 install without any modules. I launched my Java Web application simply by clean+build and then run menu items.
The non-default setup is this:
I added two JARs from the Jersey project to the Library folder of my project:
jersey-bundle-1.5-SNAPSHOT.jar
jersey-view-client-1.5-SNAPSHOT.jar
I removed the restlib libraries added by Glassfish.
I set class loader delegate to false in sun-web.xml:
as described by the Jersey docs.
That all worked fine up to a sudden point.
Can anyone provide a clue where I could at least start investigating?

The same thing (everything works until NoClassDefFoundError emerges) happened to me once in a while on other projects as well.
The solution is to remove .netbeans/6.9/var/cache and restart NetBeans. I suspect that the culprit is corrupted index for NetBeans' custom classloader.

Took me some time, but here is the best way I see to solve the problem: http://www.nordsc.com/blog/?p=574

Related

Eclipse, maven, tapestry, tomcat auto load

I'm running eclipse mars EE. I have a maven project with tapestry 5.4.1. I have tomcat 7 maven plugin and everything is working fine except I'm not able to immediately see changes to tml and css files. When I make a change to any file it's eventually reloaded but it takes time which slows development. I want to be able to see css and tml changes instantly. I can wait for java changes until tomcat reloads them but I can't wait for css and tml changes.
I've read several articles on configuring the tomcat server within eclipse including this stackoverflow entry
However, they don't seem to work or achieve what I want. It seems the issue lies in the fact that tomcat has to wait for a new jar/war to be created and deployed instead of pulling the files directly from the project.
Also, I'm aware of Tapestry's class reloading feature....which doesn't seem to work either. Perhaps my project isn't configured correctly? Here is a screen shot of my project
There MUST be a way to accomplish this. We've all been writing web apps for tomcat in eclipse for 15 years!
Thanks for your help!
It sounds like you may have several issues that are described in the "Troubleshooting Live Class Reloading" section at the bottom of the https://tapestry.apache.org/class-reloading.html page. Please read the Tomcat-specific help at http://www.tynamo.org/Developing+with+Tomcat+and+Eclipse/ if you haven't already.

Running jersey 2 server using jetty 9

I have been struggling for many hours on trying to deploy a simple HelloWorld webservice written in java on a windows 7 (later ill need on linux) pc.
Most of the examples I found (from general places, and others questetions on stackoverflow) didn't work or used deprecated versions of jersey and other librarys.
My goal, is to write a webservice in java, where coding it should be easy and so does deploying it. It doesn't need to suuport anything special regarding the amount of request running and performance (my requirements are minimum)
Frommy research, I have come to believe the use of jersey with embeded netty web service should anser what I was looking for (if someone knows better, I would also like to hear about it, tough it isn't my main problem in this questetion but might just be an alternative solution)
I have came across this eaxmple:
jersey2-jetty-example
It gives you a working project with the dependencies needed from maven to run jersey and jetty embedded server (which can be run as a standalone jar which is exactly the kind of easy deploy im looking for)
I cloned the example and got everything running. I had problems importing it to eclipse, so I used the following command on the example folder:
mvn -DoutputDirectory=./lib dependency:copy-dependencies
which will give you a copy of the lib folder of the deps from maven needed,
then I created a java project with this lib folder in the build path and same source code as the sample, and all worked good.
The problem occurs when I try to take this java project and export it as an runnable jar (with the source files included option !).
I can then use java -jar to run the service, but when I try to access it from the browser (same as used in when I run it from eclipse), it never works, im always getting error 404 for the same routes that worked a second ago when running from eclipse. I couldn't figure out whats the source of the problem or what eclipse does differently that makes it behave in a different fashion.
I have found the reason the jar didn't work while in eclipse it did work, it was because of a duplicate jar that I was importing the caused the problem. The jars I got from maven in the git sample had 2 duplicate jars called hamcrest-all and hamcrest-core. removing one of them from the project build path fixed the problem.
If someone can answer the other open ended questetion that I asked, which is if using jersey and jetty like this is the best solution for my requirments I will be happy to hear about it

Glassfish + PostgreSQL, ClassNotFoundException, mysterious solutions

I have a very annoying problem with Glassfish and PostgreSQL. I have an EAR which contains a WAR and several other EJBs. I am using PostgreSQL. The annoying thing is that sometimes (this sometimes is the most disturbing thing because I have no clue what could go wrong) I get a ClassNotFoundException: java.lang.ClassNotFoundException: org.postgresql.core.Parser
Sometimes (!!!), the problem is solved if I clean and build the whole EAR, sometimes I have to restart the Glassfish, too.
I sometimes get NoClassDefFoundError, too.
Could anybody tell me how to include, package or do anything with the JAR which contains the missing class?
Thank you,
Norbert
Where do you put the jar: directly inside the EAR? Or in the WAR inside the EAR? For JDBC drivers, I think the recommendation is to always put them in the container's shared area and never in an application. (When I used JBoss a couple of years ago, we always put JDBC drivers into server/lib and had trouble if they were included in EARs as well, especially if the versions got out of sync)

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 :(

Getting Error when deploying on Tomcat

I have already compiled my application, when I am running it in web
mode from Eclipse everything is working perfectly fine, no error at
all. In my project, i'm using several libraries such as hibernate. All
libraries have been correctly been placed on the classpath as well as
in the lib folder in web-inf.
however when i'm deploying it on tomcat, i'm getting several problem,
first no data is being loaded from database. I was using a lib for
capcha at http://www.javacodegeeks.com/2010/06/add-captcha-gwt-application.html. That also is not working well
I am also trying it on Jetty with the same problem
Can someone please help, i've got to deploy this system??
Be sure to include all required libraries in your /war/WEB-INF/lib folder
Yes, it was a problem of lib, whenever deploying your app on the server, make sure that u have the required libs that r on your classpath in the folder webinf/lib.