java.lang.NoClassDefFoundError: javax/transaction/UserTransaction - noclassdeffounderror

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

Related

Spring Batch CommandLineJobRunner on linux

I am trying to run my job using SpringBatch-CommandLineJobRunner on Linux, I have the below jars in classpath.
Can anyone please take a look and see If I am missing any jars and tell me the missing jars. In our project they dont want to use any tools like Maven or STS, we are just using eclipse, our jobs run well from eclipse. On Linux we get the below errors.. we are using below command
java -cp org.springframework.batch.core.launch.support.CommandLineJobRunner springbatch/config/applicationBatchContextPlan.xml crossRefAllPlansJob
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/batch/core/launch/support/CommandLineJobRunner
Jars in Classpath on linux :
springbatch/lib/aopalliance-1.0.jar
springbatch/lib/commons-collections-3.2.1.jar
springbatch/lib/commons-lang3-3.3.2.jar
springbatch/lib/commons-lang3-3.3.2-javadoc.jar
springbatch/lib/commons-logging-1.2.jar
springbatch/lib/javax.batch-api-1.0.jar
springbatch/lib/log4j-1.2.17.jar
springbatch/lib/ojdbc6.jar
springbatch/lib/spring-aop-4.1.7.RELEASE.jar
springbatch/lib/spring-aspects-4.1.7.RELEASE.jar
springbatch/lib/spring-batch-core-3.0.4.RELEASE.jar
springbatch/lib/spring-batch-infrastructure-3.0.4.RELEASE.jar
springbatch/lib/spring-beans-4.1.7.RELEASE.jar
springbatch/lib/spring-context-4.1.7.RELEASE.jar
springbatch/lib/spring-core-4.1.7.RELEASE.jar
springbatch/lib/spring-expression-4.1.7.RELEASE.jar
springbatch/lib/spring-jdbc-4.1.7.RELEASE.jar
springbatch/lib/spring-retry-1.1.2.RELEASE.jar
springbatch/lib/spring-tx-4.1.7.RELEASE.jar
Also, I want to know if there is any other way we can run spring batch jobs on linux without using the CommandLineJobRunner.
Based looking at this post and this post, you need to manually include all the jars on your classpath.
So basically:
java -cp ... org.springframework.batch.core.launch.support.CommandLineJobRunner springbatch/config/applicationBatchContextPlan.xml crossRefAllPlansJob
The first post has a handy shell script to help with this.
In terms of other deployment options, you can deploy a spring batch application anywhere you can deploy spring (e.g. servlet container). Generally though, if it is the principal thing going on in the app, a plain old jar is probably the simplest option.
The problem is resolved since a couple of days. The jars in the classpath were not getting picked up properly.After a couple of retries, it did and its working as expected now
Thanks to everyone for helping.
Thanks
Lakshmi

Hadoop Mapreduce ClassNotFoundException

I know this question might have already been answered but i havn't found a proper answer.
I am using hadoop mapreduce on eclipse and i want to create an executable jar to put it on a linux server where there is my hdfs cluster. The problem when i run the jar on my hdfs cluster and eclipse, there is exception appearing caused by java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory. So I added an external jar common-logging but when i run it again and another NoClassDefFoundError appeared but this time with log4j-level and so on. I wondered how many external jar i had to add but i don't think that it's the best solution. Does anyone have the same problem and how did you solve it ?
Thank you very much.
Usually, this error occurs when a previous exception occurred during logging initialisation.
Hadoop is quite fickle about dependencies, you should either make sure that your third party libs are part of your hadoop classpath or create a shaded jar with all dependencies in your job jar. You should use maven or assembly to create that jar.

Including DB2JCC4 in Tomcat 7

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.

Glassfish + PostgreSQL, ClassNotFoundException, mysterious solutions

I have a very annoying problem with Glassfish and PostgreSQL. I have an EAR which contains a WAR and several other EJBs. I am using PostgreSQL. The annoying thing is that sometimes (this sometimes is the most disturbing thing because I have no clue what could go wrong) I get a ClassNotFoundException: java.lang.ClassNotFoundException: org.postgresql.core.Parser
Sometimes (!!!), the problem is solved if I clean and build the whole EAR, sometimes I have to restart the Glassfish, too.
I sometimes get NoClassDefFoundError, too.
Could anybody tell me how to include, package or do anything with the JAR which contains the missing class?
Thank you,
Norbert
Where do you put the jar: directly inside the EAR? Or in the WAR inside the EAR? For JDBC drivers, I think the recommendation is to always put them in the container's shared area and never in an application. (When I used JBoss a couple of years ago, we always put JDBC drivers into server/lib and had trouble if they were included in EARs as well, especially if the versions got out of sync)

Eclipse & JSP: java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.<init>(Ljava/lang/String;ZLjava/lang/String;ZZ)V

I'm using Eclipse 3.4 with WTP 3.0.2 and running a fairly large Dynamic Web Project. I've set up the project so that I can access it at http://127.0.0.1:8080/share/ but whenever I do, I get the following error:
java.lang.NoSuchMethodError: javax.servlet.jsp.tagext.TagAttributeInfo.(Ljava/lang/String;ZLjava/lang/String;ZZ)V
at org.apache.jasper.compiler.TagLibraryInfoImpl.createAttribute(TagLibraryInfoImpl.java:572)
at org.apache.jasper.compiler.TagLibraryInfoImpl.createTagInfo(TagLibraryInfoImpl.java:401)
at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:248)
at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:162)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:423)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:492)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1552)
at org.apache.jasper.compiler.Parser.parse(Parser.java:126)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:211)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)
As none of the above files is my own, pointing out the cause of the problem is quite hard. Any ideas where to start looking?
I ended up answering my own question: the problem was that among the necessary JARs that I had added to Tomcat was a conflicting servlet.jar. When I removed this, the error disappeared.
Did you set a Tomcat path in "Preferences->Tomcat->Advanced->Tomcat base" ?
Try to clean that path (getting back to default configuration), and check if that does solve the problem.
most probably the tomcat plugin in the eclipse cause the conflict problem, i manage to solve the problem by getting the same version jar file and override it in the tomcat plugin in the eclipse.
I had similar problem and I had fixed this problem by Ensuring that i have correct version of servlet.jar in the classpath that is being taken by my application and also i had kept old J2EE.jar file in the classpath and that was causing the main problem. Hence I removed it from the classpath to ensure that it uses by default files.
I had the same problem running Eclipse Helios, with Maven handling dependencies and using Jetty as webserver. After updating to Spring 3.1 I suddenly got this problem, but only on my local development machine.
I first deleted the spring and jetty folders in my local maven repository and updated the dependencies, but that didn't improve the situation.
Then I just deleted the servlet-api and servlet-api-2.5 folders that comes with jetty (but leaving everything else), I got it to work.
All hail the magic of the classpath.