I have an enterprise app created in Netbeans 6.8 which comes packaged with a Glassfish V3 server. I've been receiving the following exception from the server log when I try to deploy and run the EAR project:
SEVERE: jdbc.exc_cnfe_ds
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
From googling, the common solution to this is to copy the jar file (mysql-connector-java-5.1.6-bin.jar) containing that class to
$glassfish-v3-install-root/glassfish/domains/domain1/lib.
and in fact that's where it resides on the Unix server. However, I'm testing this on windows and the "domains/domain1" directories don't exist in the default glassfish install. I added them manually and added the jar, but it made no difference. I also added the jar as a variable to the windows classpath, but that also had no effect.
I then tried adding the jar file $glassfish-v3-install-root/glassfish/lib, and that produced a different error:
SEVERE: RAR5111 : Error casting to javax.sql.Datasource
java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource
I'm using the same jar file as exists for the server. I'm guessing the jar is misplaced? I don't want to put it in the project because that's not how it's deployed in production. Any help appreciated.
Putting the jar file in $glassfish-v3-install-root/glassfish/lib turned out to be correct.
The
"SEVERE: RAR5111 : Error casting to javax.sql.Datasource java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource"
error was, I believe, caused by an incorrect setting for the jdbc pooling on the glassfish server. But going to the admin console, available from the Netbeans "server" tab, going to the "JDBC", "Connection Pools", select "java.sql.driver" as the resource type and "com.mysql.jdbc.driver" as the driver classname will get rid of the casting issue.
Click the "Ping" button near the top to make sure you're connecting.
Related
I deployed have build the .war file on centos with eclipse and then deployed it on tomcat 8.5 on centos(Linux). It is working with that. But when I deployed the same ".war" or build a new ".war" file with eclipse on windows It is not working on Tomcat8.5 and it throws BeansInCreation Exception. Having the same Java1.7 and Tomcat8.5 version windows7.
The build was also working on windows on the previous version(before updating)
and there are nothing major changes done in the latest code.
Here are the logs from localhost :
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name '': Bean with name '' has been injected into other beans ['','',''] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:268)
... 98 more
I think the problem may be because of "large file path" as Linux support more large file path than windows. I have changed in the regedit also to support but that doesn't need to have changed.
If it works on linux but not on windows i assume that there is a class loading issue (order of classes) while your war is deployed. I would recommend to check /lib directory inside your .war file.
Maybe it contains different versions from the same jar.
Edited:
You can track the class loading of tomcat (or any java application) on linux and windows. For this you need to start it with a special vm paramter (-verbose:class). take a look here:
Java verbose class loading
Can you please help me with following error I'm facing in WAS9 environment:
In order to resolve the import
org.apache.cxf.binding.soap.SoapHeader
I added the following dependencies in my pom.xml:
cxf-api-2.7.7
cxf-rt-bindings-soap-2.7.7
But when I'm trying to run my application, I'm getting the following error.
Default Executor-thread-7] ([ ]) Controllerclass - org.apache.cxf.bus.extension.ExtensionException
at org.apache.cxf.bus.extension.Extension.load(Extension.java:222)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.loadAndRegister(ExtensionManagerImpl.java:199)
at org.apache.cxf.bus.extension.ExtensionManagerImpl.initialize(ExtensionManagerImpl.java:118)
at org.apache.cxf.bus.extension.ExtensionManagerBus.doInitializeInternal(ExtensionManagerBus.java:147)
at org.apache.cxf.bus.CXFBusImpl.initialize(CXFBusImpl.java:191)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createBus(LibertyApplicationBusFactory.java:119)
at com.ibm.ws.jaxws.bus.LibertyApplicationBusFactory.createClientScopedBus(LibertyApplicationBusFactory.java:86)
at com.ibm.ws.jaxws.metadata.JaxWsClientMetaData.<init>(JaxWsClientMetaData.java:28)
at com.ibm.ws.jaxws.metadata.JaxWsModuleMetaData.getClientMetaData(JaxWsModuleMetaData.java:123)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:84)
at com.ibm.ws.jaxws.support.JaxWsMetaDataManager.getJaxWsClientMetaData(JaxWsMetaDataManager.java:123)
at com.ibm.ws.jaxws.client.LibertyProviderImpl.createServiceDelegate(LibertyProviderImpl.java:56)
at javax.xml.ws.Service.<init>(Service.java:57)
Caused by: java.lang.InstantiationException:org.apache.cxf.bus.osgi.OSGIBusListener
at java.lang.Class.newInstance(Class.java:427)
at org.apache.cxf.bus.extension.Extension.load(Extension.java:218)
Caused by: java.lang.NoSuchMethodException:org.apache.cxf.bus.osgi.OSGIBusListener.<init>()
at java.lang.Class.getConstructor0(Class.java:3082)
at java.lang.Class.newInstance(Class.java:412)
The server where your WAS9 has been deployed has different version of the above jar file. You need to have same version of jar files both in your eclipse where you have developed your codes and the server where you are deploying the war or ear.
mavan dependency file pom.xml is used during your project compilation. It might add the jar in your binary under lib folder as well. But WAS9 might considering the one which is in server's CLASSPATH. Hence check your class path and replace that jar with the one which you have mentioned in your pom.xml file. Hope that will fix your issue.
We can eliminate this exception by adding webProfile-7.0 in our server.xml, but how ever this is not working with javaee-7.0 not sure, if one knows about how to handle this in javaee-7.0 please share your approach.
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/
I have modified an EAR for Weblogic 10 ( BEA 10 )which is already running on BEA 8..
I am getting the following error while deploying the EAR..
[HTTP:101163]Could not load user defined listener: com.xxx.xxxx.jmx.LifecycleListener java.lang.NoClassDefFoundError: com/tibco/sdk/MException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:187) at weblogic.servlet.internal.WebComponentContributor.createListenerInstance
Have you faced this error ?Please help me...
From the Exception it seems that some library is missing from your ear file. Make sure that com.xxx.xxxx.jmx.LifecycleListener is a valid package and included correctly in your ear.
If you are developing and building the ear with JDeveloper make sure you add this lib in your application resources. If you do this manualy make sure that this lib exists in your WEB-INF/lib folder
I've tried to deploy a Netbeans WAR webservice into Glassfish several times, but it returns this error:
Error occurred during deployment: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException:
javax.servlet.ServletException:
com.sun.xml.ws.transport.http.servlet.WSServletException:
WSSERVLET11: failed to parse
runtime descriptor: java.lang.RuntimeException: MASM0015: Class [
com.sun.xml.ws.tx.runtime.TxTubeFactory ] does not implement [
com.sun.xml.ws.assembler.dev.TubeFactory ] interface.
Please see server.log for more details.
Whatever WAR I generate in Eclipse works in Glassfish, but I tried importing from Netbeans this project, and it didn't work. Glassfish also returns this same error. The log doesn't extend the information of the possible problem.
By the way, in the embedded Glassfish for Netbeans, the webservice works like a charm, but importing this, results in an error in the Glassfish server (which is another computer)
Any suggestions? Is there any configuration I need to change in the Glassfish server?
Thank you all for your ideas and solutions.
Cristina
Extract from Server .LOG
[#|2012-05-31T10:16:59.951-
0430|INFO|glassfish3.1|com.sun.xml.ws.wstx|_ThreadID=40;_ThreadName=Thread-1;|[failed
to localize] HOST_AND_PORT_LOOKUP_FAILURE_2015(https://192.168.2.43:8080)
java.lang.ClassNotFoundException: com.sun.enterprise.webservice.WsTxUtils
[#|2012-05-31T10:16:59.990-
0430|SEVERE|glassfish3.1|com.sun.xml.ws.wspolicy.jaxws.PolicyWSDLParserExtension|_ThreadID= 40;_ThreadName=Thread-1;|WSP1007: Policy exception occured when finishing WSDL parsing.
com.sun.xml.ws.policy.PolicyException: [failed to localize]
WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004/08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
Caused by: com.sun.xml.ws.policy.PolicyException: [failed to localize] WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004 /08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field tm to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field wsatCoordinatorService to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field wsatCoordinatorService to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
Something similar happened to me recently. What happened was that initially I was going to deploy the application to Tomcat7, so Netbeans included some Metro jars in my library section. I then decided to deploy to Glassfish instead, however those Metro jars are what are apparently causing the problem you are seeing. I just deleted the Metro jars from my libraries section in Netbeans, redeployed, and everything was ok.
Here is a link that talks a little bit more about what is happening: https://java.net/jira/browse/WSIT-1636.