I keep geting NoSuchMethodError for XmlSchemaCollection.read(Lorg/xml/sax/InputSource;), I found that there is problem in older versions of XMLSchema What happened to: org.apache.ws.commons.schema.XmlSchemaCollection.read(InputSource).
I changed maven dependency but error keep repeating.
Caused by: java.lang.NoSuchMethodError: org.apache.ws.commons.schema.XmlSchemaCollection.read(Lorg/xml/sax/InputSource;)Lorg/apache/ws/commons/schema/XmlSchema;
at org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.afterPropertiesSet(CommonsXsdSchemaCollection.java:137)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 55 more
maven dependency
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-xml</artifactId>
<version>2.1.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.ws.xmlschema</groupId>
<artifactId>xmlschema-core</artifactId>
<version>2.0.3</version>
</dependency>
schema collection bean
<bean id="schemaCollection" class="org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection">
<property name="xsds" value="/message.xsd"/>
<property name="inline" value="true"/>
</bean>
It might be that some other library is depending on older version of xmlschema-core.
check
mvn dependency:tree
if you see xmlschema-core in dome other library as dependency, then try to exclude it by using exclusion on parent dependency
see Dependency Exclusions
The other option is;
if you have a problem or missing artifactId in your projects pom.xml, this problem persists too.
Related
maybe someone has already figured that out or has some tips, I would be really thankful.
I'm trying to use the Keycloak-Admin-Client maven dependency in a modularized Java 11 application. The Application is modularized via JPMS/Jigsaw.
I'm using the version 9.0.2 of the Keycloak-Admin-Client.
<keycloak-admin-client.version>9.0.2</keycloak-admin-client.version>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>${keycloak-admin-client.version}</version>
My current Problem:
java.lang.module.FindException: Module javax.ws.rs.api not found, required by com.fasterxml.jackson.jaxrs.base
But I already have this in my module-info and POM:
requires java.ws.rs;
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
The javax.ws.rs-api jar is also in my libs folder (module-path):
module-path lib folder
Some additional informations from the jackson-jaxrs-providers GitHub-Repo:
requires static javax.ws.rs.api;
requires static java.ws.rs;
requires static jakarta.ws.rs.api;
https://github.com/FasterXML/jackson-jaxrs-providers/blob/master/json/src/moditect/module-info.java
I hope my problem is understandable, please ask if more details are needed.
Thanks a lot and best regards.
Pierre
The problem was that the javax.ws.rs-api artifact Version 2.1 has a different artifact-id "java.ws.rs-api" not "javax.ws.rs-api".
In Version 2.0.1. are packages missing.
Version 2.1-m08 works.
<dependency>
<groupId>javax.ws.rs</groupId>
<!-- pwi: JAX-RS 2.x has different artifact-id, "javax.ws.rs-api" and Version 2.0.1 has missing packages -->
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1-m08</version>
</dependency>
I have created a Spring MVC Maven project in which I have added a commons-fileupload 1.4 dependency.
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.4</version>
</dependency>
Moreover I have added the bean reference for Multipart resolver into my Spring configuration file:
<bean name="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="5252880"></property>
</bean>
I've checked into my local repository for corresponding jar files and they are present however when I deploy my project into Websphere Liberty server I'm getting the error:
Caused by: java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory
What am I doing wrong in adding the missing dependency?
Below is my stack trace.
Caused by: java.lang.NoClassDefFoundError: org/apache/axiom/om/util/StAXParserConfiguration
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:64)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:197)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
After a bit searching found that, the dependencies in my project for org.apache.axis2 were been upgraded from 1.5.1 to 1.5.3.
After 1.5.1 version had a transitive dependency on the library having the StAXParserConfiguration class.
But the later(newer) one does not have it. As such, I have to add the artifact explicitly in my pom.
You probably need to bundle the missing library with your deployed artifact,
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-api</artifactId>
<version>1.2.14</version>
</dependency>
I'm trying to use Hibernate Validator in my project, but it isn't working. On the following line:
SessionFactory sessions = config.buildSessionFactory(builder.build());
I get the following exception:
org.hibernate.cfg.beanvalidation.IntegrationException: Error activating Bean Validation integration
at org.hibernate.cfg.beanvalidation.BeanValidationIntegrator.integrate(BeanValidationIntegrator.java:154)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1857)
at net.myProject.server.util.HibernateUtil.<clinit>(HibernateUtil.java:32)
... 36 more
Caused by: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:119)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:45)
at org.hibernate.validator.internal.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:217)
at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:111)
I found this question which seems quite similar to my problem. He describes his solution as
I had yet another bean validator jar in the class path. But not from
maven, so i didn't realize it. Removing that solved the problem.
I think my problem is the same. On http://hibernate.org/validator/documentation/getting-started/ it says:
This transitively pulls in the dependency to the Bean Validation API
(javax.validation:validation-api:1.1.0.Final)
That must be causing this issue, since reverting to an older version (4.3.1.Final) fixes the issue. Is there a way to force Hibernate to not pull in the Bean Validation API?
Edit: I've tried to exclude the javax-validation api:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.0.3.Final</version>
<exclusions>
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
But it didn't seem to have any effect.
Try adding this dependency to your pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
If not consider using hibernate-validator4.2.0.Final I have that one in my config and it is working fine.
For me, the 1.1.0.Final version javax.validation.validation-api had worked. Because, the javax.validation.spi.ConfigurationState interface of 1.1.0.Final has getParameterNameProvider method, which was absent in 1.0.0.GA.
I added the below dependency in pom.xml
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
<scope>test</scope>
</dependency>
I had the problem again. Thats how I've fixed that:
1-Exclude spring.validator from the 'web' dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</exclusion>
</exclusions>
</dependency>
2-After insert the dependecy with a previous version:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
in my case i just deleted the hibernate-validator and it worked .(i also had a combo of both validation api and hibernate-validator and tried everything) or you can go to your maven repository-->org and then delete the hibernate folder and rebuild your project again..
hope it helps..
I thought it would be useful to explain what is going on here.
Hibernate is calling ConfigurationState.getParameterNameProvider:
ValidatorFactoryImpl.java:
public ValidatorFactoryImpl(ConfigurationState configurationState) {
...
configurationState.getParameterNameProvider()
...
}
You can find the documentation of getParameterNameProvider:
getParameterNameProvider
ParameterNameProvider getParameterNameProvider()
Returns the parameter name provider for this configuration.
Returns:
parameter name provider instance or null if not defined
Since:
1.1
So what's the problem? The problem is that the method didn't always exist. It was added at some point in the future.
And the rule when creating interfaces is that they are set in concrete: you shall not change an interface ever. Instead the JavaX validator changed the ConfigurationState interface, and added a few new methods over the years.
The java validation code is passing the Hiberate an outdated ConfiguationState interface; one that doesn't implement the required interfaces.
You need to ensure that javax.validation.Validation.buildDefaultValidatorFactory is updated to to support version 1.1.
Removing this jar javax.validation:validation-api:1.1.0.Final solved my problem.
Make sure you have only one validation jar. If we have two jars then they may conflict resulting in error.
Go to the dependecies project and delete, hibernate.validator, and reinstall that in the most recent version. It has solved the problem for me.
I have read post related with this but not get any answer working for me.
I am configuring second level cache in Hibernate v4.3. And I have used MySQL 5.0
I have written following elements in hibernate.cfg.xml
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
I have annotated my Entity class for cache as follows
#Entity
#Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
public class Employee { ....}
Following exception is shown when run
INFO: HHH000397: Using ASTQueryTranslatorFactory
Exception in thread "main" org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:233)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:197)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:178)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:295)
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2442)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2438)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1855)
at com.example.hibernate.Hibernate4Main.main(Hibernate4Main.java:32)
Caused by: org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.ehcache.EhCacheRegionFactory]
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:101)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:46)
at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:83)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:223)
... 7 more
Caused by: org.hibernate.boot.registry.selector.spi.StrategySelectionException: Unable to resolve name [org.hibernate.cache.ehcache.EhCacheRegionFactory] as strategy [org.hibernate.cache.spi.RegionFactory]
at org.hibernate.boot.registry.selector.internal.StrategySelectorImpl.selectStrategyImplementor(StrategySelectorImpl.java:128)
at org.hibernate.cache.internal.RegionFactoryInitiator.initiateService(RegionFactoryInitiator.java:87)
... 10 more
I have seen than there are different cache providers for Hibernate v3 like EhCacheProvoider. All are in org.hibernate.cache package.
But for Hibernate 4.3 there are only 3 classes as RegionFactory.class and other two are of exception.
1. What is wrong with above code?
2. What are major changes made for Second level cache configuration in Hibernate 4.3?
I solved this for my configuration. Viewing the "effective pom" for my project had shown:
<dependencyManagement>
<dependencies>
...
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.3.7.Final</version>
</dependency>
...
</dependencies>
</dependencyManagement>
along with most of my other dependencies.
Copying that hibernate-ehcache dependency into my actual project pom file added a second entry for it outside of the <dependencyManagement/> tag and that solved my problem. I had thought that because it was already included in the effective pom I didn't need to add it but apparently that is not the case for hibernate-ehcache as it seems to be for other packages.
Your pom.xml file should look like below
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>4.3.7.Final</version>
<exclusions>
<exclusion>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.7.1</version>
</dependency>
and Your hibernate.cfg.xml should contain the following configuration
<property name="hibernate.cache.use_second_level_cache">true</property>
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>
Refer this - http://architects.dzone.com/articles/hibernate-4-and-ehcache-higher
add hibernate-ehcache jar to your project, that will solve the problem.
I got the same problem before. I added slf4j-api-1.6.1.jar to the project and fixed this problem. I was using Hibernate 4.3.5.