I have created two Jersey servlet projects using com.sun.jersey.spi.spring.container.servlet.SpringServlet. I use jersey 1.19.1 jars. Both projects has the dependent jars in lib folder. I deployed both the projects in liberty 9 server.
When I try to access the endpoints, one project works fine but not the other one. I have below exception in console if second project does not work. If I restart that project alone (not the server), it works. I do not know why and I try to find the permanent fix for this.
SRVE0271E: Uncaught init() exception created by servlet [jersey-servlet] in application [secondproject]: java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension
SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
If first project does not work, I see the below exception in console.
SRVE0271E: Uncaught init() exception created by servlet [jersey-servlet] in application [firstproject]: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
SRVE0276E: Error while initializing Servlet [jersey-servlet]: javax.servlet.ServletException: SRVE0207E: Uncaught initialization exception created by servlet
Update with full stack:
java.lang.RuntimeException: javax.naming.NameNotFoundException: CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:183)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadOnStartupCheck(ServletWrapper.java:1428)
at com.ibm.ws.webcontainer.webapp.WebApp.doLoadOnStartupActions(WebApp.java:1181)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinally(WebApp.java:1149)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:1055)
at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6499)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:446)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:248)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:313)
at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:251)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:300)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:471)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:405)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:285)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:256)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1153)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.lang.Thread.run(Thread.java:785)
Caused by: javax.naming.NameNotFoundException: CDIExtension
at com.ibm.ws.jndi.internal.ContextNode.lookup(ContextNode.java:218)
at com.ibm.ws.jndi.internal.WSContext.lookup(WSContext.java:297)
at com.ibm.ws.jndi.WSContextBase.lookup(WSContextBase.java:62)
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
... 33 more
Caused by: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
at com.sun.jersey.server.impl.cdi.CDIExtension.getInitializedExtension(CDIExtension.java:181)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactory.<init>(CDIComponentProviderFactory.java:95)
at com.sun.jersey.server.impl.cdi.CDIComponentProviderFactoryInitializer.initialize(CDIComponentProviderFactoryInitializer.java:76)
at com.sun.jersey.spi.container.servlet.WebComponent.configure(WebComponent.java:572)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.configure(ServletContainer.java:332)
at com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:604)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:207)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
... 1 more
Please check this link, it is helpful to me.
You can solve the problem when setting the system-property
com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
This can be done from the GlassFish server console.
Select the node ->Configuration->server-config->JVM Settings
change to the tab ‘JVM Options’
add a new entry
-Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
restart your server
In the logs you can see:
Caused by: java.lang.ClassCastException: com.sun.jersey.server.impl.cdi.CDIExtension incompatible with com.sun.jersey.server.impl.cdi.CDIExtension
Liberty uses Jersey as JAX-RS provider, so you have conflict. You either have to remove these jars from your application, or make sure that JAX-RS feature is not included explicitly or implicitly in your server.xml
The error,
javax.naming.NameNotFoundException: Unable to resolve 'com.sun.jersey.config.CDIExtension'. Resolved 'com.sun.jersey.config'; remaining name 'CDIExtension'
can be caused due to an class import in EJB3
Example:
import javax.enterprise.context.RequestScoped;
#RequestScoped
public class SampleServices {
#EJB
CalcBeanLocal calcBean;
.....
When importing RequestScope "bean.xml" will be added to WEB-INF.
This ca be resolved by using #stateless annotation instead of #RequestScope and by removing the above created "bean.xml" in WEB-INF.
Example:
#stateless
public class SampleServices {
#EJB
CalcBeanLocal calcBean;
.....
Related
I have JAX-RS based REST API running on WebSphere Application Server Version 8.5.5.9 Liberty Profile. It got below dependencies. Webservices worked fine.
Due to some security vulneribilites in Jackson Library I updated to 2.11 version. Now my dependencies look like this:
Now When I start my server or make API call I see the below error message in log:
[6/8/20 16:47:14:929 CDT] 0000004d id= com.ibm.ws.webcontainer.servlet.ServletWrapper E init SRVE0271E: Uncaught init() exception created by servlet [REST Service] in application [webservices]: java.lang.IllegalArgumentException
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:170)
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:153)
at jersey.repackaged.org.objectweb.asm.ClassReader.<init>(ClassReader.java:424)
at com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:138)
at com.sun.jersey.core.spi.scanning.JarFileScanner.scan(JarFileScanner.java:97)
at com.sun.jersey.spi.scanning.servlet.WebAppResourcesScanner$1.f(WebAppResourcesScanner.java:94)
at com.sun.jersey.core.util.Closing.f(Closing.java:71)
at com.sun.jersey.spi.scanning.servlet.WebAppResourcesScanner.scan(WebAppResourcesScanner.java:92)
at com.sun.jersey.spi.scanning.servlet.WebAppResourcesScanner.scan(WebAppResourcesScanner.java:79)
at com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.init(WebAppResourceConfig.java:102)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:89)
at com.sun.jersey.api.core.servlet.WebAppResourceConfig.<init>(WebAppResourceConfig.java:74)
at com.sun.jersey.spi.container.servlet.WebComponent.getWebAppResourceConfig(WebComponent.java:668)
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:435)
at com.sun.jersey.spi.container.servlet.ServletContainer.getDefaultResourceConfig(ServletContainer.java:602)
at com.sun.jersey.spi.container.servlet.WebServletConfig.getDefaultResourceConfig(WebServletConfig.java:87)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:699)
at com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:674)
at com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:205)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:394)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:577)
at javax.servlet.GenericServlet.init(GenericServlet.java:161)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:633)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1161)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4869)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.handleRequest(DynamicVirtualHost.java:297)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:997)
at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost$2.run(DynamicVirtualHost.java:262)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink$TaskWrapper.run(HttpDispatcherLink.java:955)
at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:341)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:471)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:405)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:285)
at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:256)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:504)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:574)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:929)
at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:1018)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1160)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.lang.Thread.run(Thread.java:820)
Only code change I made is replacing
import org.codehaus.jackson.map.ObjectMapper;
with
import com.fasterxml.jackson.databind.ObjectMapper;
Any thoughts on how to resolve this.
I am wondering if I have to update Jersey.
org.codehaus.jackson is an older version of Jackson.
com.fasterxml.jackson represents the new project and package.
Your server is using new version of ObjectMapper so if it do not work, consider to upgrade Jersey also
https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client
https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-server
Tell me at comment if you have any issue ^^
This is the error log resulting from the exception. I'm not sure what causing it to fail during the deployments
2016-05-23 10:19:57,656 INFO [com.sdars.util.EJBUtil]: {java.naming.provider.url=t3:/localhost:7001, java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory, weblogic.jndi.enableServerAffinity=true}
2016-05-23 10:19:57,656 INFO [com.sdars.util.EJBUtil]: javax.naming.ConfigurationException: t3:/localhost:7001 [Root exception is java.net.MalformedURLException: t3:/localhost:7001]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:36)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:808)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:365)
at weblogic.jndi.Environment.getContext(Environment.java:319)
at weblogic.jndi.Environment.getContext(Environment.java:288)
at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
at javax.naming.InitialContext.init(InitialContext.java:244)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
Caused by: java.net.MalformedURLException: t3:/localhost:7001
at weblogic.protocol.ServerURL.parseURL(ServerURL.java:486)
at weblogic.protocol.ServerURL.<init>(ServerURL.java:104)
at weblogic.rjvm.ServerURL.<init>(ServerURL.java:49)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:335)
... 37 more
I believe that the error is due to trivial typo in java.naming.provider.url property value. Missing a / in the url.
Change from : t3:/localhost:7001
to : t3://localhost:7001
You may look at an example here from oracle's documentation.
Exception you are getting is
Root exception is java.net.MalformedURLException: t3:/localhost:7001. Standard weblogic url is of following format.
t3://ip:port
Looks like you are missing / in your url configuration
t3://localhost:7001
Hi may i know which library files am i missing in order to solve this exception ? Please help, thanks.
included : xmlsec-1.4.3
ERROR ] SRVE0777E: Exception thrown by application class 'org.apache.jasper.runtime.PageContextImpl.handlePageException:701'
com.ibm.websphere.servlet.error.ServletErrorReport: java.lang.NoClassDefFoundError: org.apache.xml.security.Init (initialization failure)
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:701)
at [internal classes]
at com.ibm._jsp._newlistener._jspService(_newlistener.java:223)
at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:101)
at [internal classes]
Caused by: java.lang.NoClassDefFoundError: org.apache.xml.security.Init (initialization failure)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:168)
at com.rexit.easc.SoapSender.sentSOAP(SoapSender.java:93)
at com.rexit.easc.testingXML.checkIsmNcd_value(testingXML.java:2815)
at com.rexit.easc.testingXML.proc_MOTOR(testingXML.java:517)
at com.rexit.easc.testingXML.processInput(testingXML.java:269)
at com.ibm._jsp._newlistener._jspService(_newlistener.java:182)
The problem seems to be that Init class can not be initialized (first loaded in JVM), it says initalization failure. From the code the only thing that happens during class initialization (some static code to be called) is creating Log. According to this article IBM WebShere has built-in Apache commons logging. LogFactory might not be created because of WebSphere configuration.
We are trying to get InitialContext using a listener in web.xml of our application and getting below error:
SEVERE: Unable to init UserDataCachejavax.naming.NoInitialContextException: Cannot instantiate class: org.apache.naming.java.javaURLContextFactory [Root exception is
java.lang.ClassNotFoundException: org.apache.naming.java.javaURLContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:17)
This class is present in catalina.jar.
Java version used is jdk1.6.0_02
Tomcat version is tomcat 7
Please let us know if any one has faced this error or is it related to security manager on server?
I am trying to deploy an MDB in WAS 8.5. The session Factory is being initialized in ejbCreate method. When I try to deploy the application ejb loads successfully and then it shuts down the Queue Activation and gives the following exceptions-
I am not using any framework or MAven for built so all the jars and config files have been added to the classpath as in a Standalone Java Application.
Here are the Hibernate and JAVAEE Jars I am using-
antlr-2.7.7
c3p0-0.9.1
commons-collections-3.2.1
commons-logging-api-1.1.3
dom4j-1.6.1
hibernate-c3p0-4.1.5.Final
hibernate-commons-annotations-4.0.1.Final
hibernate-core-4.1.5.Final
hibernate-entitymanager-4.1.5.Final
hibernate-envers-4.1.5.Final
hibernate-jpa-2.0-api-1.0.1.Final
javassist-3.15.0GA.jar
jboss-logging-3.1.0.GA.jar
jboss-transaction-api_1.1_spec-1.0.0.Final
jms-1.1
log4j-1.2.15
MySQL-connector-java-5.1.22
slf4j-api-1.6.1
javaee.jar
javaee-api-6.0
Here is the exception stacktrace from system logs
EJB threw an unexpected (non-declared) exception during invocation of method "onMessage".Exception data:
javax.ejb.EJBException: MDB PostConstruct failure; nested exception is:
java.lang.Exception: See nested Throwable
at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:472)
at com.ibm.ejs.container.MessageDrivenBeanO.initialize(MessageDrivenBeanO.java:427)
at com.ibm.ejs.container.BeanOFactory.create(BeanOFactory.java:147)
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1238)
at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:1356)
at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate
(UncachedActivationStrategy.java:88)
at com.ibm.ejs.container.activator.Activator.preInvokeActivateBean(Activator.java:615)
at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:4205)
at com.ibm.ejs.container.EJSContainer.preInvokeMdbActivate(EJSContainer.java:3709)
at com.ibm.ejs.container.MessageEndpointHandler.beforeDelivery
(MessageEndpointHandler.java:1449)
at com.ibm.ejs.container.MessageEndpointHandler.invokeMessageEndpointMethod
(MessageEndpointHandler.java:866)
at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:832)
at $Proxy50.beforeDelivery(Unknown Source)
at com.ibm.mq.connector.inbound.AbstractWorkImpl.run(AbstractWorkImpl.java:188)
at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java:608)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1783)
Caused by: java.lang.Exception: See nested Throwable
at com.ibm.ejs.container.util.ExceptionUtil.EJBException(ExceptionUtil.java:470)
... 15 more
Caused by: java.lang.NoClassDefFoundError: org.hibernate.HibernateException
at java.lang.J9VMInternals.verifyImpl(Native Method)
at java.lang.J9VMInternals.verify(J9VMInternals.java:85)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:162)
at com.hps.superenrollment.ejbmodule.SuperEnrollmentRequestMDB.ejbCreate
(SuperEnrollmentRequestMDB.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor
(InterceptorProxy.java:232)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed
(InvocationContextImpl.java:559)
at com.ibm.ejs.container.interceptors.InvocationContextImpl.doLifeCycle
(InvocationContextImpl.java:273)
at com.ibm.ejs.container.MessageDrivenBeanO.initialize(MessageDrivenBeanO.java:411)
Please help me as I am completely lost on what is going wrong here .
The NoClassDefFoundError indicates that some Hibernate class is not in your class-path. Are you sure you have all dependency jars in your classpath (including the jars which are needed at runtime)?
The exception indicating that you should use a PostConstructor method instead of the bean class constructor indicates that you should use the ejbCreate() method. This is the recommended location to initialise and load dependencies of your MDB as it is called by one single thread of the ejb container and ensures that the MDB has been fully constructed before you execute the configuration in the ejbCreate(). It is somewhat similar to the init method in a servlet which is also guaranteed to be called single threaded by the servlet container.