How do I check if a maven dependency works with Tomcat 9 - spring-boot

I want to use this dependency in my project.
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13.3</version>
</dependency>`
It works in embedded tomcat 8 in my local.
But I want to know if Tomcat 9 also supports it or not. Because while running it in Tomcat 9 server I am getting an error:
java.lang.NoClassDefFoundError: org/bouncycastle/asn1/ASN1Primitive
How do i know this is caused by tomcat 9?

Related

Cannot load JDBC Driver class in Birt 4.6.0-20160607

i am having a Java EE project in which i include the Birt runtime as a maven dependency:
<dependency>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.eclipse.birt.runtime</artifactId>
<version>4.6.0-20160607</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.birt.runtime</groupId>
<artifactId>org.apache.xerces</artifactId>
</exclusion>
<exclusion>
<artifactId>org.apache.poi</artifactId>
<groupId>org.eclipse.birt.runtime</groupId>
</exclusion>
</exclusions>
</dependency>
The engine seems to be created (i hope at least) . In my report i have defined the datasource settings.
<data-sources>
<oda-data-source extensionID="org.eclipse.birt.report.data.oda.jdbc" name="somename" id="43">
<list-property name="privateDriverProperties">
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
</list-property>
<property name="odaDriverClass">oracle.jdbc.driver.OracleDriver</property>
<property name="odaURL">jdbc:oracle:thin:#host...</property>
<property name="odaUser">username</property>
<encrypted-property name="odaPassword" encryptionID="base64">password</encrypted-property>
</oda-data-source>
</data-sources>
Unfortunately it seems that Birt cannot find the ojdbc driver (Note, we use an oracle database) and we get the following error:
SEVERE [org.eclipse.birt.data.engine.odaconsumer] (default task-20)
Unable to open connection.:
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC
Driver class: oracle.jdbc.driver.OracleDriver.
I have included in my Web module under WEB-INF/lib the following jar org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar but i am still getting the same error.
Is there any way to solve this by adding the ojdbc as a maven dependency or is there any other workaround ?
Update: I have tried to also to add the also the org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar as a maven dependency.
<!-- Oracle JDBC driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.birt</groupId>
<artifactId>ojdbc</artifactId>
<scope>system</scope>
<version>1.0</version>
<systemPath>${basedir}\src\main\resources\lib\org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar</systemPath>
</dependency>
I am getting the same error. Bellow some part of the stacktrace:
2017-01-05 13:07:11,990 SEVERE
[org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default
task-45) DriverClassLoader failed to load class:
oracle.jdbc.driver.OracleDriver: java.lang.ClassNotFoundException:
oracle.jdbc.driver.OracleDriver
at org.eclipse.birt.core.framework.URLClassLoader.findClass1(URLClassLoader.java:188)
......
......
2017-01-05 13:07:12,020 SEVERE
[org.eclipse.birt.data.engine.odaconsumer] (default task-45) Unable to
open connection.: org.eclipse.birt.report.data.oda.jdbc.JDBCException:
Cannot load JDBC Driver class: oracle.jdbc.driver.OracleDriver.
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.findDriver(JDBCDriverManager.java:881)
Update 2: I made further changes but still without success. I added the org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar library in all my modules under WEB-INF and MEtA-INF
\src\main\webapp\WEB-INF\lib\org.eclipse.birt.report.data.oda.jdbc_4.6.0.v201606072122.jar
The results are quite the same:
2017-01-05 15:40:49,927 SEVERE
[org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default
task-19) DriverClassLoader failed to load class:
org.eclipse.birt.report.data.oda.jdbc:
java.lang.ClassNotFoundException:
org.eclipse.birt.report.data.oda.jdbc
I would also like to note here something. For our persistence in the application, we use a datasource on our wildfly in which we use the ojdbc driver as a module in Wildfly 10 .
I am slowly running out of ideas with Birt + ojdbc
Finally solved the problem. I had to install the oda jdbc driver in my local manen repository and add it as a dependency in my ejb module.
<dependency>
<groupId>org.eclipse.birt.ojdbc</groupId>
<artifactId>odajdbc</artifactId>
<version>4.6.0-201606072122</version>
</dependency>
Furthermore, for some reason which i cannot yet explain, Birt required also the ojdbc6 driver in my web module. I honestly cannot understand why, since the entire birt implementation and runtime is in the ejb module.
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4.0</version>
</dependency>
That solved the problem and now the reports are getting generated.
I am now facing two new problems which i have to solve.
1) java.lang.OutOfMemoryError: Java heap space : I found in Eclipse bugzilla that this problem can be solved with the ojdbc7 driver. The reports are not generated unless i push my servers -Xmx above 1400mb
2) [org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager] (default task-20) DriverClassLoader failed to load class: oracle.jdbc.driver.OracleDriver: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver: For some reason i get this error only one time when i want to generate a report. The report is generated without problems and the exception never appears again.
At least the reports are working now and can continue solving the other issues.

Spring boot jar Unable to start embedded Tomcat

i have created spring rest services using eclipse IDE. It works fine in eclipse when i run using Debug configurations however when I export it as a executable JAR and run using below command
java -jar cs.jar
it gives me below error:
org.springframework.context.ApplicationContextException: Unable to start embedde
d container; nested exception is org.springframework.boot.context.embedded.Embed
dedServletContainerException: Unable to start embedded Tomcat
at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.onRefresh(EmbeddedWebApplicationContext.java:124)
at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:474)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationConte
xt.refresh(EmbeddedWebApplicationContext.java:109)
why it's not working as a jar?
You need to check if you have included servlet-api jar in your classpath, if yes, delete it.
If servlet-api is in classpath, it is included in WEB-INF/lib and then the error is thrown because servlet container has already servlet api jar.
Delete servlet-api dependency from maven or gradle if exits or if this dependency is adding by any other module then exclude servlet api dependency like below
<dependency>
<groupId><groupId></groupId>
<artifactId><some dependency></artifactId>
<version><version></version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>

Servlet 500 error ClassNotFound exception

I'm building a web app using Vaadin and it needs to communicate with several REST APIs. I've set it up in IntelliJ with Maven. I was thinking for the REST client I would use GSON to parse the JSON objects I'd be receiving from the open APIs, however, the application crashes due to a servlet exception error.
Caused by:
java.lang.ClassNotFoundException: com.google.gwt.json.client.JSONObject
I've added the GSON dependency to the pom.xml:
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
And have tried changing the module settings from Provided to Compiled to Runtime but with no change.
I'm just stumped as to why the GSON jar appears in the project dependencies within IntelliJ using Maven but fails on run time. I've seen references to Eclipse and including the jar in the classpath but, again, I'm using IntelliJ/Maven to build my Vaadin project and satisfy dependencies.
Any help is greatly appreciated!
Add below dependency in your classpath:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>2.3.0</version>
</dependency>

Exception occurred while accessing jsf page: Servlet.service() for servlet default threw exception: java.lang.NoSuchMethodError

I'm trying to develop a web application using following technologies JSF 2.0 , EJB 3, JPA, Maven.. It's based on MVC design pattern so I have 3 projects so far: one is an EJB project which contains business and model, the second one is the view part which contains JSF and all beans that will be used in JSF pages and the third one is an EAR projects used to unite previous project that I mentioned.
So far I made a simple app and the EAR Project was deployed successfully in JBoss 7 but whenever I try to access a page I get the following exception:
Servlet.service() for servlet default threw exception: java.lang.NoSuchMethodError: com.ocpsoft.pretty.PrettyContext.newDetachedInstance(Ljavax/servlet/http/HttpServletRequest;)Lcom/ocpsoft/pretty/PrettyContext;
I want to mention that I'm not so familiar with these technologies.
Please let me know if you want to give you additional info such as maven dependencies or whatever you think that it can cause this error.
I have the following dependencies related to prettyfaces:
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>ocpsoft-pretty-faces</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.11.Final</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-integration-faces-annotations</artifactId>
<version>2.0.0.Alpha5</version>
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-config-prettyfaces</artifactId>
<version>2.0.11.Final</version>
</dependency>
I guess that the prettyfaces-core is missing, try to add this dependency :
<dependency>
<groupId>com.ocpsoft</groupId>
<artifactId>prettyfaces-core</artifactId>
<version>3.0.0</version>
</dependency>
I'm not sure about it, if it doesn't work, try the depedencies listed in the link below
http://mavenhub.com/c/com/ocpsoft/pretty/prettycontext

Running Arquillian in Equinox

I'm trying to run integration tests in an OSGi container, namely the Equinox container embedded in Eclipse, using Arquillian in remote mode.
I followed the instructions given on the JBoss OSGI site. So I began by provisionning my target platform by adding these artefacts (which I found by browsing the jboss repository) :
<dependency>
<groupId>org.jboss.arquillian.osgi</groupId>
<artifactId>arquillian-osgi-bundle</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<!-- required by arquillian-osgi-bundle -->
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.1.0.GA</version>
</dependency>
<dependency>
<groupId>org.jboss.osgi.jmx</groupId>
<artifactId>jboss-osgi-jmx</artifactId>
<version>1.0.10</version>
</dependency>
When I try to validate the bundles, I get unsatisfied imports from jboss-osgi-jmx :
missing package org.jboss.osgi.spi.capability
missing package org.jboss.osgi.testing
Apparently, the missing packages belong to these artifacts (once again, found by browsing):
<!-- osgi.spi : this one ?-->
<dependency>
<groupId>org.jboss.osgi</groupId>
<artifactId>jboss-osgi-spi</artifactId>
<version>1.0.10</version>
</dependency>
<!-- or that one ?-->
<dependency>
<groupId>org.jboss.osgi.spi</groupId>
<artifactId>jbosgi-spi</artifactId>
<version>1.0.26</version>
</dependency>
<!-- osgi.testing -->
<dependency>
<groupId>org.jboss.osgi.testing</groupId>
<artifactId>jbosgi-testing</artifactId>
<version>1.0.4</version>
</dependency>
But neither of these artifacts is an OSGI bundle, so I'm stuck with unresolved constraints.
So, my questions are :
did I screw up my platform configuration ?
does anybody already succeeded at using Arquillian inside a non-JBoss
osgi container in remote mode (plain felix would be OK) ?
Try Pax Exam for OSGi testing. You can choose between embedded and remote usage (Native Test Container vs. Forked Test Container).
Pax Exam supports all OSGI 4.2 compliant frameworks. It it regression tested on Equinox, Felix and Knopflerfish.

Resources