servlet.service error, classNotFoundException - java

I am done building the java spring boot app and now I am trying to deploy it to VPS. Everything works except once I access part of web app that is connected to the database I get this error
ERROR 7379 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
When I put connection url to database to be jdbc:mysql://"ip of server":3306/kuponi i get this error
and when I put connection url to database to be jdbc:mysql://localhost:3306/kuponi

Try adding these dependencies to your pom.xml file
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-ri</artifactId>
<version>2.3.3</version>
</dependency>

Related

Http 500 error in soap API java due to jaxb jar file

One of my soapAPI was giving HTTP 500 error. when we searched in log we got the below issue.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator'. Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
To remove this issue we put below jar in our pom.xml
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
and this issue gone. But unfortunately code is creating problem in other places. The functionality which were working earlier now giving http 500 error. When we remove the above jar the original issues comes but new issue vanished.
Are we doing some mistake by including above jar files? is there any guess to get it done? I know issue seems somewhat strange but it is coming like this only. We are using java 8 , jsp and struts.
We did not do any code changes.

how to add jsf com.sun.faces in websphere 9

I want to start my app using com.sun.faces jsf and primefaces dependency in websphere 9.
The part of pox.xml:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
I added jsf-impl-2.2.8-30.jar and jsf-api-2.2.8-30.jar to shared libs in WebSphere (Enterprise Applications > app_name > Shared library references, for application and for module) and got exception in log:
Could not invoke an operation on object: WebSphere:name=ApplicationManager,process=server1,platform=proxy,node=OPOLSKYNode01,version=9.0.0.9,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=OPOLSKYNode01Cell,spec=1.0 because of an mbean exception: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: com.ibm.ws.cdi.CDIRuntimeException: com.ibm.ws.cdi.CDIDeploymentRuntimeException: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.event.ObserverException
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
....
Caused by: java.util.ServiceConfigurationError: com.sun.faces.util.cdi11.CDIUtil: Provider com.sun.faces.util.cdi11.CDIUtilImpl not a subtype
...
Later I found that there was a warning written in websphere (Enterprise Applications > app_name > JSP and JSF options):
Version 9.0 and later nodes use the MyFaces JSF implementation, even if SunRI is selected in a mixed-cell environment. For more configuration information, read about JavaServer Faces in the product documentation.
And I tried to add a shared libraries with mojarra-jsf-impl-2.0.0-b04.jar and mojarra-jsf-api-2.0.0-b04.jar
but got:
com.ibm.ws.classloader.CompoundClassLoader#bce1c60f[war:isclite/isclite.war]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\classes;C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\lib\abdera.client.0.2.2-incubating.jar;C:\Program
...
00000093 annotations W ScannerContextImpl getInputDataForClass Class loader [
com.ibm.ws.classloader.CompoundClassLoader#2d433080[app:isclite]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\lib\batik-all.jar;C:\Program
...
Help me please!
Is it possible to start app with jsf dependency in websphere ?

sendgrid exception java.lang.NoSuchMethodError

I am getting exception when I try to use SendGrid sg = new SendGrid(sendGridAPIKEY);
It gives exception because send grid uses HttpClientBuilder.create().build(); internally.
I resolved this issue by adding following lines
DefaultHttpClient defaultHttpClient = new DefaultHttpClient();
Client sendGridClient = new Client(defaultHttpClient, false);
SendGrid sg = new SendGrid(sendGridAPIKEY, sendGridClient);
where DefaultHttpClient is deprecated.
But I want to know why HttpClientBuilder.create().build() line gives error.
I am using JDK 1.8 and following POM dependency
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<!-- send Grid dependency -->
<dependency>
<groupId>com.sendgrid</groupId>
<artifactId>sendgrid-java</artifactId>
<version>4.0.1</version>
</dependency>
Exception:
Nov 06, 2017 10:15:26 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [spring] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoSuchMethodError: org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V] with root cause
java.lang.NoSuchMethodError: org.apache.http.impl.conn.CPool.setValidateAfterInactivity(I)V
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:176)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.<init>(PoolingHttpClientConnectionManager.java:158)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:973)
at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58)
at com.sendgrid.Client.<init>(Client.java:76)
at com.sendgrid.Client.<init>(Client.java:56)
at com.sendgrid.SendGrid.<init>(SendGrid.java:24)

EJB ETL NoClassDefFoundError: org.apache.poi.util.SAXHelper during runtime

Root pom has the following dependencies,
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.16</version>
</dependency>
But during runtime, during etl process following error occurs,
EJB threw an unexpected (non-declared) exception during invocation of method "****" on bean "BeanId(***-ear#***-ejb.jar#***ServiceImpl, null)". Exception data: java.lang.NoClassDefFoundError: org.apache.poi.util.SAXHelper
Root cause is NoClassDefFoundError in the following code snippet,
XMLReader parser = SAXHelper.newXMLReader();
Environment used,
JDK 1.6.0_35
Websphere Application Server v8.0
Eclipse Juno Service Release 2
Full stack trace can be found here
Caused by: java.lang.ClassNotFoundException: org.apache.poi.util.SAXHelper
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:230)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:703)
at java.lang.ClassLoader.loadClass(ClassLoader.java:682)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:123)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:566)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
... 87 more
note: I have opened the ear archive and found the respective jars available. Checked Eclipse java build path also. Everything seems to be fine.
Thanks.
SAXHelper is in poi-ooxml-3.16.jar. I suspect that one of the static initializers in this class is failing.
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

NoClassDefFoundError: org/directwebremoting/extend/ConvertUtil

After moving a Tomcat app from one server to the other, we get this error:
SEVERE: Servlet.service() for servlet dwr-invoker threw exception
java.lang.NoClassDefFoundError: org/directwebremoting/extend/ConvertUtil
at org.directwebremoting.dwrp.CallBatch.parseParameters(CallBatch.java:135)
at org.directwebremoting.dwrp.CallBatch.<init>(CallBatch.java:47)
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:72)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
We have the dwr.jar in the WEB-INF/lib dir (and I opened it and checked, the org/directwebremoting/extend/ConvertUtil is there)
/srv/tomcat6/webapps/APPNAME/WEB-INF/lib/dwr.jar
UPDATE this is how DWR dependency is defined in the pom.xml
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
<version>3.rc1</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/dwr.jar</systemPath>
</dependency>

Categories

Resources