Using the javax.validation API with Spring 3.1.1 - spring-mvc

I'm using
Spring 3.3.1
WebLogic 11g
JDK 1.60_29
I decided that wanted to do Java based form validation. When I went to compile my code I saw that I needed the javax.validation libraries. So, I put these tags in my pom.xml:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.CR5</version>
</dependency>
and I got this ONE extra jar:
validation-api-1.0.CR5.jar
I put that into my war/WEB-INF/lib
I booted up WebLogic 11g and Spring coughed up blood:
[ERROR] - 2012-Jul-06 12:31:13 - servlet.DispatcherServlet:initServletBean(): Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0': Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to find a default provider
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
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:212)
at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1981)
at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1955)
at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1874)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1518)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:484)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:200)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:247)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:671)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:44)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:184)
at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:361)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)
at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)
at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:180)
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:96)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
Caused by: javax.validation.ValidationException: Unable to find a default provider
at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:265)
at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:184)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 57 more
Googling around I kept seeing the javax.validation API mentioned with hibernate. Given that and the error message I took the guess that I needed hibernate to provide something so I added a hibernate jar to my war/WEB-INF/lib, but that caused even more errors.
Any ideas about how I can get Spring 3.1.1 and the javax.validation API to play nice?
Thanks much in advance
Steve

Weblogic 11G is Java EE 5 compliant and thus does not implement the JSR-303, javax.validation, spec, which was added as a part of Java EE 6. Consequently, you must add a default provider for this, such as the Hibernate Validator:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
Alternatively, if you upgrade to a Java EE 6 compliant application server, this dependency can be ignored as it is already included.
Btw, you may want to consider to update your javax.validation dependeny to version 1.0.0.GA.

Related

Start weblogic weblogic12.2.1.4.0 causes exceptions

I imported my maven project then I started my project on my weblogic server but it gives
java.lang.NoSuchMethodError: weblogic.i18n.logging.CatalogMessage.getLocalizerResourceName()
I checked my jar file and I saw it does not contains CatalogMessage class.Do you have any idea how to fix that problem.
My pom fies contains weblogic 10.3.2.0 jar but it does not contains necessary class files
My full error message :
The WebLogic Server encountered a critical failure
Reason:weblogic.common.internal.VersionInfo.initialize(ZLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IIII)V
Exception in thread "main" java.lang.NoSuchMethodError: weblogic.i18n.logging.CatalogMessage.getLocalizerResourceName()Ljava/lang/String;
at weblogic.logging.MessageLogger.log(MessageLogger.java:68)
at weblogic.logging.MessageLogger.log(MessageLogger.java:114)
at weblogic.logging.WLMessageLogger.log(WLMessageLogger.java:52)
at weblogic.kernel.T3SrvrLogger.logServerStateChange(T3SrvrLogger.java:2284)
at weblogic.t3.srvr.T3Srvr.setState(T3Srvr.java:190)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:458)
at weblogic.Server.main(Server.java:67)
I cannot understand why project contains weblogic 10.3.2.0 jar?I use weblogic 12.2.1.4.0 .
My pom file is :
<dependency>
<groupId>com.myRepo.reporter-application.project</groupId>
<artifactId>weblogic</artifactId>
<version>10.3.2.0</version>
<scope>provided</scope>
</dependency>

JavaFx RichText RunTime Error java.lang.NoClassDefFoundError: org/fxmisc/richtext/TextFlowLayout

I have a runtime error for java.lang.Exception: java.lang.NoClassDefFoundError: org/fxmisc/richtext/TextFlowLayout. I'm using java14 and JavaFx13. I use Maven to download the dependencies and use the maven-assembly-plugin to package my dependencies in a single jar.
I already added in require org.fxmisc.richtext in module-info.java. At design time, the class call works. But not at runtime.
Mavem:
<dependency>
<groupId>org.fxmisc.richtext</groupId>
<artifactId>richtextfx</artifactId>
<version>0.10.5</version>
</dependency>
The error occurs when instantiating the class in Runtime:
CodeArea codeArea = new CodeArea();
The MANIFEST.MF file must contain Multi-Release: true
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
Link solution: https://github.com/FXMisc/RichTextFX/issues/966

log4j2 : Async logger is NOT starting

I have recently upgraded my application to use log4j2. I am trying to make use of its async logger feature. However looks like its not creating one.
As per Log4j Async config, it says,
To make all loggers asynchronous, add the disruptor jar to the classpath and set the system property Log4jContextSelector to org.apache.logging.log4j.core.async.AsyncLoggerContextSelector.
I also set the status="trace" in log4j.xml to see if it configures and instantiate async logger. But looks like it failing.
2017-01-25 01:58:30,799 main TRACE Reregistering context (1/1): 'AsyncContext#18b4aac2' org.apache.logging.log4j.core.async.AsyncLoggerContext#6bf08014
2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2'
2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=StatusLogger'
2017-01-25 01:58:30,800 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=ContextSelector'
2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=Loggers,name='
2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=Appenders,name='
2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=AsyncAppenders,name='
2017-01-25 01:58:30,801 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=AsyncLoggerRingBuffer'
2017-01-25 01:58:30,802 main TRACE Unregistering but no MBeans found matching 'org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=Loggers,name=,subtype=RingBuffer'
2017-01-25 01:58:30,803 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext#18b4aac2
2017-01-25 01:58:30,805 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=AsyncLoggerRingBuffer
2017-01-25 01:58:30,806 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=StatusLogger
2017-01-25 01:58:30,807 main DEBUG Registering MBean org.apache.logging.log4j2:type=AsyncContext#18b4aac2,component=ContextSelector
2017-01-25 01:58:30,816 main TRACE Using default SystemClock for timestamps.
2017-01-25 01:58:30,816 main TRACE Using DummyNanoClock for nanosecond timestamps.
2017-01-25 01:58:30,817 main DEBUG Reconfiguration complete for context[name=AsyncContext#18b4aac2] at URI /etc/opt/sun/im/default/config/log4j2.xml (org.apache.logging.log4j.core.async.AsyncLoggerContext#6bf08014) with optional ClassLoader: null
2017-01-25 01:58:30,817 main DEBUG Shutdown hook enabled. Registering a new one.
2017-01-25 01:58:30,818 main DEBUG LoggerContext[name=AsyncContext#18b4aac2, org.apache.logging.log4j.core.async.AsyncLoggerContext#6bf08014] started OK.
As I don't see anything like "Starting AsyncLogger disruptor".
Then as suggested, I tried using asyncLogger tag, I could see it printing,
2017-01-25 00:27:26,970 main TRACE AsyncLoggerConfigDisruptor creating new disruptor for this configuration.
2017-01-25 00:27:26,971 main TRACE property AsyncLoggerConfig.WaitStrategy=TIMEOUT
2017-01-25 00:27:26,987 main DEBUG Starting AsyncLoggerConfig disruptor for this configuration with ringbufferSize=4096, waitStrategy=TimeoutBlockingWaitStrategy, exceptionHandler=org.apache.logging.log4j.core.async.AsyncLoggerConfigDefaultExceptionHandler#7f284218...
2017-01-25 00:27:26,988 main TRACE AsyncLoggerConfig[xmppd] starting...
But again at later stage it throws exception for class not found,
2017-01-25 00:27:31,658 main ERROR Unable to invoke factory method in class class org.apache.logging.log4j.core.async.AsyncLoggerConfig for element AsyncLogger. java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:132)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:942)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:882)
at org.apache.logging.log4j.core.config.AbstractConfiguration.createConfiguration(AbstractConfiguration.java:874)
at org.apache.logging.log4j.core.config.AbstractConfiguration.doConfigure(AbstractConfiguration.java:498)
at org.apache.logging.log4j.core.config.AbstractConfiguration.initialize(AbstractConfiguration.java:227)
at org.apache.logging.log4j.core.config.AbstractConfiguration.start(AbstractConfiguration.java:239)
at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:530)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:603)
at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:620)
at org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:226)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:242)
at org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:45)
at org.apache.logging.log4j.LogManager.getContext(LogManager.java:174)
at org.apache.logging.log4j.LogManager.getLogger(LogManager.java:618)
at org.apache.logging.log4j.LogManager.getRootLogger(LogManager.java:652)
Caused by: java.lang.NoClassDefFoundError: com/lmax/disruptor/EventFactory
at org.apache.logging.log4j.core.config.AbstractConfiguration.getAsyncLoggerConfigDelegate(AbstractConfiguration.java:197)
at org.apache.logging.log4j.core.async.AsyncLoggerConfig.(AsyncLoggerConfig.java:81)
at org.apache.logging.log4j.core.async.AsyncLoggerConfig.createLogger(AsyncLoggerConfig.java:188)
... 23 more
Caused by: java.lang.ClassNotFoundException: com.lmax.disruptor.EventFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 26 more
I have verified, the disruptor jar which I included has this class. I am using disruptor-3.3.6.jar.
Also How to verify that the async logger has started ?
Any help would be appreciated.
Add the LMAX Disruptor dependency.To use AsyncLogger, your pom.xml should be like this
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.7</version>
</dependency>
Further reading : Performance of log4j2 compared to log4j1
Having tried all the suggestions, I had to look for another solution.
First, make sure you have a file called log4j2.component.properties in the classpath. ( in the same place you have log4j2 file src/main/resources)
its content is :
Log4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
Next, verify you have this dependency ( I was getting this Exception in thread "main" java.lang.NoClassDefFoundError: com/lmax/disruptor/EventTranslatorVararg when I didn't have it)
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.4.1</version>
</dependency>
I need to investigate further but it seems that Log4j2 depends on a class com.lmax.disruptor.EventFactory which is no longer present in the disruptor version you are using. Can you use an older version? 3.3.2 should work.
Add these dependancy in your Pom file:
<!-- Exclude Spring Boot's Default Logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Add Log4j2 Dependency -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.7</version>
</dependency>
Adding this dependency solved the issue for me :
<dependency>
<groupId>com.lmax</groupId>
<artifactId>disruptor</artifactId>
<version>3.3.7</version>
</dependency>

wildfly loading class from wrong jar

I am deploying my war file on Wildfly 9
I am getting exception which is quite strange.
17:40:27,952 ERROR [io.undertow.request] (default task-7) UT005023:
Exception handling request to /DirectRegistry/index.htm:
org.springframework.web.util.NestedServletException: Handler
processing fai led; nested exception is
java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:860)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:350)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
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:722) Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletInputStream
at org.springframework.web.multipart.commons.CommonsMultipartResolver.isMultipart(CommonsMultipartResolver.java:110)
at org.springframework.web.servlet.DispatcherServlet.checkMultipart(DispatcherServlet.java:937)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:797)
... 34 more
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletInputStream >from [Module
"org.apache.commons-fileupload:main" from local module loader
#6c3a6465 (finder: local module finder #6d955a6 5 (roots:
C:\JAVA\WF9\wildfly-9.0.0.Final\modules,C:\JAVA\WF9\wildfly-9.0.0.Final\modules\system\layers\base))]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:205)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:455)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:404)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:385)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:130)
... 37 more
My jboss-deployment structure:
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure>
<deployment>
<dependencies>
<!--
we want to use the saaj module provided by JBoss
it looks like we can't use the implementation provided by the JDK - JBoss somehow does not seem to allow it
-->
<module name="com.sun.xml.messaging.saaj" />
<module name="javax.servlet.api"/>
<module name="com.gbst.directregistry.configuration" />
<module name="com.gbst.directregistry.hypersonic" />
<module name="org.apache.commons-fileupload"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
javax.servlet.api in the service/layers/... is where it is located and I have seen that the class is located there.
org.apache.commons-fileupload is something I made myself to contain a class to solve an issue when i had this:
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver"/>
seems like this CommonsMultipartResolver uses : org.apache.commons.fileupload.FileUpload which is not found in the system/layer/.. libs so i added my own lib in module\org\apache\commons-fileupload . Every time i try to invoke my url now it throws the error above. Why is WF trying to find ServletInputStream in org.apache.commons-fileupload even though it is already there in the WF System/layers/ libs even though it is located in javax.servlet.api. This is base libraries for WF so these should ahve precedence.
as for the commons-fileupload.jar is concerned it doesnt not have any Javax package. so i am not sure why is it looking into this jar.
Appreciate any insight.

Problems with servlets and maven

i am trying to build my first servlet using maven but don't know what i should add to the POM so the servlet
I have tried to add the below dependencies to the POM file (I found in one of the posts). The addition enables me to compile my servlet but when i try to run mvn package or to test my JUnits i am getting a ClassFormatError:
Initial SessionFactory creation failed.java.lang.ClassFormatError:
Absent Code attribute in method that is not native or abstract
in class file javax/validation/Validation
The pom.xml is:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<repository>
<id>java.net2</id>
<name>Repository hosting the Java EE 6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
can someone explain and guide?
Thanks
:-)
At the outset, you may want to follow Senthil's comment above.
As for the error, it is because the specified dependency only has the APIs (method definitions) and not the implementation.
Typically, the implementation is provided by the app server. Hence the application should work in an app server which implements Java EE 6 (like Glassfish).
mvn package should not give any error - it is the test phase before packaging which fails, which you can circumvent, if interested using mvn package -DskipTests.

Resources