How to create a postgresql xa datsource in wso2esb - wso2

how to manage the transactions in wso2esb or wso2dss
we have option to create a datasource in wso2esb.While i am creating external datasource with xadatasource but its unable to create its giving issue i created with below configuration
Data Source Type*=RDBMS
Name*=USCProduction
Data Source Provider*=External Data Source
Data Source Class Name*=org.postgresql.xa.PGXADataSource
Data Source Properties
====================
url=jdbc:postgresql://localhost:5432/USCProduction
user=admin
password=admin
bbut its unable to create giving error like this
ERROR: Error in creating external data source: org.postgresql.xa.PGXADataSource
ERROR - DataSourceRepository Error in creating external data source: org.postgresql.xa.PGXADataSource
org.wso2.carbon.ndatasource.common.DataSourceException: Error in creating external data source: org.postgresql.xa.PGXADataSource
at org.wso2.carbon.ndatasource.rdbms.utils.RDBMSDataSourceUtils.handleExternalDataSource(RDBMSDataSourceUtils.java:323)
at org.wso2.carbon.ndatasource.rdbms.utils.RDBMSDataSourceUtils.createPoolConfiguration(RDBMSDataSourceUtils.java:283)
at org.wso2.carbon.ndatasource.rdbms.RDBMSDataSource.<init>(RDBMSDataSource.java:42)
at org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader.createDataSource(RDBMSDataSourceReader.java:58)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.createDataSourceObject(DataSourceRepository.java:202)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.registerDataSource(DataSourceRepository.java:359)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.addDataSource(DataSourceRepository.java:473)
at org.wso2.carbon.ndatasource.core.services.NDataSourceAdminService.addDataSource(NDataSourceAdminService.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
how we can do this and try with this also copied this into datasources file
<datasource>
<name>sample</name>
<xa-datasource jndi-name="java:jboss/PostgresXADS" pool-name="PostgresXADS">
<driver>postgresql</driver>
<xa-datasource-property name="ServerName">localhost</xa-datasource-property>
<xa-datasource-property name="PortNumber">5432</xa-datasource-property>
<xa-datasource-property name="DatabaseName">USCProduction</xa-datasource-property>
<security>
<user-name>admin</user-name>
<password>admin</password>
</security>
<validation>
<valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker">
</valid-connection-checker>
<exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter">
</exception-sorter>
</validation>
</xa-datasource>
<drivers>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasource>
how can i create xa datasource in wso2esb to use transaction mediator

You need to add the PostgreSQL JDBC Driver to ESB_HOME/repository/components/lib, and restart the server.

Related

IWAB0014E Unexpected exception occurred using apache-cxf

I am trying to create a simple soap web service application using Eclipse - Spring tools Suite
(4.10.0.RELEASE) and I encountered this error.
I am using Tomcat v10.0 server, and Apache-CXF-3.4.3. Can anyone please help me out with this exception?
IWAB0014E Unexpected exception occurred.
Cannot invoke "org.eclipse.core.resources.IResource.getFullPath()" because "srcDirectoryResource" is null
java.lang.NullPointerException: Cannot invoke "org.eclipse.core.resources.IResource.getFullPath()" because "srcDirectoryResource" is null
at org.eclipse.jst.ws.jaxws.core.utils.JDTUtils.getJavaProjectSourceDirectoryPath(JDTUtils.java:159)
at org.eclipse.jst.ws.jaxws.core.utils.JDTUtils.getJavaProjectSourceDirectoryPath(JDTUtils.java:146)
at org.eclipse.jst.ws.internal.cxf.creation.core.commands.WSDL2JavaDefaultingCommand.execute(WSDL2JavaDefaultingCommand.java:111)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.runCommand(CommandFragmentEngine.java:421)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.visitTop(CommandFragmentEngine.java:361)
at org.eclipse.wst.command.internal.env.core.fragment.CommandFragmentEngine.moveForwardToNextStop(CommandFragmentEngine.java:256)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager$6.run(SimpleCommandEngineManager.java:296)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:436)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:352)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1033)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleCommandEngineManager.runForwardToNextStop(SimpleCommandEngineManager.java:266)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.runForwardToNextStop(WizardPageManager.java:93)
at org.eclipse.wst.command.internal.env.ui.widgets.WizardPageManager.getNextPage(WizardPageManager.java:156)
at org.eclipse.wst.command.internal.env.ui.widgets.SimpleWizardPage.getNextPage(SimpleWizardPage.java:138)
at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:910)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:468)
at org.eclipse.jface.dialogs.Dialog.lambda$0(Dialog.java:619)
at org.eclipse.swt.events.SelectionListener$1.widgetSelected(SelectionListener.java:84)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:252)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4209)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1043)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4026)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3626)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:823)
at org.eclipse.jface.window.Window.open(Window.java:799)
at org.eclipse.wst.command.internal.env.ui.widgets.popup.DynamicPopupWizard.run(DynamicPopupWizard.java:132)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:239)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:580)
at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:414)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4209)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1043)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4026)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3626)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
at org.eclipse.equinox.launcher.Main.run(Main.java:1461)```
Looks like https://bugs.eclipse.org/570817. You can manually edit the project's .classpath file so that the source folder entry is first, or update the underlying Eclipse to 2021-06 and WTP 3.22.

Indexing doc/pdf/docx file into solr using ContentStreamUpdateRequest

Hi I am here using Solr 4.7.2 for indexing the document.
Using ContentStreamUpdateRequest of solrj I am trying to index a file in Solr but while
I am sending a file path and unique id field as an input using UI
In action class while sending the object of ContentStreamUpdateRequest passing parameter to solrServer object
i.e
SolrServer solrServer = ..;
solrServer.request(contentStreamUpdateRequest);
I am getting following error
Exception:
org.apache.solr.client.solrj.SolrServerException
Exception message:
error reading streams
Exception trace:
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:382)
at org.apache.solr.client.solrj.impl.HttpSolrServer.request(HttpSolrServer.java:199)
at com.adastra.candidate.search.solr.action.SolrUpdateAction.aaaExecute(SolrUpdateAction.java:49)
at com.adastra.base.action.BaseAction.execute(BaseAction.java:181)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
at java.lang.Thread.run(Unknown Source)
Can please suggest me in fixing it.
I think that in version 4.7.2 streaming is disabled by default and you have to enable it in file solrconfig.xml
change
<requestParsers enableRemoteStreaming="false"
to
<requestParsers enableRemoteStreaming="true"
Also, have a look at the documentation
http://wiki.apache.org/solr/SolrSecurity#Streaming_Consideration
Let me know if this fixed the issue. Be aware of security when enabling remote streaming.

External DataSources not working with secured WSO2 DSS 3.2.2

Following is a sample dbs file which is deployed as dataservice in WSO2_DSS_3.2.2
<data name="login" serviceNamespace="www.abc.com/services/security" transports="http https">
<description>security service</description>
<config id="a_security">
<property name="carbon_datasource_name">sample-ds</property>
</config>
<query id="login" useConfig="a_security">
...
</query>
<operation name="login">
<call-query href="login">
...
</call-query>
</operation>
<resource method="POST" path="login">
...
</resource>
</data>
And sample-ds is setup from management console (its saved in registry). And this worked fine in a fresh DSS but when I applied a certificate with the DSS, it gives the following error. I tried this with several fresh DSS copies but same happens when applying the certificate.
ERROR {org.wso2.carbon.ndatasource.core.DataSourceRepository} - Error in updating data source [remove:false] at path '/repository/components/org.wso2.carbon.ndatasource/mdl-psm-ds': Error in updating data source 'mdl-psm-ds' from registry [remove:false]: Error in secure load of data source meta info: errorDuringDecryption
org.wso2.carbon.ndatasource.common.DataSourceException: Error in updating data source 'mdl-psm-ds' from registry [remove:false]: Error in secure load of data source meta info: errorDuringDecryption
at org.wso2.carbon.ndatasource.core.DataSourceRepository.updateDataSource(DataSourceRepository.java:186)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.updateAllUserDataSource(DataSourceRepository.java:135)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.refreshAllUserDataSources(DataSourceRepository.java:115)
at org.wso2.carbon.ndatasource.core.DataSourceRepository.initRepository(DataSourceRepository.java:92)
at org.wso2.carbon.ndatasource.core.DataSourceManager.initTenant(DataSourceManager.java:92)
at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.initSuperTenantUserDataSources(DataSourceServiceComponent.java:189)
at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.checkInitTenantUserDataSources(DataSourceServiceComponent.java:180)
at org.wso2.carbon.ndatasource.core.internal.DataSourceServiceComponent.setRegistryService(DataSourceServiceComponent.java:131)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
The reason is registry data related to data source has been encrypted from previous key and try to decrypt using the new key.To overcome this issue, you can reconfigure datasource with the same name after the server is started up. Then datasouce passwords will be encrypted again with the new certificate.
If the main error is Caused by: org.wso2.carbon.core.util.CryptoException: A crypto service implementation has not been registered., add below component class to org.wso2.carbon.core project:
package org.wso2.carbon.core.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.crypto.api.CryptoService;
/**
* #scr.component name="carbon.core.dshcomponent" immediate="true"
* #scr.reference name="carbonCryptoService" interface="org.wso2.carbon.crypto.api.CryptoService"
* cardinality="0..1" policy="dynamic" bind="setCarbonCryptoService" unbind="unsetCarbonCryptoService"
*/
public class CarbonCoreDataHolderHelperComponent {
private static Log log = LogFactory.getLog(CarbonCoreDataHolderHelperComponent.class);
private CarbonCoreDataHolder dataHolder = CarbonCoreDataHolder.getInstance();
protected void activate(ComponentContext ctxt) {
}
protected void deactivate(ComponentContext ctxt) {
}
protected void setCarbonCryptoService(CryptoService cryptoService){
if (log.isDebugEnabled()) {
log.debug("crypto service loaded..");
}
dataHolder.setCryptoService(cryptoService);
}
protected void unsetCarbonCryptoService(CryptoService cryptoService){
dataHolder.setCryptoService(null);
if (log.isDebugEnabled()) {
log.debug("crypto service unloaded..");
}
}
}
This Component will bind crypto service prior to user datasource initilization.

P6SpyDriver cannot be cast to javax.sql.XADataSource exception while trying to configure P6Spy 2.0 with xa-datasource using Jboss AS 7 and potgres

P6spy v2 has a support for xa datasources - P6spy on github
In my jboss AS 7 standalone-full-ha.xml, i have the following datasource configurations.
<xa-datasource jndi-name="java:jboss/datasources/MyDS" pool-name="v" enabled="true" use-java-context="true" use-ccm="false">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="PortNumber">
5432
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
MyDB
</xa-datasource-property>
<driver>p6spy</driver>
<xa-pool>
<min-pool-size>50</min-pool-size>
<max-pool-size>150</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
<driver name="p6spy" module="com.p6spy">
<xa-datasource-class>com.p6spy.engine.spy.P6SpyDriver</xa-datasource-class>
</driver>
</drivers>
After that, i put the p6spy-2.0.1.jar in jboss\modules\com\p6spy\main folder and also defined the module.xml file. Also, i put the spy.properties file alongwith the P6spy.jar and in that added the line to enable postgres driver
realdriver=org.postgresql.Driver
With all these settings, when i start my server, i get the following exception.
Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Could not create connection
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:447)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:385)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761)
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397)
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.getManagedConnection(AbstractConnectionManager.java:329)
at org.jboss.jca.core.connectionmanager.tx.TxConnectionManagerImpl.getManagedConnection(TxConnectionManagerImpl.java:368)
at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.allocateConnection(AbstractConnectionManager.java:464)
at org.jboss.jca.adapters.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:129)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:67) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcServicesImpl.java:253) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:119) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:75) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:159) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:71) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2270) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2266) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1735) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:84) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:904) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:889) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73) [hibernate-entitymanager-4.0.1.Final.jar:4.0.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:162) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.start(PersistenceUnitServiceImpl.java:85) [jboss-as-jpa-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_40]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_40]
at java.lang.Thread.run(Thread.java:724) [rt.jar:1.7.0_40]
Caused by: java.lang.ClassCastException: com.p6spy.engine.spy.P6SpyDriver cannot be cast to javax.sql.XADataSource
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:553)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:430)
... 30 more
At this step i am clueless as to how should i make it work.
Edit:
As per quintonm's reply, i used com.p6spy.engine.spy.P6ConnectionPoolDataSource class which implements XADatasource. But now i am getting the following exception.
Caused by: javax.resource.ResourceException: Could not find accessor on XADataSource:
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:629)
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:430)
... 30 more
Caused by: java.lang.NoSuchMethodException: com.p6spy.engine.spy.P6ConnectionPoolDataSource.setDatabaseName(java.lang.String)
at java.lang.Class.getMethod(Class.java:1655) [rt.jar:1.7.0_40]
at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXADataSource(XAManagedConnectionFactory.java:597)
Also, following the generic instructions stated in P6spy's documentation, i used the 'RealDataSource' property in xa-datasource-properties but it then says no such property exist.
The problem that you are currently facing is that JBoss is expecting you to use a class that implements the Datasource interface in xa-datasource-class. For the P6Spy driver definition, you are using P6SpyDriver which implements java.sql.Driver. Instead of using P6SpyDriver, you want to use com.p6spy.engine.spy.P6ConnectionPoolDataSource.
P6Spy's support for DataSource implementations in JNDI is a little different than using a Driver class. Instead of modifying the JDBC URL, you must setup a second JDNI DataSource. The one that the application connects to will be the P6Spy DataSource. That DataSource will be a proxy to the real data source. The instructions for setting this up are be found here.
Note: The instructions say that you should use P6DataSource. However, since you need XA support, you will need to use P6ConnectionPoolDataSource.
For a better understanding of how this works, you can take a look at the test for XADataSources - XADataSourceTest
If you have any problems getting this to work, just post a message to p6spy-users#googlegroups.com or enter an issue
well, after the update of the question, your config should look like this. Didn't give it a test try, but in general, you need to proxy your existing one (postgres one) via p6spy:
<xa-datasource jndi-name="java:jboss/datasources/MyDSReal" pool-name="v" enabled="true" use-java-context="true" use-ccm="false">
<xa-datasource-property name="ServerName">
localhost
</xa-datasource-property>
<xa-datasource-property name="PortNumber">
5432
</xa-datasource-property>
<xa-datasource-property name="DatabaseName">
MyDB
</xa-datasource-property>
<driver>postgresql</driver>
<xa-pool>
<min-pool-size>50</min-pool-size>
<max-pool-size>150</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
<xa-datasource jndi-name="java:jboss/datasources/MyDS" pool-name="v" enabled="true" use-java-context="true" use-ccm="false">
<driver>p6spy</driver>
<xa-pool>
<min-pool-size>50</min-pool-size>
<max-pool-size>150</max-pool-size>
<is-same-rm-override>false</is-same-rm-override>
<interleaving>false</interleaving>
<pad-xid>false</pad-xid>
<wrap-xa-resource>false</wrap-xa-resource>
</xa-pool>
<security>
<user-name>postgres</user-name>
<password>postgres</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</xa-datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="postgresql" module="org.postgresql">
<xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
</driver>
<driver name="p6spy" module="com.p6spy">
<xa-datasource-class>com.p6spy.engine.spy.P6ConnectionPoolDataSource</xa-datasource-class>
</driver>
</drivers>
Moreover I think you don't need spy.properties file if you're OK with default config. As RealDriver property would be needed if going the driver way (not the datasource one as you do now).
UPDATE:
removed section reported as problematic:
<xa-datasource-property name="RealDataSource">
java:jboss/datasources/MyDSReal
</xa-datasource-property>
if that is a problem in the DS config => let's configure it in a different way, you can go for any of available:
System properties
Environment variables or
spy.properties
where you need to set:
realdatasource=java:jboss/datasources/MyDSReal
UPDATE 2:
I gave it a test try and it seems p6spy doesn't support the XA Datasources for the JBoss / Wildfly (yet). For more details, see the official docs: http://p6spy.github.io/p6spy/2.0/install.html

FacesServlet denies acces when using Web Services on Google App Engine

I'm developing a sample application with Google App Engine over Java that uses Web Services.
Everything works well when I work in the local enviroment, the server service is deployed in my google account and the client is deployed in my local environment.
The problem comes when I deploy the application on Google App Engine and try to execute it. An exception occurs when the backing bean tries to create an instance of the server client:
This is the exception I get:
javax.el.ELException: /home.xhtml at line 20 and column 64 action="#{bergeData.obtenerListado}": java.lang.ExceptionInInitializerError
Caused by:
java.security.AccessControlException - access denied ("java.lang.RuntimePermission" "getClassLoader")
Caused by: java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at java.lang.Class.newInstance0(Class.java:370)
at java.lang.Class.newInstance(Class.java:323)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:49)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:134)
at javax.xml.ws.spi.Provider.provider(Provider.java:127)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.beeva.client.gen.AutomovilServerAPIService.<init>(AutomovilServerAPIService.java:46)
at com.beeva.controller.AutomovilServletClient.<init>(AutomovilServletClient.java:35)
at com.beeva.gae.BergeData.obtenerListado(BergeData.java:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:45)
at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at org.apache.myfaces.view.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:83)
at javax.faces.component._MethodExpressionToMethodBinding.invoke(_MethodExpressionToMethodBinding.java:88)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:100)
at javax.faces.component.UICommand.broadcast(UICommand.java:120)
at javax.faces.component.UIViewRoot._broadcastAll(UIViewRoot.java:937)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:271)
at javax.faces.component.UIViewRoot._process(UIViewRoot.java:1249)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:675)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:34)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:171)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:189)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:480)
at com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:487)
at com.google.tracing.TraceContext.runInContext(TraceContext.java:774)
at com.google.tracing.TraceContext$DoInTraceContext.runInContext(TraceContext.java:751)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:342)
at com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:334)
at com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:484)
... 1 more
Caused by: java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "getClassLoader")
at com.google.appengine.runtime.Request.process-98b41701563e1bbd(Request.java)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:564)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.ClassLoader.getSystemClassLoader(ClassLoader.java:1479)
at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:519)
at com.sun.xml.bind.v2.model.nav.ReflectionNavigator.findClass(ReflectionNavigator.java:58)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:249)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:95)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
at com.sun.xml.bind.v2.model.impl.TypeRefImpl.calcRef(TypeRefImpl.java:92)
at com.sun.xml.bind.v2.model.impl.TypeRefImpl.getTarget(TypeRefImpl.java:69)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget(RuntimeTypeRefImpl.java:58)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeRefImpl.getTarget(RuntimeTypeRefImpl.java:51)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get(ElementPropertyInfoImpl.java:74)
at com.sun.xml.bind.v2.model.impl.ElementPropertyInfoImpl$1.get(ElementPropertyInfoImpl.java:77)
at java.util.AbstractList$Itr.next(AbstractList.java:358)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:255)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:100)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:209)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:95)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:81)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:315)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:330)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:466)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:253)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:240)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:440)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:220)
at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:218)
at java.security.AccessController.doPrivileged(AccessController.java:34)
at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:217)
at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:88)
... 55 more
`
The trace of the exception starts in this line of code:
AutomovilServletClient clienteService = new AutomovilServletClient();
AutomovilServletClient has a constructor which initializes the API service:
public AutomovilServletClient() {
this.automovilAPI = new AutomovilServerAPIService().getAutomovilServerAPIPort();
}
First goes to the constructor of AutomovilServerAPIService:
#WebServiceClient(name = "AutomovilServerAPIService", targetNamespace = "http://server.beeva.com/", wsdlLocation = "http://1.XXXX.appspot.com/AutomovilServerAPIService.wsdl")
public class AutomovilServerAPIService
extends Service
{
private final static URL AUTOMOVILSERVERAPISERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.beeva.client.gen.AutomovilServerAPIService.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.beeva.client.gen.AutomovilServerAPIService.class.getResource(".");
url = new URL(baseUrl, "http://1.XXXX.appspot.com/AutomovilServerAPIService.wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'http://1.XXXX.appspot.com/AutomovilServerAPIService.wsdl', retrying as a local file");
logger.warning(e.getMessage());
}
AUTOMOVILSERVERAPISERVICE_WSDL_LOCATION = url;
}
public AutomovilServerAPIService() {
super(AUTOMOVILSERVERAPISERVICE_WSDL_LOCATION, new QName("http://server.beeva.com/", "AutomovilServerAPIService"));
}
}
In the method AutomovilServerAPIService() is where I lose track of the execution. I have checked the content of the constant AUTOMOVILSERVERAPISERVICE_WSDL_LOCATION and it's correct.
Anyone has an idea of why it happens when it is deployed up to Google App Engine?
Thanks in advance
UPDATE: Trying the SOAP example of Google Developers I have found that the problem comes with use of Java Server Faces Servlet. My project is a Google Web Application Project with JSF capabilities. So this line in the web.xml is what causes the problem:
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
However, I have no idea how to fix it :(
UPDATE 2:
SOLVED!! I have found that the problem is a incompatiblity of GAE with Apache MyFaces JSF-Core 2.0. When adding JSF Capabilities via properties/Project Facets, select JSF 2.0 (Mojarra 2.Z.X-FCS) instead of Apache MyFaces
I tried example at https://developers.google.com/appengine/articles/soap and it is working both locally and online.
The changes i made before online deployment were:
For Server application changed url in wsdl file
For client application changed url in SOAPService.java
I think second change you have already done.
Can you confirm whether you have updated WSDL file before deploying online?
<service name="TestSOAPService">
<port name="TestSOAPPort" binding="tns:TestSOAPPortBinding">
<soap:address location="**http://CHANGE_TO_ONLINEID.appspot.com**/testsoap"/>
</port>
</service>