NoSuchMethodError when compiling in Eclipse with Spring IDE - eclipse

I have a development environment based on Eclipse Juno with Spring IDE installed. My project uses also Spring Security. The Spring version I am using is 2.5.5 and Spring Security is at 2.0.6. Now, after updating Spring IDE from 3.1.0 to 3.3.0, I am getting a NoSuchMethodError when Spring compiler is trying to compile this line:
<security:authentication-provider user-service-ref="userDetailsService" />
<bean id="userDetailsService" class="com.mycompany.security.MyUserDetailsService">
<property name="daoFactory" ref="DaoFactory" />
</bean>
MyUserDetailsService implements UserDetailsService and InitializingBean.
schemaLocation for the file has been defined as:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.6.xsd"
The stacktrace looks like this:
!MESSAGE Error occured processing '/Server/WEB-INF/business-layer-context.xml'
!STACK 0
java.lang.NoSuchMethodError: org.springframework.beans.factory.support.BeanDefinitionBuilder.addConstructorArg(Ljava/lang/Object;)Lorg/springframework/beans/factory/support/BeanDefinitionBuilder;
at org.springframework.security.config.AuthenticationProviderBeanDefinitionParser.parse(AuthenticationProviderBeanDefinitionParser.java:88)
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:74)
at org.springframework.ide.eclipse.beans.core.internal.model.namespaces.DelegatingNamespaceHandlerResolver$ElementTrackingNamespaceHandler.parse(DelegatingNamespaceHandlerResolver.java:177)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ErrorSuppressingBeanDefinitionParserDelegate.parseCustomElement(BeansConfig.java:1400)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1417)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$ToolingFriendlyBeanDefinitionDocumentReader.doRegisterBeanDefinitions(BeansConfig.java:1330)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:110)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:494)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.registerBeanDefinitions(BeansConfig.java:402)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$2.loadBeanDefinitions(BeansConfig.java:388)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:445)
at org.springframework.ide.eclipse.beans.core.internal.model.BeansConfig$3.call(BeansConfig.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
When compiling the application with Ant script and starting the server, everything works fine, so the problem is limited to Eclipse and Spring IDE. Both my Ant and Eclipse configurations use the same Spring library. addConstructorArg method still seems to exist in the newest version of Spring, so I am puzzled by this error. What could be causing this problem?

I believe this is because Spring Tools Suite comes with it's own spring libraries. So for the XML parsing and validation it does not use libraries on your project classpath.
Please see STS-3679

Check your XML configuration files for both Spring and Spring security.
Do you have correct URLs in xsi:schemaLocation, like:
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd

Related

How to use log4j 2.17.1 in Spring-Boot 1.3.6 with Java-8

My Java-8 project is build using spring-boot 1.3.6 version, Which by default inherit 'log4j-core-2.4.1', but now I want to upgrade log4j-core to 2.17.1 for which I added
<log4j2.version>2.17.1</log4j2.version> into pom.xml file of my project. The build runs fine but the error says:-
*ERROR org.springframework.boot.SpringApplication - Application startup failed
java.lang.NoSuchMethodError: org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(Lorg/apache/logging/log4j/core/config/ConfigurationSource;)Lorg/apache/logging/log4j/core/config/Configuration;*
Short answer: you can't.
A breaking change in log4j-core (cf. LOG4J2-1547) renders version 2.7.0 and later incompatible with Spring Boot 1.3.x. You can either:
upgrade to Spring Boot 1.5.x or later,
downgrade to Log4j 2.3.2 (which includes the newest security patches):
<properties>
<log4j2.version>2.3.2</log4j2.version>
</properties>

Spring + JPA + Maven + JSF problems with datasource configuration

I get the following error whenever I try to run/deploy a maven project, which I feel is properly developed. The error ..
Build Path is incomplete. Cannot find class file for org/apache/commons/pool/impl/Generic/ObjectPool....is found on the line
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
in my datasource-config file, which is then imported in the applicationContext.xml.
I would be grateful if anyone can help. The application is being implemented on eclipse Luna + tomcat 8,0.

Lookup failed for 'java:comp/BeanManager' when deploying to Glassfish 4

I already made some research on Google and SO but could not find a solution.
I am writing a java ee 7 Web application including Omnifaces and Primefaces using Eclipse. When deploying the application to Glassfish 4, I get the following error:
javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager'
The longer part of the stacktrace is
java.lang.IllegalStateException: javax.naming.NamingException: Lookup failed for 'java:comp/BeanManager' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Error retrieving java:comp/BeanManager [Root exception is java.lang.IllegalStateException: Cannot resolve bean manager]]
at org.omnifaces.util.JNDI.lookup(JNDI.java:87)
at org.omnifaces.config.BeanManager.init(BeanManager.java:76)
at org.omnifaces.config.BeanManager.getReference(BeanManager.java:115)
at org.omnifaces.application.OmniApplication.createConverter(OmniApplication.java:86)
at javax.faces.application.ApplicationWrapper.createConverter(ApplicationWrapper.java:403)
at org.primefaces.config.ConfigContainer.initConfig(ConfigContainer.java:69)
But I highly doubt that the problem is related to Omnifaces, it's more to state that I didn't do any messy call to cause this.
There is a beans.xml in WEB-INF, it's not completely empty.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
<interceptors>
<class>x.y.z.security.SecurityInterceptor</class>
</interceptors>
</beans>
For the discovery-mode=all, I know it is not recommended, but this is due to an issue I found here: https://java.net/jira/browse/GLASSFISH-20667
If you need more information, facets config or the like, I am happy to post it - but as I've run out of ideas where to locate the problem I don't want to post the everything like complete POM, Glassfish, Eclipse, Maven config or all the code.
edit 2014-01-27:
Ok, after I had written my below comment (the one in comments), I got an idea. Can someone maybe check it out/confirm easily? I was able to load the application to GF after recreating a new database. Can eclipselink cause the above? I am using MS SQL Server 2012, and of course I get SQLExceptions and warnings that tables+fks already exist when redploying, but warnings should not fail my application deployment, should they?
<persistence-unit name="xyzPersistenceUnit" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/xyzDS</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>

failed to run wicket examples on tomcat7

I downloaded wicket examples 1.6.0 and built successfully in netbeans7.2. but got errors when I tried to deploy on tomcat 7:
Cannot deploy the module. The context.xml file seems to be broken. Check whether it is well-formed and valid.
The module has not been deployed.
See the server log for details.
at
org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:210)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.performDeploy(ExecutionChecker.java:178)
at
org.netbeans.modules.maven.j2ee.ExecutionChecker.executionResult(ExecutionChecker.java:130)
at
org.netbeans.modules.maven.execute.MavenCommandLineExecutor.run(MavenCommandLineExecutor.java:212)
at
org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
heres the contents in context.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
I prefer to run wicket in eclipse as it negates the requirement to mess around with an external tomcat instance.
If you are comfortable with eclipse and maven i would download wicket 1.6 example archetype via maven, import into eclipse and then in the test directory you can run the run.java class to get an internal jetty server host wicket for you.
this should get you started quickly without having to wrestle with tomcat configurations too.
Not really an answer but an alternative route to the same end point
Add parameter path to context tag, same path that app will be served:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/application-path-name/">
<!-- <Loader className="org.atmosphere.util.AtmosphereClassloader"/> -->
<Loader delegate="true"/>
</Context>
Answer obtained from this question.

Eclipse FeatureNotFoundException

I have built my project with maven
All builds successful and eclipse properties generation is also successful
But when I open the project in Eclipse 4, I am getting this error
An internal error occurred during: "Loading descriptor for SALYExplorer.".
org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'taglib' not found. (platform:/resource/SALYExplorer/src/main/webapp/WEB-INF/web.xml, 313, 10)
At that location I have some properties
Though the project runs smoothly and everything is fine, just while exploring the project in Navigation pane, Eclipse always throws this error box (quite annoying).
COde at that location
<taglib>
<taglib-uri>xx.tld</taglib-uri>
<taglib-location>/WEB-INF/tld/xx.tld</taglib-location>
</taglib>
and xx definations int it's file
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
.........
</taglib>
The problem is not the taglib at all, it's just a bad error description by Eclipse.
it is the project facet vs. web.xml dtd.. their versions must match!
if the web.xml says:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
but the project has a
"Dynamic Web Module 2.5"
then this error will occur.. change facet to 2.3 or web.xml to 2.5... in other words: they must match..
I ran into this error while trying to update a maven project in Eclipse (ALT+F5).
web.xml
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
and project facet
Dynamic Web Modul 3.0
Here is how I could fix it:
Removed all xmls-schema definition from the web-app element
<web-app>
then update the maven project (ALT+F5).
Re-insert the schema definitions and re-update project (ALT+F5).
According to jsp_2_1.xsd included from web-app_2_5.xsd, taglib tag should be in jsp-config tag:
<xsd:complexType name="jsp-configType">
<xsd:annotation>
<xsd:documentation>
The jsp-configType is used to provide global configuration
information for the JSP files in a web application. It has
two subelements, taglib and jsp-property-group.
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="taglib"
type="javaee:taglibType"
minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="jsp-property-group"
type="javaee:jsp-property-groupType"
minOccurs="0"
maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID"/>
When I wrapped taglib in js-config, the error disappeared.
<jsp-config>
<taglib>
<taglib-uri>http://www.springframework.org/tags/form</taglib-uri>
<taglib-location>/WEB-INF/taglibs/spring-form.tld</taglib-location>
</taglib>
</jsp-config>
Previous parsers were probably more lenient. My config: Eclipse Luna, built-in maven 3.2.1, web.xml 2.5, Dynamic Web Project facet 2.5.
For the time being if it's just the annoying Error Message that you want to fix, then as a short-term fix take a look at disabling validation here : Eclipse 'loading descriptor' takes ages
If the above does not work, an alternative would be to use AHK (Autohotkey) which would take slightly more work at your end. (I have been using an AHK script for a couple of years now to get rid of the Eclipse Error popups that I don't care about)
Eclipse Bug 198630 was raised almost 5 years back and in that there is a comment which has an almost identical error message as the OP. (The bug itself was finally closed as not being reproducible).
I have the following questions for you :
Would it be possible for you to show us the Error log ? (To get at the error log you can either take a look at the Error Log View or by looking at the actual file : WORKSPACE_HOME/.metadata/.log. Please take a look at this for more detailed information. )
Are you using any specific Server Adapters like WebLogic or Glassfish ?
I have the following recommendations :
In the eclipse bug thread, the problem was fixed at least once by updating to a specific JST version. Hence, would it be possible for you to run an Eclipse update and see whether the problem is resolved ? (This can be done by going to Help -> Check for Updates)
Would it be possible to try importing the project in Eclipse Indigo (instead of
Juno, which you currently have) and see whether you can reproduce
the problem ? (Eclipse Indigo downloads are available here and I believe you would need the Java EE version)
I just got the same symptoms, with a web-app project using maven. In my case, was related to struts taglib tags in web.xml, and the project having a struts v1.2.9 dependency. I solved the problem by switching to struts v1.3.10. Don't ask why this solved the problem.
If you are in the same situation and you upgrade your struts dependency from 1.2.9 to 1.3.10, be sure to use at least dtd v2.3 in the DOCTYPE declaration of your web.xml:
!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"
or you'll get another problem (your webapp won't startup without an internet connection)
Hope this helps
I suspect that the problem is with Eclipse web Tools Platform and Java EMF Model. Here is an image of a list of plugins including Java EMF Model and JEM stuff from Eclipse Web Tools Platform:
https://stackoverflow.com/users/1503535/nitin-gurram, does your stack trace look like this?
!ENTRY org.eclipse.core.jobs 4 2 2012-09-28 12:10:00.554
!MESSAGE An internal error occurred during: "Loading descriptor for grch97.".
!STACK 0
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'taglib' not found. (platform:/resource/grch97/WEB-INF/web.xml, 891, 11)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.getResource(ProjectResourceSetImpl.java:1003)
at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.getModelResource(JEE5ModelProvider.java:169)
at org.eclipse.jst.jee.model.internal.Web25ModelProvider.getModelObject(Web25ModelProvider.java:44)
at org.eclipse.jst.jee.model.internal.JEE5ModelProvider.getModelObject(JEE5ModelProvider.java:215)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.loadProviders(AbstractMergedModelProvider.java:261)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.access$2(AbstractMergedModelProvider.java:255)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider$LoadModelsWorkspaceRunnable.run(AbstractMergedModelProvider.java:278)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.loadModel(AbstractMergedModelProvider.java:249)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.getMergedModel(AbstractMergedModelProvider.java:219)
at org.eclipse.jst.jee.model.internal.common.AbstractMergedModelProvider.getModelObject(AbstractMergedModelProvider.java:139)
at org.eclipse.jst.jee.ui.internal.navigator.Web25ContentProvider.getNewContentProviderInstance(Web25ContentProvider.java:69)
at org.eclipse.jst.jee.ui.internal.navigator.LoadingJeeDDJob.run(LoadingJeeDDJob.java:50)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'taglib' not found. (platform:/resource/grch97/WEB-INF/web.xml, 891, 11)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeature(XMLHandler.java:1985)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeature(XMLHandler.java:1949)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeature(XMIHandler.java:145)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1893)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1017)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:995)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:706)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:240)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1505)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1284)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.jem.internal.util.emf.workbench.ProjectResourceSetImpl.demandLoad(ProjectResourceSetImpl.java:811)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 14 more
I managed to fix this by removing the validator out of the .project file for each of the projects that had the issue.
I had a similar error using eclipse 4.3 (Kepler), maven 3.1.0, tomcat 6.0.37 and jdk7 (have also jre6 installed), and found a solution to fix it or at least to get rid of the tedious errors by configuring tomcat in eclipse.
In Preferences->Server-> Runtime Environments, define a new run time environment "Apache Tomcat 6.0" and select the jre6 installation from the installed JREs.
Then review the Targeted Runtimes in the project's properties. Apache Tomcat v6.0 should be associated with Java Runtime Environment v1.6 (if not yet defined press new and check that the selected JRE is a java 1.6 runtime).
Hope it helps
I was able to update the project Java facet to 1.5 and the errors stopped.
In my case, this problem got resolved by using the version
org.eclipse.emf.ecore.xmi_2.10.2.v20150123-0348 and org.eclipse.emf.ecore.xmi.source_2.10.2.v20150123-0348 and
org.eclipse.emf.ecore.xmi_2.10.2.v20150123-0348 and
org.eclipse.emf.ecore.xmi.source_2.10.2.v20150123-0348 and
org.eclipse.emf.common_2.10.1.v20150123-0348
jars in the build path.
Earlier jars of old version were being used inspite of new version present.
Right click on the project in Eclipse -> Build Path -> Configure Build Path -> Project Facets -> Uncheck Dynamic Web Module
Note: This approach is good as long you dont plan to run the web-app from within eclipse thru an embedded app server.