The first screenshot shows a working run configuration. The second shows a non working one. They are identical module/classpath wise - at least according to the visible info.
Clearly there's a bug in IJ for this. So .. how have others of you out there discovered a workaround for this? Also, ideas on what triggers this behavior?
WORKING run configuration
NOT Working run configuration - gives ClassNotFoundException for org.apache.hadoop.fs.PathFilter
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.fs.PathFilter
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
Here is the UDFPafDqm module - which DOES include hadoop jar from Hortonworks - so the ClassNotFoundException is bogus
The process above was repeatable : if you copy a run configuration it does not necessarily work - and can fail as described. You have to start from scratch. This is an IJ bug.
Related
I am trying to do my first test-automation with Spock.
I do not want to use maven.
I am using eclipse java EE oxygen 4.7.
I have created a groovy project.
I have added the Spock jar as an external library in the build path configuration.
Spock ist Spock-core-1.1-groovy-2.4.
I have also added geb jar the same way.
However, I am getting this strange error from the automatic build, which I do not understand and I am seeking for help. So far I haven't found anything helpfull.
General error during semantic analysis: Transform org.spockframework.compiler.SpockTransform#xxxx cannot be run org.codehaus.groovy.GroovyException:
Transform org.spockframework.compiler.SpockTransform#xxxx cannot be run at
org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:416) at
org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:972) at
org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at
org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609) at
org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586) at
org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:217) at
org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:613) at
org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:879) at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:141) at
java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoClassDefFoundError: Unable to load class org.spockframework.runtime.ErrorCollector due to
missing dependency org/junit/runners/model/MultipleFailureException at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:397) at
org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:353) at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:981) at
org.codehaus.groovy.ast.ImmutableClassNode.getDeclaredMethods(ImmutableClassNode.java:105) at
org.spockframework.compiler.AstNodeCache.(AstNodeCache.java:65) at org.spockframework.compiler.SpockTransform$Impl.(SpockTransform.java:
52) at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:47) at
org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:395) ... 9 more
My code is as simple as you can get. This is the code:
//The error is on the "p" letter of package
package hellowworld
class HelloWorld{
static main(args) {
}
}
Please note that this error only happens when I add Spock jar. The closest question was Spock without maven or gradle, but obviously the problems are different.
I just cut the file from the package directory pasted it out side and then recut pasted in the package back. It worked well and I have no idea why.
This is one of those problems which occasionally arise in Eclipse and most people just won't know why!
The thing to do usually is to try several "strategies" and hope that one will work. If not you have to come back to SO and try to enlist the support of an expert.
One tip: in my experience sometimes it is worth trying "Refresh Gradle" and "Build all" more than once. Not only that, but sometimes trying either of these actually then seems to do nothing... but a couple of seconds later the horrid x in the red box then vanishes like morning mist!
Highlight/select the project in Project Explorer --> right-click --> Gradle --> Refresh Gradle Project
Put cursor in a code file open in the editor, press Ctrl-B (Project --> Build all)
Close all files in editor, close Eclipse and start up Eclipse again
Try the above in various combinations
Reboot and then try the above in various combinations
If this fails to cure it you may need to turn to SO.
I am trying to execute some Java with the Maven exec plugin, and am getting an error Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: my.biz.CoolEntity. I tried a number of failed solutions, before ultimately finding a hacky fix. Based on the hacky fix, I believe the issue to be a runtime classpath error.
I am looking for an answer that will tell me how to address the problem without resorting to copying the needed files into place, as I do in the hacky fix.
Background
I have a Maven project "Project A" which has dependencies upon Hibernate 5.0.1.Final as well as another project "Project B". Project B contains my JPA entity classes, including my.biz.CoolEntity.
Normally, I build everything into a shaded JAR and run/deploy that, without any issues.
Hibernate issue
Recently, I began using Maven's exec:java goal, but am running into what on the surface is a Hibernate issue. when I run mvn exec:java -DmainClass=my.biz.CoolEntity, I get this error:
Caused by: org.hibernate.UnknownEntityTypeException: Unable to locate persister: my.biz.CoolEntity
at org.hibernate.internal.SessionFactoryImpl.locateEntityPersister(SessionFactoryImpl.java:792) ~[hibernate-core-5.0.1.Fi
nal.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.locateEntityPersister(SessionImpl.java:2641) ~[hibernate-core-5.0.1.Final.jar:5.0.1
.Final]
at org.hibernate.internal.SessionImpl.access$2500(SessionImpl.java:164) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2579) ~[hibernate-core-5.0.1.Final
.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2566) ~[hibernate-core-5.0.1.Final
.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.byId(SessionImpl.java:1044) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:955) ~[hibernate-core-5.0.1.Final.jar:5.0.1.Final]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:1075) ~[hibernate-entitymanager-5.
0.1.Final.jar:5.0.1.Final]
Failed attempts
I tried making use of the exec plugin's <additionalClasspathElements> and <includePluginDependencies>. The first solution didn't result in any different, and the second resulted in a compile-time error.
Hacky fix
What ended up working for me was copying the compiled classes from Project B into Project A.
Try changing the imports from "javax" to "jakarta". I had the same issue and mine worked when I made the change.
When the entities are residing in a different jar, you have to include it in persistence.xml. <jar-file>entities-packaged.jar</jar-file>. Different options are explained here
When we use Hibernate 5 jars, then we get
org.hibernate.UnknownEntityTypeException: Unable to locate persister".
I just changed the hibernate jar versions from 5 to 4 and then everything was fine.
Hibernate 5 does not locate the entity classes even after mapping.
I too got the same exception and it was due to missing the entity annotation #Entity for the class. Please check if the #Entity annotation is available in your class
I'm struggling with getting Eclipse to recognize my logging configuration when I quick run tests from within Eclipse (Alt + Shift + X, T), or by running from the Run Configurations. I really don't care all that much about logging from the tests per se, but really just providing the configuration so that any log statements executed will not fail.
Failed to instantiate [ch.qos.logback.classic.LoggerContext]
Reported exception:
java.lang.NoSuchMethodError: ch.qos.logback.core.util.Loader.getResourceOccurrenceCount(Ljava/lang/String;Ljava/lang/ClassLoader;)Ljava/util/Set;
at ch.qos.logback.classic.util.ContextInitializer.multiplicityWarning(ContextInitializer.java:160)
at ch.qos.logback.classic.util.ContextInitializer.statusOnResourceSearch(ContextInitializer.java:183)
at ch.qos.logback.classic.util.ContextInitializer.getResource(ContextInitializer.java:141)
at ch.qos.logback.classic.util.ContextInitializer.findURLOfDefaultConfigurationFile(ContextInitializer.java:130)
at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:144)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:123)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:337)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:287)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:309)
I have logback-test.xml in src/test/resources, and have configured that as a source folder with an output of target/test-classes.
I even took at shot at editing the Classpath of the Run Configuration for JUnit for my project, and added the test-classes folder there, and it didn't help.
Is there something simple that I'm missing? I don't seem to recall having this issue in the past with other projects.
I checked my pom.xml, and logback-classic didn't have a specified version, and logback-core did. I set a property for the version and set them both to be the same.
I have done more than an hour of searching while trying to run JUnit on my project. I can see that there is a class missing - LogEntryFormatter. But no matter how hard I tried, I am not able to find the jar file which contains this one. Eclipse shows the below stack trace after running the Test case file.
java.lang.NoClassDefFoundError: weblogic/logging/LogEntryFormatter
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClass0(ClassLoader.java:892)
at java.lang.ClassLoader.loadClass(ClassLoader.java:302)
at java.lang.ClassLoader.loadClass(ClassLoader.java:300)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at weblogic.logging.commons.LogImpl.(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.(SpringJUnit4ClassRunner.java:91)
...
When I use #RunWith(SpringJUnit4ClassRunner.class) and if I use #RunWith(JUnit4.class), a sample test seems to work.
Any sort of help will be useful. I am using WebLogic server, and all weblogic related jars are available on the classpath.
Ok, so after a lot of effort I am able to run JUnit Tests, although not in the exact way I want. I am also at a loss to explain why this is happening or where weblogic.logging is configured. This could be a possible problem with my project setup. After adding the following jar files to the classpath (after removing everything except jdk), it seems to be working for me.
wlclient
com.bea.core.utils.classloaders
com.bea.core.descriptor
com.bea.core.utils
com.bea.core.management.core
junit 4.5
Thanks to all those who helped by providing valuable comments. The stack traces encountered at each step helped me point in the right direction.
I have a Java (6) application which uses Hibernate (V3.3.2) to read data from HSQLDB, which i build and debug/run with Eclipse (V3.5.1), and it works fine.
I then created a GWT (V1.7) Servlet web app, copied my hibernate classes into it, and added the same User Libraries dependencies. However when i run the servlet and try to access a URL which invokes my code i get this:
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
at xxx.daoimpl.DAOSession.initialise(DAOSession.java:40)
where DAOSession.java:40 is :
AnnotationConfiguration config = new AnnotationConfiguration ();
Googling for this error suggests i am missing slf4j-api.jar from the classpath, however if i look at the command line for the Debug properties i can see this jar there:
C:\java\jsedk_6\jre\bin\javaw.exe
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:54541
-Xmx512m -Dfile.encoding=Cp1252
-classpath
D:\dev\workspace\xxx\src;
D:\dev\workspace\xxx\resources;
D:\dev\workspace\xxx\war\WEB-INF\classes;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-user.jar;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-dev-windows.jar;
C:\java\hibernate-annotations-3.4.0.GA\hibernate-annotations.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\ejb3-persistence.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\hibernate-commons-annotations.jar;
C:\java\hibernate-distribution-3.3.2.GA\hibernate3.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\antlr-2.7.6.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\commons-collections-3.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\dom4j-1.6.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\javassist-3.9.0.GA.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\jta-1.1.jar;
C:\java\hibernate-validator-4.0.1.GA\hibernate-validator-4.0.1.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\validation-api-1.0.0.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\log4j-1.2.14.jar;
C:\java\hsqldb\lib\hsqldb.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.jar;
C:\java\restlet-jee-2.0m5\lib\org.restlet.ext.servlet.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.ext.xml.jar;
C:\java\slf4j-1.5.8\slf4j-api-1.5.8.jar;
C:\java\slf4j-1.5.8\slf4j-log4j12-1.5.8.jar
com.google.gwt.dev.HostedMode
...
If i open the jar i can see the LoggerFactory class in there.
Any idea why it isn't being found by the class loader?
Edit 1: If try to access org.slf4j.LoggerFactory from my code, Eclipse compiles it ok, but i get the same error at runtime.
Edit 2: If i add a Test class with a main which calls the same code and run it, it works. So this classpath problem seems specific to the Servlet.
thanks,
jon
It seems that copying the two slf4j jars to the war/WEB-INF/lib sub-project/dir fixed the problem. I'm not really sure why i should need to do this for these two jars and not for all the other Hibernate, Restlet etc jars that the project also uses, though i suppose for consistency i will do that anyway - i guess it will make deployment easier as well.
If someone can provide some sort of explanation as to why this worked and why exactly i need to do it i will select it as the "correct" answer, otherwise i'll select this one.
Can you please reconfirm that you have at least two slf4j.jar files in the classpath, the slf4j-api.jar and exactly one implementation, such as slf4j-jdk14.jar?
You must not have multiple sflj4-implementations in the classpath.
You have a runtime dependency issue so everything compiles fine but the dependency is in your jars. You need to visit the Hibernate site and look at the compatibility matrix and make sure you are matched up correctly then check the dependencies for annotations and core. You log4J jars look fine so it's definitely some quirk.
If it works in Eclipse then logically it's definitely some diff between the 2 runtimes (eclipse and non-eclipse), if the matrix checks out fine then see if you can factor out the commonalities in the 2 then work out the differences -- your answer should be in there.
I had a similar issue except I was using Tomcat and the NoClassDefFound error was on the juli logger. I fixed it by removing the Tomcat dependencies from my classpath when running in hosted mode because hosted mode embeds a Tomcat server that was conflicting. So I would see what happens if you remove some or all of the restlet jars from your classpath to see if they conflict.