No Method Found Error - eclipse

I am trying to make a basic spring mvc 3.0 application. But when i launch my server, i get the following error
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.<init>(Ljava/lang/Class;)V
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:350)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:296)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:830)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:493)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:631)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:588)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:645)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:508)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:449)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:133)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:857)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:679)
Can someone tell me why?

You have two libraries which are incompatible because of different versions.
On one hand you have spring-beans.jar in Version 3.0.5 (or some other 3.0.x). -- This jar contains org.springframework.beans.factory.annotation.InjectionMetadata with an two parameter constructor public InjectionMetadata(Class targetClass, Collection<InjectedElement> elements).
And this is the only one constructor of that class.
On the other hand you have spring-orm.jar, I do not know its version but I guess something like 2.0.x or 3.1.x. This contains a class org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor which try to create an instance of InjectionMetadata with an one parameter constructor.
And this result in this
java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.(Ljava/lang/Class;)V
The solution is simple: make sure that spring-beans.jar and spring-orm.jar (as well as every other spring jar) is of the same version.

Do a search including archives (.jar files) (easy with Total Commander for example) on your classpath for files containing InjectionMetadata.class. Errors like this usually happen when there is a different version of the class loaded runtime then used/seen by your favourite IDE when you edit the code.

Review libraries version. You can be using a old spring-beans version and a newer spring-core one, for example.

You can make all jars consistent using BOM dependency.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.5.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>

The solution is simple: make sure that spring-beans.jar and spring-orm.jar (as well as every other spring jar) is of the same version.

Related

How to see persisted data(persisted thru spring-data-gemfire) in gemfire commanline gfsh

I'm getting to introduced to pivotal GemFire, so I created a starter project in spring and replicated the below project in spring guide.
https://spring.io/guides/gs/accessing-data-gemfire/
And this project is working data is been persisted and I can able to retrieve data as well.
On the other side I have downloaded the "GemFire 8.2.1" and installed in my system and set all env variables and can able to run the conmmandLine for GemFire "gfsh" .
1) Now my question is how to view that persisted data (persisted thru spring-data-gemfire) in this commandline gfsh. so, that I can really see how it is storing and etc.
2) Also, in the above spring project although it working fine its throwing exception as
[info 2016/06/07 20:24:55.559 IST <main> tid=0x1] Command Service could not be initialized. Could not find Spring Shell library which is needed for CLI/gfsh in classpath. Internal support for CLI & gfsh is not enabled. Note: For convenience, absolute path of "gfsh-dependencies.jar" from "lib" directory of GemFire product distribution can be included in CLASSPATH of an application.
com.gemstone.gemfire.management.DependenciesNotFoundException: Could not find Spring Shell library which is needed for CLI/gfsh in classpath. Internal support for CLI & gfsh is not enabled. Note: For convenience, absolute path of "gfsh-dependencies.jar" from "lib" directory of GemFire product distribution can be included in CLASSPATH of an application.
at com.gemstone.gemfire.management.cli.CommandService.createLocalCommandService(CommandService.java:135)
at com.gemstone.gemfire.management.internal.beans.MemberMBeanBridge.<init>(MemberMBeanBridge.java:352)
at com.gemstone.gemfire.management.internal.beans.ManagementAdapter.handleCacheCreation(ManagementAdapter.java:152)
at com.gemstone.gemfire.management.internal.beans.ManagementListener.handleEvent(ManagementListener.java:111)
at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.notifyResourceEventListeners(InternalDistributedSystem.java:2243)
at com.gemstone.gemfire.distributed.internal.InternalDistributedSystem.handleResourceEvent(InternalDistributedSystem.java:503)
at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.init(GemFireCacheImpl.java:1009)
at com.gemstone.gemfire.internal.cache.GemFireCacheImpl.create(GemFireCacheImpl.java:682)
at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:182)
at com.gemstone.gemfire.cache.CacheFactory.create(CacheFactory.java:229)
at org.springframework.data.gemfire.CacheFactoryBean.createCache(CacheFactoryBean.java:398)
at org.springframework.data.gemfire.CacheFactoryBean.resolveCache(CacheFactoryBean.java:303)
at org.springframework.data.gemfire.CacheFactoryBean.init(CacheFactoryBean.java:244)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:871)
at org.springframework.data.gemfire.CacheFactoryBean.getObject(CacheFactoryBean.java:86)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1590)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:534)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:523)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1162)
at org.springframework.data.gemfire.repository.support.GemfireRepositoryFactoryBean.setApplicationContext(GemfireRepositoryFactoryBean.java:71)
at org.springframework.context.support.ApplicationContextAwareProcessor.invokeAwareInterfaces(ApplicationContextAwareProcessor.java:119)
at org.springframework.context.support.ApplicationContextAwareProcessor.postProcessBeforeInitialization(ApplicationContextAwareProcessor.java:94)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at com.wrd.mytrah.GemFireSubject03Application.main(GemFireSubject03Application.java:26)
```
so how to resolve this , it has anything to do with the above problem (question 1)
Please help to this newbee.. thanks
1) You have a few options for seeing the data persisted to GemFire from your Spring Data GemFire based application using Gfsh.
1.a) You can execute OQL from the gfsh command-line like so...
gfsh>query --query="SELECT * FROM /<your region name here> WHERE <predicates here>"
For example...
SELECT c.name FROM /Customers c WHERE c.age > 21
See the GemFire documentation for more details...
http://gemfire.docs.pivotal.io/docs-gemfire/latest/tools_modules/gfsh/command-pages/query.html
http://gemfire.docs.pivotal.io/docs-gemfire/latest/developing/querying_basics/chapter_overview.html
1.b) You also have the option of using GemFire's Data Browser tool, which is a component of the GemFire Pulse Management/Monitoring tool.
http://gemfire.docs.pivotal.io/docs-gemfire/latest/tools_modules/pulse/chapter_overview.html
http://gemfire.docs.pivotal.io/docs-gemfire/latest/tools_modules/pulse/quickstart.html#topic_F0ECE9E8179541CCA3D6C5F4FBA84404 (scroll down to the section, "Data Browser").
The following documentation explains how to start/launch Pulse from Gfsh...
http://gemfire.docs.pivotal.io/docs-gemfire/latest/tools_modules/pulse/quickstart.html#topic_523F6DE33FE54307BBE8F83BB7D9355D
Essentially...
gfsh>start pulse
After a Locator/Manager has been started.
2) As for the Exception, GemFire currently has a bug where it attempts to load the management command classes even if the GemFire Server node is not a "Manager". This Exception is benign, but you can eliminate it by including the Spring Shell dependency on your classpath. For example, using Maven, you would declare the following dependency...
<dependency>
<groupId>org.springframework.shell</groupId>
<artifactId>spring-shell</artifactId>
<version>1.0.0.RELEASE</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
</exclusion>
</exclusions>
</dependency>
If you are not using Maven or Gradle, then you can do as the Exception message states and put the $GEMFIRE_HOME/lib/gfsh-dependencies on your application classpath (perhaps in your IDE).
However, if you are following the Spring Guides, then you are using either Maven or Gradle.
Hope this helps!
Cheers,
John

How do I get my Eclipse JUnit test run to behave the same as running the test on the mvn command line?

I’m using Eclipse Juno on Mac 10.9.1, Maven 3.1.1, JUnit 4.11, and have this Apache httpcomponents dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.4</version>
</dependency>
When I run a JUnit test in Eclipse (by right clicking my test name, and selecting “Run As” -> “Junit Test”), I get the following error
java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute(Lorg/apache/http/client/methods/HttpUriRequest;)Lorg/apache/http/client/methods/CloseableHttpResponse;
at org.usersubscr.subco.ebook.mvc.CleverInstantLoginController.validateInstantAccessLogin(CleverInstantLoginController.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.mainco.subco.ebook.mvc.CleverInstantLoginControllerTest.submitLoginWithCode(CleverInstantLoginControllerTest.java:119)
at org.mainco.subco.ebook.mvc.CleverInstantLoginControllerTest.testInstantLoginSuccess(CleverInstantLoginControllerTest.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
The specific line where things are dying is
response1 = httpclient.execute(httppost);
The frustrating thing about this is that when I run the same test on the command line, using
mvn clean test -Dtest=MyHttpTest
The test runs fine without the error. I have tried running “mvn eclipse:eclipse” on my project and refreshing my workspace, but that doesn’t seem to help. How can I get the Eclipse JUnit to behave the same way as running the test on the command line?
I frequently run into this problem.
If I am running from Maven, either from command line or from Eclipse, then I always do mvn clean test.
If I am running as JUnit from Eclipse, then I first do Project > Clean (followed by build), and finally Run as JUnit. If that still does not solve the problem, then I first do Maven Clean and repeat the procedure.
Bottom line is: Maven and Eclipse each have their own (strong) opinion on how the world works, and in certain cases they contradict each other.
Okay, had this exact same problem with
java.lang.NoSuchMethodError: org.apache.commons.collections.MapUtils.isNotEmpty
For me this was because Hibernate includes commons-collections-3.1 which does not include method isNotEmpty(). I though it was really weird, as when I used m2e plugin Dependency Hierarchy feature, it showed me that it automatically excluded the dependency and used 3.2 instead. What's worse, it seemed that manually excluding the artifact from the pom did not do anything.
For me the problem was that I had Maven dependency with scope set to test and for some reason Eclipse JUnit used this dependency without exception. I have multi module project and I was trying to find out the problem in downstream module (that is, I was looking the dependency hierarchy of a module that included a module, which included another module, that had the dependency which caused problems), so Eclipse Maven plugin did not see the dependency as the scope was test. As said, JUnit did not understand that it should't use this dependency further down the road, and this gave me headache.
For you the problem might be something else, so I try to give more general picture to track the problem down. Following is the process I used to track and eliminate the issue, hope this helps:
used m2e plugin Dependency Hierarchy to track down all versions of the dependency
found out that Hibernate uses old dependency
went to my local m2 repo and renamed all incorrect versions (see image)
run tests (to verify we are on right track), they should fail saying that the dependency cannot be found
use Notepad++ to find all files that include the wrong dependency (for me the search string was "commons-collections/3.1/commons-collections-3.1.jar" and file name filter was ".classpath")
find out the modules trying to use it
check the exact pom files and exclude the culprit (for me it was the following:)
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
</exclusions>
</dependency>

Apache Mahout and REST Java Web Application Integration

I have a problem with link those two things - Apache Mahout and Java Web Application Integration.
I use standard Java Web Application Maven project and Jersey 2.4 to build my webservice. My application server is Apache Tomcat 7.
When I run this project without Mahout and try:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" 'http://myhost:8089/ensembleRestApi/recommeng/algorithm/articleCore/cf?limit=5'
I got response and also can go through source code (with debugger)
But when I add Mahot dependency to my pom.xml file:
<dependency>
<groupId>org.apache.mahout</groupId>
<artifactId>mahout-core</artifactId>
<version>0.9</version>
</dependency>
And try to do the same curl command, I got this AbstractMethodError yet before breakpoint in webservice method is invocated in my source code:
Do you know where is the problem please?
SEVERE: Servlet.service() for servlet [jersey-serlvet] in context with path [/ensembleRestApi] threw exception [Servlet execution threw an exception] with root cause
java.lang.AbstractMethodError: javax.ws.rs.core.UriBuilder.uri(Ljava/lang/String;)Ljavax/ws/rs/core/UriBuilder;
at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:286)
at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:218)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Ok, so if somebody will fight with the same thing, remember that this exception is because of:
Thrown when an application tries to call an abstract method. Normally,
this error is caught by the compiler; this error can only occur at run
time if the definition of some class has incompatibly changed since
the currently executing method was last compiled.
by Oracle
This means that you have some conflicts in libraries (which are in dependencies)
So I tried to downgrade my mahout-core library version and with version 0.7 everything works fine.
I just encountered the same problem, and it's because of a conflict in Jersey versions. For my endpoints, I'm using Jersey 2.14. But Mahout 0.9 depends on hadoop-core 1.2.1, which has several Jersey 1.8 dependencies. The AbstractMethodError is caused because your endpoint is using a Jersey 1.8 class which does not have this method defined.
Exclude all the com.sun.jersey dependencies from your pom.xml...Here I'm using gradle:
compile ('org.apache.mahout:mahout-integration:0.11.1'){
exclude group: 'com.sun.jersey'
}
In eclipse you can go to your 'Maven Dependencies' folder in your project -> right click-> 'Maven' ->'Exclude Maven Artifact...' for all the 'jersey1.xxx' dependencies and the exclusions will be added in your pom.xml file

Jersey + Eclipse + Jetty : Serialization of polymorphic types results to a java.lang.NoSuchFieldError: EXTERNAL_PROPERTY exception on Ubuntu 12.04

I experience a very strange problem and I don't have found any help to resolve it. I'm developing an app using Jersey to provides RESTfull services that are accessed by a GWT website. Services produce Json contents that are deserialized by RestyGWT. Everything works fine until I wanted to serialize polymorphic types. I also use Shiro to protect returned values to unauthorized users.
The serialization process run well on Mac OS X Lion using Eclipse Indigo and included Jetty as webserver. It also work well by using Tomcat 6. When I'm on Linux (an Ubuntu 12.04 distro), the app run well by using Tomcat 6 but when I use Ecplise's included Jetty as webserver, the exception below is always thrown.
I tried to update each lib to the latest stable version as I read in some posts. Does anyone has experienced this problem ?
Thank you in advence.
java.lang.NoSuchFieldError: EXTERNAL_PROPERTY
at org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector._findTypeResolver(JacksonAnnotationIntrospector.java:781)
at org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector.findTypeResolver(JacksonAnnotationIntrospector.java:199)
at org.codehaus.jackson.map.AnnotationIntrospector$Pair.findTypeResolver(AnnotationIntrospector.java:1032)
at org.codehaus.jackson.map.ser.BasicSerializerFactory.createTypeSerializer(BasicSerializerFactory.java:200)
at org.codehaus.jackson.map.ser.BasicSerializerFactory.buildContainerSerializer(BasicSerializerFactory.java:406)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:268)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:782)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:735)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:344)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findTypedValueSerializer(StdSerializerProvider.java:420)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:601)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1613)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:558)
at com.sun.jersey.spi.container.ContainerResponse.write(ContainerResponse.java:306)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1451)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1363)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1353)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:414)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1097)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:380)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1088)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:360)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
In my case the same exception was caused by having restygwt library on the Classpath.
RestGwt includes the Jackson Annotation Classes in it's own source tree. This then leds to version conflicts between the Jackson library and RestyGwt beginning with the Jackson 1.9, where in the JsonTypeInfo Class new Enummeration Value for the As Enum was introduced (EXTERNAL_PROPERTY), which is resolved at Runtime and thus leds to the above Exception.
My solution was to back to the 1.7.1 Version of Jackson. Note aside: From my point of view the redundant inclusion of the source code, is not the way to resolve dependencies.
Check the version of your Jackson is 1.9 or bigger, because this enum was added in 1.9.
I've experienced the same issue recently with a GWT 2.4 application, using Jackson 1.9.7 and RestyGWT 1.3.
We're using one of Thomas Broyer's archetypes which produces three different Maven projects for the GWT app. We have RestyGWT included as a dependency in client and shared projects. Because the server project has a dependency on the shared one, we had a dependency (received transitively) on RestyGWT on the server project. So, in order to make it work I excluded the RestyGWT dependency when setting the shared project dependency on server project:
<dependency>
<groupId>io.pst</groupId>
<artifactId>accounts-ui-shared</artifactId>
<exclusions>
<exclusion>
<groupId>org.fusesource.restygwt</groupId>
<artifactId>restygwt</artifactId>
</exclusion>
</exclusions>
</dependency>
A simple workaround is to exclude the old Jackson lib from your RestyGWT dependency, while ensuring the most recent one will supercede it :
<dependency>
<groupId>org.fusesource.restygwt</groupId>
<artifactId>restygwt</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.jackson</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.9.9</version>
</dependency>

Class cast exception when invoking a web service in Jboss 4.2.3 GA

We have created a web service in Netbeans 7.1 which is running fine on glassfish 3.1.1. Now I have to move my service application to Jboss 4.2.3 GA-JDK6. There is no problem found when deploying the web service on Jboss, but however invoking the web service causes an exception: -
"setProperty must be overridden by all subclasses of SOAPMessage class". To overcome this problem I had added jboss-native-saaj.jar in the JBOSS_HOME/lib/endorsed. which resolved the problem and the service got invoked but failed to return the response, but it resulted in a new exception: -
Caused by: java.lang.ClassCastException: com.sun.xml.messaging.saaj.soap.ver1_1.Envelope1_1Impl cannot be cast to org.jboss.ws.core.soap.SOAPElementImpl
at org.jboss.ws.core.soap.SOAPEnvelopeImpl.<init>(SOAPEnvelopeImpl.java:60)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:124)
at org.jboss.ws.core.soap.EnvelopeBuilderDOM.build(EnvelopeBuilderDOM.java:96)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:280)
at org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP.read(SOAPMessageUnMarshallerHTTP.java:84)
at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:518)
at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:307)
... 54 more
Also I want to tell that I'm actually invoking a webservice from within a webservice.
Please help in this, as there no documentation or solution available for the same.
Thanks in Advance
Adding the complete stacktrace of the previously occurred error:-
javax.xml.ws.WebServiceException: java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at org.jboss.ws.core.jaxws.client.ClientImpl.handleRemoteException(ClientImpl.java:404)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:314)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:172)
at org.jboss.ws.core.jaxws.client.ClientProxy.invoke(ClientProxy.java:152)
at $Proxy183.authenticateUser(Unknown Source)
at com.liaison.soi.sts.usermgmt.service.impl.UserManagementServiceImpl.authenticateUser(UserManagementServiceImpl.java:46)
at com.liaison.soi.sts.usermgmt.service.impl.UserManagementServiceImpl.authenticateUser(UserManagementServiceImpl.java:25)
at com.liaison.soi.sts.auth.AuthenticationHandler.validate(AuthenticationHandler.java:24)
at com.sun.xml.wss.impl.callback.PasswordValidationCallback.getResult(PasswordValidationCallback.java:80)
at com.sun.xml.wss.impl.misc.DefaultSecurityEnvironmentImpl.authenticateUser(DefaultSecurityEnvironmentImpl.java:1166)
at com.sun.xml.ws.security.opt.impl.incoming.UsernameTokenHeader.validate(UsernameTokenHeader.java:160)
at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.handleSecurityHeader(SecurityRecipient.java:341)
at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.cacheHeaders(SecurityRecipient.java:275)
at com.sun.xml.ws.security.opt.impl.incoming.SecurityRecipient.validateMessage(SecurityRecipient.java:225)
at com.sun.xml.wss.jaxws.impl.SecurityTubeBase.verifyInboundMessage(SecurityTubeBase.java:450)
at com.sun.xml.wss.jaxws.impl.SecurityServerTube.processRequest(SecurityServerTube.java:295)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:641)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:600)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:585)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:482)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:314)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:608)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:259)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.invokeAsync(ServletAdapter.java:213)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:159)
at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:194)
at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java:80)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.UnsupportedOperationException: setProperty must be overridden by all subclasses of SOAPMessage
at javax.xml.soap.SOAPMessage.setProperty(SOAPMessage.java:454)
at org.jboss.ws.core.soap.SOAPMessageImpl.<init>(SOAPMessageImpl.java:83)
at org.jboss.ws.core.soap.MessageFactoryImpl.createMessage(MessageFactoryImpl.java:171)
at org.jboss.ws.core.CommonSOAP11Binding.createMessage(CommonSOAP11Binding.java:59)
at org.jboss.ws.core.CommonSOAPBinding.bindRequestMessage(CommonSOAPBinding.java:158)
at org.jboss.ws.core.CommonClient.invoke(CommonClient.java:291)
at org.jboss.ws.core.jaxws.client.ClientImpl.invoke(ClientImpl.java:302)
I think your problem is in following.
The implementation SOAPMessageImpl was packaged in jboss-native-saaj.jar only till JBoss 3.2.2.GA (check here). Latest JBoss has this class in jbossws-native-core.jar. So you create a class conflict when you put jboss-native-saaj.jar into server/libs (or package with your application). So the solution will be: just remove jboss-native-saaj.jar, as jbossws-native-core.jar is (I believe) already there.
To make sure check META-INF for jboss-native-saaj.jar: was it packaged for JBoss 4.2.3? what is that date of packaging? This will take you to right decision.
This can be easily googled.
See https://issues.jboss.org/browse/JBWS-1439 and https://community.jboss.org/message/618306.
It's a well-known issue under Java 6 caused by obsolete jax-ws jars bundled within.
You'll have to play with moving some jars to endorsed dir as noted in above issue.
An alternative solution is to upgrade to JBossWS-3.1.1 (the last one supporting JBoss AS 4.2.3.GA).
Same issue in JBoss 5.1.2 is resolved with the addition of
jboss-as/lib/endorsed/jbossws-native-factories-3.1.2.SP11.jar