javaURLContextFactory ClassNotFound - java

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?

Related

Application not deploying on Tomcat server

I am trying to run an application on tomcat server. The application was earlier running on Jboss EAP. All the configuration changes have been made in the tomcat context.xml and other application related configuration files like web.xml, etc. The only ERROR and SEVERE logs that I see when the application is being deployed are mentioned below:
[main] ERROR org.springframework.web.context.ContextLoader - Context
initialization failed
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'redisCacheManager' defined in class path
resource [config/serviceContext.xml]: Instantiation of bean failed;
nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.tcs.cdm.cache.CacheManager]: Constructor threw
exception; nested exception is java.lang.Error: Unresolved compilation
problems: The type redis.clients.jedis.JedisPoolConfig cannot be
resolved. It is indirectly referenced from required .class files
. . .
SEVERE: Exception sending context initialized event to listener
instance of class
[org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'redisCacheManager' defined in class path
resource [config/serviceContext.xml]: Instantiation of bean failed;
nested exception is
org.springframework.beans.BeanInstantiationException: Failed to
instantiate [com.tcs.cdm.cache.CacheManager]: Constructor threw
exception; nested exception is java.lang.Error: Unresolved compilation
problems: The type redis.clients.jedis.JedisPoolConfig cannot be
resolved. It is indirectly referenced from required .class files
. . .
SEVERE: One or more listeners failed to start. Full details will be
found in the appropriate container log file
org.apache.catalina.core.StandardContext startInternal SEVERE: Context
[/AppName] startup failed due to previous errors
I have gone through several threads but did not find any solution working for me. I have tried making version changes to jsf related jars in my pom.xml but that also doesn't help. I am currently using tomcat version 9.0.36 but have also tried TomEE 8.0.8 for the same but facing the same issue in both the cases. It would be great if someone could guide as to why this error is coming or a possible solution for the same.

javax.naming.NameNotFoundException: CDIExtension

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;
.....

ConnectorRuntimeException: Invalid resource

I am creating an enterprise java application using netbeans 8.0.1 java EE6 and glassfish server 4.1.1 attached with netbeans.
When I have created the db in mysql and connected successfully and created entity class from database and session bean for that entity class and I am going to deploy the application it gives this error:
Caused by: com.sun.appserv.connectors.internal.api.ConnectorRuntimeException: Invalid resource : java:module/custordermgt__pm
at org.glassfish.jdbcruntime.service.JdbcDataSource.validateResource(JdbcDataSource.java:81)
at org.glassfish.jdbcruntime.service.JdbcDataSource.setResourceInfo(JdbcDataSource.java:62)
at org.glassfish.jdbcruntime.JdbcRuntimeExtension.lookupDataSourceInDAS(JdbcRuntimeExtension.java:136)
at com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:589)
What caused this exception?
This is probably due to a NetBeans bug. Take a look at the solution here: https://stackoverflow.com/a/56921913/1429984

Getting runtime error while trying to connect mysql from java

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver from [Module "deployment.Sample.war:main" from Service Module Loader].
The above one is my error message.
I have included mysql-connector-java-5.1.35-bin.jar in my class path and it is shown in the libraries as well.
I am using JBoss AS 7.1.0.Final server to run it. How to resolve this error?

JNDI lookup fails in Glassfish

I am working on a web project using maven.When I run the server on net-beans 6.8,the build is succes,but when deploying to server I am getting lookup failed exception.Please find the server log in the following url http://pastie.org/1997218. Let me know What I have missed here. The stack trace for the error is
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
java.lang.RuntimeException: javax.naming.NamingException: Lookup failed for 'jdbc/deliver' in SerialContext [Root exception is javax.naming.NameNotFoundException: deliver not found]
at org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.<init> (PersistenceUnitInfoImpl.java:111)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:130)
at org.glassfish.persistence.jpa.PersistenceUnitLoader.<init>(PersistenceUnitLoader.java:96)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:121)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:644)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:296)
...
As it seems your production server is missing the database resource jdbc/deliver your application needs. You have configured it properly for your test instance in NetBeans. Have a look at the Services tab in NetBeans and make sure you have a similar database set up on your server.

Categories