Migrating java7 to java8 and used wildfly to deploy the services. During deployment following Error is blocking the migration.
Caused by: java.lang.IllegalArgumentException: UT010009: Servlet dispatcher of type class org.springframework.web.servlet.DispatcherServlet does not implement javax.servlet.Servlet
#Jboss-deployment-structure.xml following exclusion is defined
<exclusions>
<module name="javax.api" />
<module name="javax.servlet.api" />
</exclusions>
spring version "4.3.4.RELEASE"
Any advice :)
Thanks in advance!!
It looks like you're ending up with two different javax.servlet.Servlet on your class path. You should not be excluding the javax.api and javax.servlet.api modules and you should make sure your deployment does not contain the a servlet API or implementation module.
Related
I am trying to override the Jersey (and dependency) libraries(v2.21) available in WebLogic 12.2.1 with application packaged ones which has Jersey v2.25.1. But end up with below:
A MultiException has 4 exceptions. They are
java.lang.IllegalArgumentException: interface org.glassfish.hk2.api.ProxyCtl is not visible from class loader
java.lang.IllegalArgumentException: While attempting to create a Proxy for javax.servlet.http.HttpServletResponse in scope org.glassfish.jersey.process.internal.RequestScoped an error occured while creating the proxy
java.lang.IllegalArgumentException: While attempting to resolve the dependencies of com.abc.xyz.JerseySampleProvider.MyProvider errors were found
java.lang.IllegalStateException: Unable to perform operation: resolve on com.abc.xyz.JerseySampleProvider.MyProvider
Tried other versions of Jersey like 2.19 as well. Same result. Any help would be appreciated.I also came across similar reported issues in this forum but did not see a solution
XML as below
<container-descriptor>
<prefer-application-packages>
<!-- hk2 providers -->
<package-name>org.glassfish.hk2.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>org.jvnet.tiger_types.*</package-name>
<!-- apis -->
<package-name>javax.ws.rs.*</package-name>
<!-- java assist -->
<package-name>javaassist.*</package-name>
<!-- aop repackaged -->
<package-name>org.aopalliance.*</package-name>
<!-- guava -->
<package-name>com.google.common.*</package-name>
<!-- jersey2 providers -->
<package-name>org.glassfish.jersey.*</package-name>
<package-name>jersey.repackaged.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>com.sun.ws.rs.ext.*</package-name>
<!-- Jackson providers -->
<package-name>com.fasterxml.*</package-name>
<!--Others-->
<package-name>org.objectweb.asm.*</package-name>
<package-name>antlr.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
<!-- hk2 -->
<resource-name>META-INF/services/org.glassfish.hk2.*</resource-name>
<resource-name>org.glassfish.hk2.*</resource-name>
<resource-name>org.jvnet.hk2.*</resource-name>
<resource-name>org.jvnet.tiger_types.*</resource-name>
<resource-name>META-INF/services/javax.servlet.ServletContainerInitializer</resource-name>
<resource-name>META-INF/services/javax.ws.rs.ext.RuntimeDelegate</resource-name>
<!-- Jersey -->
<resource-name>META-INF/services/org.glassfish.jersey.*</resource-name>
<resource-name>org.glassfish.jersey.*</resource-name>
<resource-name>jersey.repackaged.*</resource-name>
</prefer-application-resources>
</container-descriptor>
I have done below configurations and tried almost all solutions found but nothing helped. When i am deploying spring boot app in war package. no error got logged in weblogic log but the application throwing 404 error.
web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:root-context.xml</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>dev</param-value>
</context-param>
<context-param>
<param-name>spring.liveBeansView.mbeanDomain</param-name>
<param-value>dev</param-value>
</context-param>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wls="http://www.bea.com/ns/weblogic/90"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-web-app.xsd">
<wls:weblogic-version>12.1.2.0.0</wls:weblogic-version>
<wls:context-root>/services/userModule/</wls:context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>com.fasterxml</wls:package-name>
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
application.properties
spring.profiles.default=default
spring.profiles.active=default
spring.liveBeansView.mbeanDomain=default
cms.config.monitor.dir=/server/location/application/artifacts
application.messages.file.name=application-messages
application.config.file.name=application-config
root-context.xml
it contains application specific configurations.
ApplicationBegin.java
#SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class})
public class ApplicationBegin extends SpringBootServletInitializer implements WebApplicationInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ApplicationBegin.class);
}
public static void main(String[] args){
SpringApplication.run(ApplicationBegin.class, args);
}
Cannot exclude tomcat server from pom.xml as it is failing the compilation. is there a way to set tomcat as provided while using spring boot starter web?
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<!-- THIS WILL BE EXCLUDE ONLY FOR WEBLOGIC DEPLOYMENT -->
<!-- <exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion> -->
</exclusions>
</dependency>
The problem is the application runs fine with embedded tomcat but it is not working even not throwing any error when deploying on weblogic. Where should i look?
Can you try class loading as the parent last? So Spring boot will use it's own container libraries.
After trying the solutions i found from different people , it couldn't solve my issue and somehow i have solved it now. all the similar issues i have seen on this topic and the soultions, i finally understood no answer was actually a solution because in most of the cases the issue happens because of wrong configuration that weblogic dosen't understand. the worst part being it doesn't even throw error. In my case other than application.properties file and a root-context.xml, i explicitly specified web.xml file in /WEB-INF location and defined context-config location there. As soon as i removed the web.xml and refactored/filtered the project dependencies from top to bottom , it resolved the issue.
and also then i realized many handy solutions on the web for this issue wouldn't even be required if your configuration is correct. for an example, configuring a jpavendor won't require if you use spring boot jpa starter correctly.
so.. if you ever face this kind of deployment issue on weblogic , you may follow below steps -
Only deploy a bareminimum part of application and make it workable
on weblogic
then add your critical dependencies / configurations and deploy them one by one on weblogic and check if it is working
you should always run your boot application to other local server first for resolving major configuration issues ..tomcat is
good.
I had the same problem, but I finally managed to solve it.
The problem was the version of web.xml descriptor. If you put the web.xml file in your project with <web-app version="2.5">, even though your Weblogic supports servlet 3.0, the spring controllers would throw 404.
That also explains the behavior of your app - what's why it started working when you removed the web.xml file.
I'm attempting to deploy a Spring Boot (2.0.2) application on JBoss EAP 7.1 server.
The code that's causing the problem is:
import javax.validation.constraints.NotBlank;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
#Component
#Validated
public class AppProperties {
#NotBlank
private String name;
When the application is deployed on JBoss I get the following exception:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
16:44:25,861 ERROR [org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter] (ServerService Thread Pool -- 6 7)
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'app' to com.example.security.config.AppProperties:
Property: app.contextpath
Value: /api
Origin: class path resource [application.yml]:5:18
Reason: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotBlank' validating type 'java.lang.String'. Check configuration for 'name'
Action:
Update your application's configuration
I've tried adding the file jboss-deployment-structure.xml with the following contents to WEB-INF/classes:
<jboss-deployment-structure>
<ear-subdeployments-isolated>true</ear-subdeployments-isolated>
<deployment>
<exclude-subsystems>
<subsystem name="jaxrs"/>
</exclude-subsystems>
<exclusions>
<module name="javaee.api"/>
<module name="javax.validation.api"/>
<module name="javax.faces.api"/>
<module name="org.hibernate.validator"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
But, no luck. What's the workaround? Thanks in advance.
Even though this question is a year old, I ran into the same issue and couldn't find a solution.
This, I know, will work for Spring Boot 2.1.x and JBoss 7.1, not sure about versions before that.
We obviously need to exclude org.hibernate.validator and javax.validation.api. What wasn't clear is that we also need to exclude the javax.faces.api (it has a transitive dependency on javax.validation.api). Excluding that javax.faces causes JBoss to fail on start up due to missing jsf libraries. We can then simply exclude the jsf subsystem.
<jboss-deployment-structure>
<deployment>
<exclude-subsystems>
<subsystem name="jsf" />
</exclude-subsystems>
<exclusions>
<module name="javax.validation.api" />
<module name="javax.faces.api" />
<module name="org.hibernate.validator" />
</exclusions>
</deployment>
</jboss-deployment-structure>
Assuming you don't need JSF from jboss, this should work.
According to this article the jboss-deployment-structure.xml shoudl be placed in 'the top level deployment, in META-INF (or WEB-INF for web deployments)'.
So with your current set-up the things configured in the xml are not applied, so if the xml is put in the right location it might work.
javax.validation.constraints.NotBlank is part of Bean Validation 2.0 and thus Java EE 8. I suspect EAP 7.1 does not support this feature yet.
I have a spring project in which i am using a validator like the following:
<beans:bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
p:basenames="WEB-INF/i18n/messages,WEB-INF/i18n/application"
p:fallbackToSystemLocale="false" />
<beans:bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<beans:property name="validationMessageSource" ref="messageSource" />
</beans:bean>
<annotation-driven validator="validator" />
<resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**" />
When i run the project i get the following BeanCreationException:
org.springframework.beans.factory.BeanCreationException: Error creating bean with
name 'validator' defined in ServletContext resource [/WEB-INF/spring/appServlet
/servlet-context.xml]: Error setting property values; nested exception is
org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'validationMessageSource' threw exception; nested exception is
java.lang.NoClassDefFoundError: org/hibernate/validator/resourceloading/ResourceBundleLocator
Here is my snippet of POM:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.3.2.RELEASE</version>
</dependency>
<!-- Hibernate entity manager with JPA 2 support. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.3.0.Beta2</version>
</dependency>
<!-- Hibernate’s implementation of JSR-303. -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.2.0.Final</version>
</dependency>
<!-- The JSR-303 Bean Validation API library. -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
Why i am getting this error?
Thanks
Your dependencies are OK. Based on the provided information the error should not appear.
So I suggest you to check your IDE and whether the hibernate-validator dependency is really on classpath. If you are using Eclipse with M2E, try to update your project:
Project (right click on project) > Maven > Update Project....
This might be a broken backwards compatibility issue: https://jira.springsource.org/browse/SPR-10466
I had a similar problem using hibernate 5.2.10.Final and hibernate-validator 6.0.2.Final (that package version doesn't seem to be in sync with the others). Turns out, hibernate-validator's groupId was changed from org.hibernate to org.hibernate.validator. Once I made that change, the error went away, however I am using Dropwizard and noticed that there may be a version conflict somewhere, so that's something to keep an eye on.
I also had this exact same problem, tried all sorts of combinations of JAR versions, different bean definitions, even customised class implementations. Turns out, I just had to clean the project and restart Eclipse. Problem solved, and lesson learnt!
Check your dependency
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.2.8.Final</version>
</dependency>
Is must be at the same version of your other Hibernate dependencies.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
Just use following dependency, it will fix your issue as this dependency provides basic validation from get go similar to hibernate.
I am using ZK framework version 6.5.2 for my application. And now I want to integrate RESTful to it by using Zest. The problem is, the latest version of Zest is 1.1.0, and it depends on zcommon-5.0.0. So this dependency (zcommon-5.0.0) is duplicated and I excluded it from my POM file, like this:
<dependency>
<groupId>org.zkoss.zest</groupId>
<artifactId>zest</artifactId>
<version>1.1.0</version>
<exclusions>
<exclusion>
<groupId>org.zkoss.common</groupId>
<artifactId>zcommon</artifactId>
</exclusion>
<exclusion>
<groupId>org.zkoss.common</groupId>
<artifactId>zweb</artifactId>
</exclusion>
</exclusions>
</dependency>
As a result zest now depends on zcommon-6.5.2. When I start my app, an error occured:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to org.zkoss.xel.taglib.FunctionDefinition
at org.zkoss.xel.taglib.Taglibs.getFunctionMapper(Taglibs.java:150)
at org.zkoss.xel.taglib.Taglibs.getFunctionMapper(Taglibs.java:109)
at org.zkoss.zest.sys.impl.ParserImpl.parse(ParserImpl.java:97)
at org.zkoss.zest.sys.impl.ParserImpl.parse(ParserImpl.java:54)
at org.zkoss.zest.sys.ZestManager.loadConfiguration(ZestManager.java:98)
at org.zkoss.zest.sys.ZestManager.init(ZestManager.java:70)
at org.zkoss.zest.sys.ZestFilter.init(ZestFilter.java:74)
Here is my web.xml:
<filter>
<filter-name>zest</filter-name>
<filter-class>org.zkoss.zest.sys.ZestFilter</filter-class>
<!-- specifies the class name of the ZEST manager to handle actions Default: org.zkoss.zest.sys.ZestManager -->
<init-param>
<param-name>manager-class</param-name>
<param-value>org.zkoss.zest.sys.ZestManager</param-value>
</init-param>
<!-- specifies the class name of the parser used to parse the configuration file (WEB-INF/zest.xml). Default: org.zkoss.zest.sys.impl.ParserImpl -->
<init-param>
<param-name>parser-class</param-name>
<param-value>org.zkoss.zest.sys.impl.ParserImpl</param-value>
</init-param>
</filter>
And here is rest definition in zest.xml:
<?xml version="1.0" encoding="UTF-8"?>
<zest>
<xel-method prefix="c" name="toMethodName"
class="com.myapp.view.RestAction"
signature="java.lang.String toMethodName(java.lang.String)"/>
<action path="/rest" method="${c:toMethodName(request.method)}"
class="com.myapp.view.RestAction">
<result>/WEB-INF/index.zul</result>
</action>
</zest>
I have compared the source code of these 2 files Taglibs.java in version 5.0.0 and 6.5.2 of zcommon and realized that they have so many differences. I think that the reason caused above problems (the initialization process has changed from 5.0.5 to 6.5.2). Could you please help me solve this problem so that I can integrate zest to my ZK application? Thank you so much.
Zest 1.1 is not compatible with ZK 6.5.2. You have to upgrade to Zest 2.0:
http://mavensync.zkoss.org/maven2/org/zkoss/zest/zest/2.0.0.FL.20130205/