Including DB2JCC4 in Tomcat 7 - db2

I have just upgraded to Tomcat v7. I am trying to include a jar in the lib that my java classes need. It is DB2JCC4.JAR. I use this to access DB2 on an IBM mainframe.
This used to work fine in Tomcat6.
When I include the jar, then I get errors such as:
Deploying web application directory C:\tomcat7\webapps\dbs
org.apache.catalina.core.ContainerBase addChildInternal
SEVERE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component
.....
caused by: org.apache.tomcat.util.bcel.classfile.ClassFormatException: null is
not a Java .class file....
I have tried putting URIEncoding in the Server.XML but that does not help.
When I take out the DB2JCC4 jar file, I do not get startup errors. Of course, then I cannot access DB2! I appreciate any suggestions.

Try changing $TOMCAT_HOME/conf/catalina.properties and add DB2JCC4.jar to tomcat.util.scan.DefaultJarScanner.jarsToSkip property value. It is used to turn off classpath scanning (which is used across JavaEE 6 specs implementations).

If you were wondering why the issue is happening in the first place and not just a workaround you can find the answer here. IBM has acknowledged the issue and has provided options for fixing it. Essentially a few of the class files are corrupt.

Related

Hibernate configuration with tomcat and eclipse

I'm creating a webApp in eclipse using tomcat & hibernate (for mysql). Ive unit tested by code and I am able to connect to the db and pull data, but I'm running into issues when trying it from the web app.
From the exception it looks like it isnt able to get to the hibernate.cfg.xml, but I've tried placing the file in the src folder, WEB-INF/lib & WEB-INF/classes but I still get the same error.
The line of code that it's failing on is:
Configuration configuration = new Configuration();
I would really really appreciate any help!
ClassPath References:
Project References:
Stacktrace:
java.lang.ExceptionInInitializerError
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
root cause
java.lang.NullPointerException
org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
org.hibernate.cfg.Environment.<clinit>(Environment.java:221)
org.hibernate.cfg.Configuration.reset(Configuration.java:324)
org.hibernate.cfg.Configuration.<init>(Configuration.java:289)
org.hibernate.cfg.Configuration.<init>(Configuration.java:293)
SOLUTION
Thanks to #Engineer, I was able to solve this by removing the jars from WEF-INF/lib & from the class path of the run configuration. Then I added them back using the "Deployment Assembly" menu in eclipse. I also have my project references here.
From Ranga Reddy:
Problem: Because of adding the jars in user library class path.
Solution: Instead of adding the jar files using User Library add the jars using classpath.

java.lang.NoClassDefFoundError: javax/transaction/UserTransaction

I am developing a web app (on tomcat 7) that needs to create a periodic task and so I chose Quartz Scheduler.But every time I start server it throws
java.lang.NoClassDefFoundError: javax/transaction/UserTransaction and
java.lang.ClassNotFoundException: javax.transaction.UserTransaction.
I rechecked many times in classpath and it is surely has this UserTransaction class in javaee.jar by this line of code System.out.println( System.getProperty( "java.class.path" ) );
So could anyone please help me point it out ? . Maybe I am missing something.
Probably (you did not state which javaee.jar you are using) you have the version from Oracle that contains only the API. This jar is suitable for compiling, not for running your application.
Check if you have javaee-api jar in your classpath. Also, you need to check if you have multiple jars carrying the same class. You can see here what all jars have javax/transaction/UserTransaction. For any futher debugging you can follow this
You may solve it just by adding jta.jar

ClassNotFoundException oracle.jdbc.driver.OracleDriver only in servlet, using Eclipse and oracle

The code below fails on the line: Class.forName("oracle.jdbc.driver.OracleDriver");
with the error:
java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
The two printlns print: Wed_Jun_22_11:18:51_PDT_2005 false This makes me think the class exists and can be found. Also this exact same class works in an a non-servlet application.
I have rebooted everything multiple times and regenerated the application/servlet multiple times. All values have been hard coded to make it simple and short.
I'm using: Eclipse JavaEE 1.4.2 Tomcat 7 jdk1.7 Oracle 11g R2 Windows 7 64bit
I have already added the jar files in web-inf. but it is still giving the following error: java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver.
Any suggestions would be great.
It is a bit hard to tell what exactly going wrong without looking into your application and tomcat server. But there are a couple of hints for your issue.
NoClassDefFoundError always makes me think that there is class collision rather than missing jar file. Be ware of the difference between ClassNotFound and NoClassDefFoundError
tomcat loads class in a different way as what normal java app does. Normally, the class loaders in a stand along java app will follow delegate pattern, which means the child class loader will always delegate the class loading job to its parent class loader. But tomcat does not exactly follow this. So it will load(find source file, read byte code and create a instace of class Class) by itself.
So check your tomcat lib as well as all the web apps under the tomcat and see if there are multiple version of ojdbcXXX.jar
Go through C:\apache-tomcat-7.0.47\lib path(this path may be differ ->based on where you pasted the Tomcat server ) then past ojdbc14.jar if its not contain.
Then restart the server in eclipse then run your app on server

Eclipse and Tomcat: Unable to start a War project

My eclipse setup for web project worked before. But all of the sudden it stops working.
Eclipse version Build id: 20100218-1602
It is a very standard setup. I have a servers project setup in eclipse. I have defined an tomcat server in it. I was able to run my web project this way.
Suddenly for some reason today I saw this exception:
org.springframework.beans.factory.CannotLoadBeanClassException:
Error loading class [some.company.persistence.dao.hbm.ProductDaoImpl]
for bean with name 'productDao' defined in class path resource [SomeDB.xml]:
problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError: org/springframework/orm/hibernate3/support
/HibernateDaoSupport
Based on the message above, can anyone suggest what may be broken?
Looks like the hibernate library is missing from the project's classpath. Figure out which one of the spring jars contains HibernateDaoSupport and add it to your project's classpath.

JBoss 5.x and Axis2

What libraries are required to run a Web Service Client that has been generated from Axis 2 on JBoss. So far I have not found anything in my searches.
I assume that the following error:
org.jboss.xb.binding.JBossXBRuntimeException: Failed to create a new SAX parser
Is due to the fact that I have place every jar file from Axis lib folder into my projects
My Solution
Did it the hard way - added and subtracted jars from my lib directory until I got it to deploy and run with no exceptions
Is what you have pasted the root cause of the stack trace? In case it is not, the problem is that probably your app is deployed with xerces related jar files in it (ex: xercesImpl-x.x.x.jar). JBoss is shipped with the xerces jars in its JBOSS_HOME/lib/endorsed folder. If the same classes are deployed with your web app this may result in class loading issues.
You can try to remove the xerces libs from your app and then test the web service client again.
Cheers!