When we started using JPA in WebLogic 10.3.5, we noticed the following exception occasionally. About half of the time we would start the server any JPA call would result in the error, the other half of the time it was fine.
java.lang.ClassCastException: :
org.apache.xerces.parsers.StandardParserConfiguration cannot be cast
to org.apache.xerces.xni.parser.XMLParserConfiguration" occurred while
attempting to determine the version of "myPersistenceXmlFileHere.xml"
Inside our EAR is a xercesImpl jat used by other portions of the project (non-JPA) without issue. I suspect the problem is simply interference from the WebLogic implementation jar.
Update: (Re)deploying in Eclipse seems to reproduce this issue regardless of settings in answer below. Once the exception appears once, it will not resolve and the only solution is to restart the server instance.
In our weblogic-application.xml we added the following, through trial and error. We now do not have any ClassCastExceptions, as the local jar should be taking precedence in this scenario.
<wls:prefer-application-packages>
<wls:package-name>org.eclipse.persistence.*</wls:package-name>
<wls:package-name>org.apache.xerces.xni.parser.*</wls:package-name>
<wls:package-name>org.apache.xerces.parsers.*</wls:package-name>
<wls:package-name>org.apache.xalan.*</wls:package-name>
</wls:prefer-application-packages>
Related
Our web service client in live environment recently got the exception:
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:107)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:135)
at com.sun.proxy.$Proxy146.search(Unknown Source)
....
I've done a lot of search online, including a few posts here at StackOverflow:
Catching webservice exception with CXF: NoClassDefFoundError: SOAPFaultBuilder
Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder
And my understanding was our client received a SOAP Fault from the server and it's missing some jar file. So I'm trying to solve the problem by first recreating it.
I created a simple Web Service server project in Eclipse which has a web method throws a simple fault class annotated by #WebFault. Then I created a simple Web Service client project which consumes the web method. The client project doesn't have any additional libraries/jars in its classpath; all it has is the JRE. To my surprise, it didn't throw the NoClassDefFoundError exception! Instead, I got the javax.xml.ws.soap.SOAPFaultException I defined on the server side.
The class SOAPFaultBuilder is indeed in rt.jar in JRE. So the simple web service projects I created probably just work as they should. However, how come the web service client in our live environment throw the NoClassDefFoundError exception? That project definitely has rt.jar in the classpath.
Can anyone please shed some light on this problem? If it's missing some jar files (either from the jaxws RI or Apache CXF or others), why would the super simple client I created didn't throw the error? Both the live environment and my local environment use Java7u51.
I have encountered the same problem and I could subsequently resolve this.
Due to the following error mentioned in the Problem, the underlying cause of the SOAP Fault could not be found.
I followed the steps mentioned in the following link, to identify the reason for NoClassDefFoundError.
http://javarevisited.blogspot.in/2011/06/noclassdeffounderror-exception-in.html
I could find the following errors in my application log:
java.lang.ExceptionInInitializerError
Caused by: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.internal.bind.api.JAXBRIContext
The reason for the above classcast exception is due to conflicting jar files.
rt.jar (this is present in jre classpath)
jaxb-impl-2.0.1.jar (this is present in my application classpath).
I have removed the file jaxb-impl-2.0.1.jar from my classpath and the actual error is gone.
I had the same erorr and I resolved this issue by deleting the jax-impl.jar from the tomcat lib folder. It was a possible conflict of the jaxb jar versions with one of my webapps installed in tomcat.
http://programtalk.com/java/i-was-running-gwt-application-on-tomca/
This should be a very easy question but I am not able to get this fixed. I have 2 import statements and in Netbeans it does not show any error but when I run the project, I am getting a ClassnotFoundDef error
<%# page import="mastertables.BranchMaster, mastertables.CreateBranchMaster"%>
both the classes are in the same package. The error is
javax.servlet.ServletException: java.lang.NoClassDefFoundError:org/hibernate/HibernateException
Please help, I am stuck on this small thing.
Thanks,
Abhijeet.
The application server is not able to retrieve the org.hibernate.HibernateException in the classpath. In this case i think you actually have the hibernate jars in your classpath, but the application server is complaining about not being able to find its definition.
Think about it: the most obvious exception for a missing dependency would be a ClassNotFoundExeption.
You are not getting this one, and you are also getting problems on instantiating an hibernate exception. Who would throw an hibernate exception if not the hibernate library itself.
So some part of hibernate is already loaded in the classpath, but not this specific class.
In my experience i'd check for libraries version conflicts/mismatch. Check the version of all the hibernate jars and dependencies.
I am trying to run the Spring 4 example given # https://spring.io/guides/gs/messaging-stomp-websocket. When I try to connect to socket, it throws me following exception. As per the example you need tomcat 7.0.50 and I checked the executable jar which has right version of tomcat. Any pointer would be helpful.
java.lang.IllegalArgumentException: No 'javax.websocket.server.ServerContainer' ServletContext attribute. Are you running in a Servlet container that supports JSR-356?
Check that you have tomcat7-websocket.jar and websocket-api.jar bundled in your executable jar - perhaps you're just getting vanilla tomcat without the extra websocket bits.
I got the same error message in another use case: I deactivated auto configuration and added WebSocketConfig manually to the configuration. Then I got the abovementioned error message.
Fixing the problem was easy: just adding WebSocketAutoConfiguration to the configuration.
I know that this is an ancient thread but I ran into this error and resolved it in modern times by adding implementation("org.springframework.boot:spring-boot-starter-tomcat") explicitly to my project.
Struts version of our application is 2.3.8. Getting following exception after every post back to the server.
Application is deployed on to WebSphere server. We don't have any validation xml in the project.
ERROR com.opensymphony.xwork2.validator.AnnotationActionValidatorManager - Caught exception while loading file java/lang/Object-validation.xml
java.lang.NullPointerException at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.loadFile(AnnotationActionValidatorManager.java:391) at com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildClassValidatorConfigs(AnnotationActionValidatorManager.java:279) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildValidatorConfigs(AnnotationActionValidatorManager.java:371) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.buildValidatorConfigs(AnnotationActionValidatorManager.java:350) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.getValidators(AnnotationActionValidatorManager.java:102) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:141) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:133) at
com.opensymphony.xwork2.validator.AnnotationActionValidatorManager.validate(AnnotationActionValidatorManager.java:128) at
com.opensymphony.xwork2.validator.ValidationInterceptor.doBeforeInvocation(ValidationInterceptor.java:222)
There seems to be a bug since Struts2 2.3.4 version. You can refer the JIRA. This bug has been fixed in 2.3.7 version. I would recommend you to verify that all your Struts2 libraries are properly updated and deployed with the correct version. Please try upgrading your Struts2 to higher version. The difference i see is that exception accurs with AnnotationActionValidatorManager in your case, where as in the bug list. it is DefaultActionValidatorManager on which loadFile() method is invoked
Struts2 always loads the validation.xml file present in xwork-version.jar. This might get this error,check it manually once.
Im getting a weird error when running my spring2.5.6,jpa(hibernate3.4) webapp in weblogic 10.3
[ERROR] Javassist Enhancement failed: com.xxx.domain.model.Scheme
java.lang.NoSuchMethodError: pcGetManagedFieldCount
at com.xxx.domain.model.Fund.<clinit>(Fund.java)
at sun.misc.Unsafe.ensureClassInitialized(Native Method)
at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAc
cessorFactory.java:25)
The com.xxx.domain.model.Scheme class is a mapped subclass entity of the abstract fund entity on a single_table inheritance hierarchy, and I'm getting this error for all entities on the hierarchy. I'm using both annotated classes and xml metadata to define the mappings for my persistence classes.
I only get this error when the app is deployed to weblogic, so everything runs fine using junit. I have tried upgrading to the latest version on javaassit.jar.
Problem Looks to me like an issue with classloading order, but I cant figure it out.
PS. As suggested by bea I have added the following to the weblogic.xml
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
Anyone got any ideas, other config tips, or directions I should take my investigation?
I had the same problem.
My entities extended a class (#MappedSuperClass) which lived inside a jar dependency. I had to move that class from the jar into my project. Only then it would work and deployed fine.
Also another way to solve this is to specify your entities explicitly in the persistence.xml
I'm sorry, I only have WebLogic 10.0 on my machine, and it doesn't have any javassist JARs in the distro. Looks like javassist was only added in 10.3 for AOP byte code generation.
It might be worth a try to remove the javassist JAR from your WebLogic deployment and use the version that it supports. Take the "prefer-web-inf-classes" tag out of your web.xml and see if it can work with the version that WebLogic prefers.
Can you post the code for the entity class and, if you're not using annotations, the segment of your hbm mapping file?
Your classpath hunch may be right on. In your weblogic-application.xml, try this
<prefer-application-packages>
<package-name>antlr.*</package-name>
<package-name>org.antlr.*</package-name>
</prefer-application-packages>
If you have any more log output, please post that as well.
I just lost a couple of days on this myself. The problem for me was that I 2 separate data-services modules in my app. I'm thinking 10.3 has some trouble with that. I'm not sure of the solution, but a work around for me was to combine both of my data-services modules into just one.
BEA seems to be aware of this issue. Hopefully the URL below will help. Reference CR370788.
http://edocs.bea.com/wls/docs103/issues/known_resolved.html