XA Transaction broken in jBPM+jBoss during Oracle to SQL Server migration - jdbc

Recently started a migration of a large Java EE application from Oracle 12c to MS SQL Server 2016. Most functionality has been smoke tested to work OK including the Quartz Scheduler, basic JMS functions, Hibernate and EJBs working ok, etc. One weird issue has stalled progress so hoping someone might have a suggestion.
The jBPM console works to be able to log in and start/suspend/stop tasks. There is an situation that always triggers an error. The jBPM task can be signaled from with the console and it starts perfectly, but once the first task is finished and the application code tries to signal the token to move to the next task, the code always crashes with an error.
This code was working of course connected to Oracle with the xa-datasource configured.
The error: (full stacktrace)
2017-10-13 16:03:31,463 [WorkManager(2)-19] DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
2017-10-13 16:03:31,464 [WorkManager(2)-19] DEBUG [org.hibernate.util.JDBCExceptionReporter] Cannot open connection [???]
org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -71740de1:d47b:59e10d94:f5 status: ActionStatus.ABORT_ONLY >; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -71740de1:d47b:59e10d94:f5 status: ActionStatus.ABORT_ONLY >)
at org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:95)
at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:69)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1860)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3044)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at org.jbpm.db.GraphSession.getToken(GraphSession.java:338)
at org.jbpm.JbpmContext.getToken(JbpmContext.java:286)
at ca.gnb.medicare.process.handling.ProcessUtilBean.signal(ProcessUtilBean.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at ca.gnb.medicare.service.interceptors.PeristenceContextInterceptor.intercept(PeristenceContextInterceptor.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$RequiresNew.invoke(TxInterceptor.java:253)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
at com.sun.proxy.$Proxy155.signal(Unknown Source)
at ca.gnb.medicare.service.util.AbstractServiceActivator.onMessage(AbstractServiceActivator.java:143)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at ca.gnb.medicare.service.interceptors.PeristenceContextInterceptor.intercept(PeristenceContextInterceptor.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInCallerTx(TxPolicy.java:126)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:195)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.mdb.MessagingContainer.localInvoke(MessagingContainer.java:249)
at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.delivery(MessageInflowLocalProxy.java:268)
at org.jboss.ejb3.mdb.inflow.MessageInflowLocalProxy.invoke(MessageInflowLocalProxy.java:138)
at com.sun.proxy.$Proxy169.onMessage(Unknown Source)
at org.jboss.resource.adapter.jms.inflow.JmsServerSession.onMessage(JmsServerSession.java:178)
at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:906)
at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:170)
at org.jboss.mq.SpySession.run(SpySession.java:323)
at org.jboss.resource.adapter.jms.inflow.JmsServerSession.run(JmsServerSession.java:237)
at org.jboss.resource.work.WorkWrapper.execute(WorkWrapper.java:204)
at org.jboss.util.threadpool.BasicTaskWrapper.run(BasicTaskWrapper.java:275)
at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:756)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.resource.ResourceException: Transaction is not active: tx=TransactionImple < ac, BasicAction: -71740de1:d47b:59e10d94:f5 status: ActionStatus.ABORT_ONLY >
at org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:319)
I cannot think of how SQL Server affects the transaction.
We also get this error on SQL Server: (full sql dump)
2017-10-11 13:10:53.44 spid61 ***Stack Dump being sent to G:\MedSt\MSSQL13.MEDST\MSSQL\LOG\SQLDump0032.txt
2017-10-11 13:10:53.44 spid61 SqlDumpExceptionHandler: Process 61 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
2017-10-11 13:10:54.15 spid61 External dump process return code 0x20000001.
External dump process returned no errors.
2017-10-11 13:10:54.15 spid61 Error: 18002, Severity: 20, State: 1.
2017-10-11 13:10:54.15 spid61 Exception happened when running extended stored procedure 'xp_sqljdbc_xa_start' in the library 'SQLJDBC_XA.dll'. SQL Server is terminating process 61. Exception type: Win32 exception; Exception code: 0xc0000005.
Code that triggers the error:
#Stateless
public class ProcessUtilBean implements ProcessUtil{
private static Logger log = Logger.getLogger();
#EJB DecrementWorkCounter decrementWorkCounter;
#TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void signal(long tokenId){
JbpmContext context = null;
try {
context = getJbpmContext();
log.info("attempting to get token (" + tokenId + ")");
Token token;
token = context.getToken(tokenId);
token.signal(); // <-- triggers error
} catch (Exception e) {
e.printStackTrace();
log.severe("Error signalling process " + e.getMessage());
} finally {
context.close();
}
}
There are of course several tons of XML, but I've changed very little. Basically just the datasources have changed, SQL Dialect and copied over the mssql-jdbc2-service.xml from the jboss examples folder.
Here is the jms-ds.xml seeing as the errors somewhat indicate an issue here with JMS:
<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>
<!-- The JMS provider loader -->
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="jboss.mq:service=JMSProviderLoader,name=JMSProvider">
<attribute name="ProviderName">DefaultJMSProvider</attribute>
<attribute name="ProviderAdapterClass">
org.jboss.jms.jndi.JNDIProviderAdapter
</attribute>
<!-- The combined connection factory -->
<attribute name="FactoryRef">java:/XAConnectionFactory</attribute>
<!-- The queue connection factory -->
<attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>
<!-- The topic factory -->
<attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>
</mbean>
<!-- The server session pool for Message Driven Beans -->
<mbean code="org.jboss.jms.asf.ServerSessionPoolLoader"
name="jboss.mq:service=ServerSessionPoolMBean,name=StdJMSPool">
<depends optional-attribute-name="XidFactory">jboss:service=XidFactory</depends>
<attribute name="PoolName">StdJMSPool</attribute>
<attribute name="PoolFactoryClass">
org.jboss.jms.asf.StdServerSessionPoolFactory
</attribute>
</mbean>
<!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
<tx-connection-factory>
<jndi-name>JmsXA</jndi-name>
<xa-transaction/>
<rar-name>jms-ra.rar</rar-name>
<connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
<config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
<config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
<security-domain-and-application>JmsXARealm</security-domain-and-application>
<max-pool-size>20</max-pool-size>
</tx-connection-factory>
</connection-factories>
Versions:
Java 1.7
jboss 4.2.3.GA
jbpm 3.2.6.sp1
hibernate 3.2.4.sp1
(I know someone will comment, so yes, these are all schedule to be upgraded)
SQL drivers tried so far:
sqljdbc_4.0.2206.100_enu
mssql-jdbc-6.2.1.jre7
mssql-jdbc-6.2.2.jre7
mssql-jdbc-6.3.3.jre7-preview
We followed directions for XA Transactions as posted
If I've missed something important, I'll add it.
** edit **
Finally got some more information from sql driver.
2017-10-18 14:03:31,096 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSReader readBytes
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad) Reading 44 bytes from offset 334
2017-10-18 14:03:31,098 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSParser parse
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad): logon: Processing TDS_ENV_CHG (0xE3)
2017-10-18 14:03:31,098 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSReader mark
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad): Buffering from: com.microsoft.sqlserver.jdbc.TDSReaderMark#6b6611f0
2017-10-18 14:03:31,098 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSReader readBytes
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad) Reading 8 bytes from offset 387
2017-10-18 14:03:31,099 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection processEnvChange
FINER: ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad Network packet size is 8000 bytes
2017-10-18 14:03:31,099 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSReader reset
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad): Resetting to: com.microsoft.sqlserver.jdbc.TDSReaderMark#6b6611f0
2017-10-18 14:03:31,099 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSReader readBytes
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad) Reading 19 bytes from offset 385
2017-10-18 14:03:31,099 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSParser parse
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad): logon: Processing TDS_DONE (0xFD)
2017-10-18 14:03:31,099 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.TDSParser parse
FINEST: TDSReader#370 (ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad): logon: Processing EOF
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection connectInternal
FINER: ConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad End of connect
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXAConnection <init>
FINER: Created an internal control connectionConnectionID:166 ClientConnectionId: a62ad6a5-19e4-4187-83f5-c60a6bb1aaad for SQLServerXAConnection:81 Physical connection:ConnectionID:165 ClientConnectionId: 78fd8cb2-78ff-44d7-9cae-e20e6256b37e
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXAConnection <init>
FINER: SQLServerXADataSource:1 user:MEDST3
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXADataSource getXAConnection
FINER: SQLServerXADataSource:1 user:MEDST3SQLServerXAConnection:81
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXADataSource getXAConnection
FINER: SQLServerXADataSource:1 Start get physical connection.
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXADataSource getXAConnection
FINE: SQLServerXADataSource:1 End get physical connection, ConnectionID:165 ClientConnectionId: 78fd8cb2-78ff-44d7-9cae-e20e6256b37e
2017-10-18 14:03:31,100 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerXADataSource:1 getXAConnection
FINER: RETURN SQLServerXAConnection:81
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerPooledConnection getConnection
FINER: SQLServerXAConnection:81 user:(default).
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerPooledConnection getConnection
FINE: SQLServerXAConnection:81 Physical connection, ConnectionID:165 ClientConnectionId: 78fd8cb2-78ff-44d7-9cae-e20e6256b37e
2017-10-18 14:03:31,098 [main] TRACE [org.jboss.web.tomcat.service.WebAppClassLoader] filter name=ca.gnb.medicare.application.claim.manage.SelectServiceProvider$1, exclude=false
2017-10-18 14:03:31,101 [main] DEBUG [org.apache.catalina.loader.WebappClassLoader] Searching local repositories
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerPooledConnection getConnection
FINE: SQLServerXAConnection:81 proxy ProxyConnectionID:81 is returned.
2017-10-18 14:03:31,101 [main] TRACE [org.jboss.web.tomcat.service.WebAppClassLoader] findClass(ca.gnb.medicare.application.claim.manage.SelectServiceProvider$1) called
2017-10-18 14:03:31,101 [main] DEBUG [org.apache.catalina.loader.WebappClassLoader] findClass(ca.gnb.medicare.application.claim.manage.SelectServiceProvider$1)
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection:165 getTransactionIsolation
FINER: ENTRY
2017-10-18 14:03:31,101 [main] TRACE [org.apache.catalina.loader.WebappClassLoader] findClassInternal(ca.gnb.medicare.application.claim.manage.SelectServiceProvider$1)
2017-10-18 14:03:31,101 [WorkManager(2)-19] INFO [org.hibernate.impl.SessionFactoryImpl] building session factory
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection:165 getTransactionIsolation
FINER: RETURN 2 (this is = TRANSACTION_READ_COMMITTED) https://docs.oracle.com/javase/7/docs/api/constant-values.html#java.sql
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection:165 isReadOnly
FINER: ENTRY
2017-10-18 14:03:31,101 [WorkManager(2)-19] DEBUG [org.hibernate.impl.SessionFactoryImpl] Session factory constructed with filter configurations : {}
2017-10-18 14:03:31,101 [JCA PoolFiller] ERROR [STDERR] Oct 18, 2017 2:03:31 PM com.microsoft.sqlserver.jdbc.SQLServerConnection:165 isReadOnly
FINER: RETURN false

**EDIT
Response from Microsoft:
Upon checking with my escalation we found that timeout value basically range a integer value which is basically a unsigned short.
So the maximum XA Timeout value is 65,535.
** /EDIT
So the issue to this specific issue turns out to be an overly high timeout value.
Either the original devs thought 333.33 hours was needed for batch processing or they just picked the number 1,200,000 seconds by random. Oracle didn't care. SQL Server SQLJDBC_XA.DLL does. I haven't found a documented maximum yet, but lowering the value solves the issue.
I've reposted the complete example code from here for completeness, but it's the 1,200,000 value here that is the culprit:
#PoolClass(value=org.jboss.ejb3.StrictMaxPool.class, maxSize=20, timeout=1200000)
#MessageDriven(
mappedName=ClaimsBatchInstigatorBean.QUEUE_NAME,
activationConfig={
#ActivationConfigProperty(
propertyName="destination",
propertyValue=ClaimsBatchInstigatorBean.QUEUE_NAME
),
#ActivationConfigProperty(
propertyName="destinationType",
propertyValue="javax.jms.Queue"
),
#ActivationConfigProperty(
propertyName = "transactionTimeout",
propertyValue = "1200000"
),
#ActivationConfigProperty(
propertyName="maxSession",
propertyValue="15"
)
}
)
Minimal code to reproduce:
package com.******.test;
import java.net.Inet4Address;
import java.sql.*;
import java.util.Random;
import javax.transaction.xa.*;
import javax.sql.*;
import com.microsoft.sqlserver.jdbc.*;
public class testXA {
public static void main(String[] args) throws Exception {
// Create variables for the connection string.
String prefix = "jdbc:sqlserver://";
String serverName = "******";
int portNumber = ******;
String databaseName = "******";
String user = "******";
String password = "******";
String connectionUrl = prefix + serverName + ":" + portNumber
+ ";databaseName=" + databaseName + ";user=" + user + ";password=" + password;
try {
// Establish the connection.
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection con = DriverManager.getConnection(connectionUrl);
// Create a test table.
Statement stmt = con.createStatement();
try {
stmt.executeUpdate("DROP TABLE XAMin");
}
catch (Exception e) {
}
stmt.executeUpdate("CREATE TABLE XAMin (f1 int, f2 varchar(max))");
stmt.close();
con.close();
// Create the XA data source and XA ready connection.
SQLServerXADataSource ds = new SQLServerXADataSource();
ds.setUser(user);
ds.setPassword(password);
ds.setServerName(serverName);
ds.setPortNumber(portNumber);
ds.setDatabaseName(databaseName);
XAConnection xaCon = ds.getXAConnection();
con = xaCon.getConnection();
con.setAutoCommit(false);
// Get a unique Xid object for testing.
XAResource xaRes = null;
Xid xid = null;
xid = XidImpl.getUniqueXid(1);
// Get the XAResource object and set the timeout value.
xaRes = xaCon.getXAResource();
// xaRes.setTransactionTimeout(0); <-- no error
// xaRes.setTransactionTimeout(30000); <-- no error
xaRes.setTransactionTimeout(1200000); //<--- error!
// Perform the XA transaction.
System.out.println("Write -> xid = " + xid.toString());
xaRes.start(xid,XAResource.TMNOFLAGS);
PreparedStatement pstmt =
con.prepareStatement("INSERT INTO XAMin (f1,f2) VALUES (?, ?)");
pstmt.setInt(1,1);
pstmt.setString(2,xid.toString());
pstmt.executeUpdate();
// Commit the transaction.
xaRes.end(xid,XAResource.TMSUCCESS);
xaRes.commit(xid,true);
// Cleanup.
con.close();
xaCon.close();
// Open a new connection and read back the record to verify that it worked.
con = DriverManager.getConnection(connectionUrl);
ResultSet rs = con.createStatement().executeQuery("SELECT * FROM XAMin");
rs.next();
System.out.println("Read -> xid = " + rs.getString(2));
rs.close();
con.close();
}
// Handle any errors that may have occurred.
catch (Exception e) {
e.printStackTrace();
}
}
}
class XidImpl implements Xid {
public int formatId;
public byte[] gtrid;
public byte[] bqual;
public byte[] getGlobalTransactionId() {return gtrid;}
public byte[] getBranchQualifier() {return bqual;}
public int getFormatId() {return formatId;}
XidImpl(int formatId, byte[] gtrid, byte[] bqual) {
this.formatId = formatId;
this.gtrid = gtrid;
this.bqual = bqual;
}
public String toString() {
int hexVal;
StringBuffer sb = new StringBuffer(512);
sb.append("formatId=" + formatId);
sb.append(" gtrid(" + gtrid.length + ")={0x");
for (int i=0; i<gtrid.length; i++) {
hexVal = gtrid[i]&0xFF;
if ( hexVal < 0x10 )
sb.append("0" + Integer.toHexString(gtrid[i]&0xFF));
else
sb.append(Integer.toHexString(gtrid[i]&0xFF));
}
sb.append("} bqual(" + bqual.length + ")={0x");
for (int i=0; i<bqual.length; i++) {
hexVal = bqual[i]&0xFF;
if ( hexVal < 0x10 )
sb.append("0" + Integer.toHexString(bqual[i]&0xFF));
else
sb.append(Integer.toHexString(bqual[i]&0xFF));
}
sb.append("}");
return sb.toString();
}
// Returns a globally unique transaction id.
static byte [] localIP = null;
static int txnUniqueID = 0;
static Xid getUniqueXid(int tid) {
Random rnd = new Random(System.currentTimeMillis());
txnUniqueID++;
int txnUID = txnUniqueID;
int tidID = tid;
int randID = rnd.nextInt();
byte[] gtrid = new byte[64];
byte[] bqual = new byte[64];
if ( null == localIP) {
try {
localIP = Inet4Address.getLocalHost().getAddress();
}
catch ( Exception ex ) {
localIP = new byte[] { 0x01,0x02,0x03,0x04 };
}
}
System.arraycopy(localIP,0,gtrid,0,4);
System.arraycopy(localIP,0,bqual,0,4);
// Bytes 4 -> 7 - unique transaction id.
// Bytes 8 ->11 - thread id.
// Bytes 12->15 - random number generated by using seed from current time in milliseconds.
for (int i=0; i<=3; i++) {
gtrid[i+4] = (byte)(txnUID%0x100);
bqual[i+4] = (byte)(txnUID%0x100);
txnUID >>= 8;
gtrid[i+8] = (byte)(tidID%0x100);
bqual[i+8] = (byte)(tidID%0x100);
tidID >>= 8;
gtrid[i+12] = (byte)(randID%0x100);
bqual[i+12] = (byte)(randID%0x100);
randID >>= 8;
}
return new XidImpl(0x20003, gtrid, bqual);
}
}

Related

Switching to CloudAMQP gives com.rabbitmq.client.ShutdownSignalException

As the titles says, I'm trying to switch to CloudAMQP for deployment purposes.
Application.properties look as followed:
#spring.rabbitmq.host = rabbitmq
#spring.rabbitmq.host = localhost
spring.rabbitmq.host=cow.rmq2.cloudamqp.com
spring.rabbitmq.username=vvecyvwz
spring.rabbitmq.password=mypassword
The error logs:
2022-05-15 13:48:54.656 INFO 105060 --- [ntContainer#0-2] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [cow.rmq2.cloudamqp.com:5672]
2022-05-15 13:48:54.748 WARN 105060 --- [.93.32.234:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-15 13:48:59.841 INFO 105060 --- [ntContainer#0-2] o.s.a.r.l.SimpleMessageListenerContainer : Restarting Consumer#665f577: tags=[[]], channel=null, acknowledgeMode=AUTO local queue size=0
2022-05-15 13:48:59.842 INFO 105060 --- [ntContainer#0-3] o.s.a.r.c.CachingConnectionFactory : Attempting to connect to: [cow.rmq2.cloudamqp.com:5672]
2022-05-15 13:48:59.941 WARN 105060 --- [.93.32.234:5672] c.r.c.impl.ForgivingExceptionHandler : An unexpected connection driver error occurred (Exception message: Socket closed)
2022-05-15 13:48:59.941 ERROR 105060 --- [ntContainer#0-3] o.s.a.r.l.SimpleMessageListenerContainer : Failed to check/redeclare auto-delete queue(s).
org.springframework.amqp.AmqpIOException: java.io.IOException
at org.springframework.amqp.rabbit.support.RabbitExceptionTranslator.convertRabbitAccessException(RabbitExceptionTranslator.java:70) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:602) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.connection.CachingConnectionFactory.createConnection(CachingConnectionFactory.java:724) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.connection.ConnectionFactoryUtils.createConnection(ConnectionFactoryUtils.java:252) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.core.RabbitTemplate.doExecute(RabbitTemplate.java:2175) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2148) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.core.RabbitTemplate.execute(RabbitTemplate.java:2128) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueInfo(RabbitAdmin.java:463) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.core.RabbitAdmin.getQueueProperties(RabbitAdmin.java:447) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.attemptDeclarations(AbstractMessageListenerContainer.java:1925) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer.redeclareElementsIfNecessary(AbstractMessageListenerContainer.java:1906) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.initialize(SimpleMessageListenerContainer.java:1349) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer$AsyncMessageProcessingConsumer.run(SimpleMessageListenerContainer.java:1195) ~[spring-rabbit-2.4.2.jar:2.4.2]
at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
Caused by: java.io.IOException: null
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:129) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQChannel.wrap(AMQChannel.java:125) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:147) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQConnection.start(AMQConnection.java:439) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1225) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:1173) ~[amqp-client-5.13.1.jar:5.13.1]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connectAddresses(AbstractConnectionFactory.java:640) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.connect(AbstractConnectionFactory.java:615) ~[spring-rabbit-2.4.2.jar:2.4.2]
at org.springframework.amqp.rabbit.connection.AbstractConnectionFactory.createBareConnection(AbstractConnectionFactory.java:565) ~[spring-rabbit-2.4.2.jar:2.4.2]
... 12 common frames omitted
Caused by: com.rabbitmq.client.ShutdownSignalException: connection error; protocol method: #method<connection.close>(reply-code=530, reply-text=NOT_ALLOWED - access to vhost '/' refused for user 'vvecyvwz', class-id=10, method-id=40)
at com.rabbitmq.utility.ValueOrException.getValue(ValueOrException.java:66) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.utility.BlockingValueOrException.uninterruptibleGetValue(BlockingValueOrException.java:36) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQChannel$BlockingRpcContinuation.getReply(AMQChannel.java:502) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQChannel.privateRpc(AMQChannel.java:293) ~[amqp-client-5.13.1.jar:5.13.1]
at com.rabbitmq.client.impl.AMQChannel.exnWrappingRpc(AMQChannel.java:141) ~[amqp-client-5.13.1.jar:5.13.1]
... 18 common frames omitted
Genuinely have no idea what's going wrong with my application. The host, username and password are 100% correct, I'm not sure where the problem could be.
I had the same error when I switched to Cloud AMQP. As you mentioned, the virtual host was missing from the properties:
spring.rabbitmq.virtual-host=vvecyvwz
spring.rabbitmq.host=cow.rmq2.cloudamqp.com
spring.rabbitmq.username=vvecyvwz
spring.rabbitmq.password=mypassword
spring.rabbitmq.port=5672
or you can do like this :
spring.rabbitmq.addresses=amqps://vvecyvwz:mypassword#cow.rmq2.cloudamqp.com/vvecyvwz
Ok so the problem was that I had to add a virtual host. Which I definitely already tried programmatically like this:
#Value("${spring.rabbitmq.host}")
private String host;
#Value("${spring.rabbitmq.username}")
private String username;
#Value("${spring.rabbitmq.password}")
private String password;
#Bean
public AmqpTemplate template() {
CachingConnectionFactory cf = new CachingConnectionFactory(host);
cf.setUsername(username);
cf.setPassword(password);
cf.setVirtualHost(username);
final RabbitTemplate rabbitTemplate = new RabbitTemplate(cf);
rabbitTemplate.setMessageConverter(converter());
return rabbitTemplate;
}
But apparently this doesn't work and I had to specify it in the application.properties
In my case, it was due to missing the leading / of the vhost value in the config.

Microsoft Graph Proxy and Bypass SSL

Im using the below :
Java 8
microsoft-graph : 2.10.0
microsoft-graph-auth : 0.2.0
okhttp : 3.14.9
I want to fetch data from Intune using Microsoft Graph API, want to use proxy and also bypass SSL (for testing). As per documentation, i have used the OKHttpClient. Used the OkHttpClient for configuring the proxy, sslSocketFactory and hostnameVerifier but it is no working.
final ClientCredentialProvider authProvider = new ClientCredentialProvider(this.clientId, this.scopes, this.clientSecret, this.tenantId, NationalCloud.Global);
final TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
#Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[0] {};
}
#Override
public void checkServerTrusted(final X509Certificate[] arg0, final String arg1)
throws CertificateException {
}
#Override
public void checkClientTrusted(final X509Certificate[] arg0, final String arg1)
throws CertificateException {
}
} };
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, trustAllCerts, new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
final OkHttpClient httpClient = HttpClients.createDefault(new ICoreAuthenticationProvider() {
#Override
public Request authenticateRequest(final Request request) {
return request;
}
}).newBuilder().proxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(this.proxyHost, this.proxyPort)))
.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]).hostnameVerifier(new HostnameVerifier() {
#Override
public boolean verify(final String arg0, final SSLSession arg1) {
return true;
}
}).build();
final IHttpProvider httpProvider = DefaultClientConfig.createWithAuthenticationProvider(authProvider)
.getHttpProvider(httpClient);
final IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider(authProvider)
.httpProvider(httpProvider).buildClient();
IUserCollectionPage page = graphClient.users().buildRequest().get();
I get the below errors:
org.apache.oltu.oauth2.common.exception.OAuthSystemException: java.net.UnknownHostException: login.microsoftonline.com
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:108)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:65)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:55)
at org.apache.oltu.oauth2.client.OAuthClient.accessToken(OAuthClient.java:71)
at com.microsoft.graph.auth.confidentialClient.ClientCredentialProvider.getAccessTokenNewRequest(ClientCredentialProvider.java:102)
at com.microsoft.graph.auth.confidentialClient.ClientCredentialProvider.getAcccessToken(ClientCredentialProvider.java:67)
at com.microsoft.graph.auth.confidentialClient.ClientCredentialProvider.authenticateRequest(ClientCredentialProvider.java:49)
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:395)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:220)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:200)
at com.microsoft.graph.http.BaseCollectionRequest.send(BaseCollectionRequest.java:92)
at com.microsoft.graph.requests.extensions.UserCollectionRequest.get(UserCollectionRequest.java:72)
at com.hsbc.gme.test.graph_test.App.main(App.java:114)
Caused by: java.net.UnknownHostException: login.microsoftonline.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)
at org.apache.oltu.oauth2.client.URLConnectionClient.setRequestBody(URLConnectionClient.java:124)
at org.apache.oltu.oauth2.client.URLConnectionClient.execute(URLConnectionClient.java:91)
... 12 more
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220Graph service exception Error code: InvalidAuthenticationToken
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220Error message: CompactToken parsing failed with error code: 80049217
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220GET https://graph.microsoft.com/v1.0/users
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220SdkVersion : graph-java/v2.10.0
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220Authorization : [PII_REDACTED]
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220401 : Unauthorized
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220[...]
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: CoreHttpProvider[send] - 220[Some information was truncated for brevity, enable debug logging for more details]
Mar 14, 2021 11:30:17 PM com.microsoft.graph.logger.DefaultLogger logError
SEVERE: Throwable detail: com.microsoft.graph.http.GraphServiceException: Error code: InvalidAuthenticationToken
Error message: CompactToken parsing failed with error code: 80049217
GET https://graph.microsoft.com/v1.0/users
SdkVersion : graph-java/v2.10.0
Authorization : [PII_REDACTED]
401 : Unauthorized
[...]
[Some information was truncated for brevity, enable debug logging for more details]
Exception in thread "main" com.microsoft.graph.http.GraphServiceException: Error code: InvalidAuthenticationToken
Error message: CompactToken parsing failed with error code: 80049217
GET https://graph.microsoft.com/v1.0/users
SdkVersion : graph-java/v2.10.0
Authorization : [PII_REDACTED]
401 : Unauthorized
[...]
[Some information was truncated for brevity, enable debug logging for more details]
at com.microsoft.graph.http.GraphServiceException.createFromConnection(GraphServiceException.java:496)
at com.microsoft.graph.http.CoreHttpProvider.handleErrorResponse(CoreHttpProvider.java:503)
at com.microsoft.graph.http.CoreHttpProvider.sendRequestInternal(CoreHttpProvider.java:423)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:220)
at com.microsoft.graph.http.CoreHttpProvider.send(CoreHttpProvider.java:200)
at com.microsoft.graph.http.BaseCollectionRequest.send(BaseCollectionRequest.java:92)
at com.microsoft.graph.requests.extensions.UserCollectionRequest.get(UserCollectionRequest.java:72)
at com.hsbc.gme.test.graph_test.App.main(App.java:114)
Note : If i use https.proxyHost and https.proxyPort then the proxy works, however how can i make it working with the OkHttpClient. Also need a way to bypass SSL

org.springframework.batch.item.ItemStreamException: Failed to initialize the reader

I'm trying to parse the flat file having multiplerecords.
for parsing I'm using FlatFileItemReader class.
while parsing i got this error.
Jan 14, 2016 4:37:45 PM org.springframework.batch.core.step.AbstractStep execute
SEVERE: Encountered an error executing the step
org.springframework.batch.item.ItemStreamException: Failed to initialize the reader
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:142)
at org.springframework.batch.item.support.CompositeItemStream.open(CompositeItemStream.java:96)
at org.springframework.batch.core.step.tasklet.TaskletStep.open(TaskletStep.java:307)
at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:192)
at org.springframework.batch.core.job.SimpleStepHandler.handleStep(SimpleStepHandler.java:137)
at org.springframework.batch.core.job.AbstractJob.handleStep(AbstractJob.java:380)
at org.springframework.batch.core.job.SimpleJob.doExecute(SimpleJob.java:124)
at org.springframework.batch.core.job.AbstractJob.execute(AbstractJob.java:301)
at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:135)
at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:128)
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)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration$PassthruAdvice.invoke(SimpleBatchConfiguration.java:117)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy16.run(Unknown Source)
at com.deere.FtpMain.main(FtpMain.java:24)
Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): URL [http://finance.yahoo.com/d/quotes.csv?s=XOM+IBM+JNJ+MSFT&f=snd1ol1p2]
at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:251)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:139)
... 22 more
In my reader class is
#Bean
public ItemReader<FtpData> reader() throws MalformedURLException{
FlatFileItemReader<FtpData> reader=new FlatFileItemReader<FtpData>();
reader.setResource(new UrlResource("http://finance.yahoo.com/d/quotes.csv?s=XOM+IBM+JNJ+MSFT&f=snd1ol1p2"));
reader.setLineMapper(new DefaultLineMapper<FtpData>(){{
setLineTokenizer(new DelimitedLineTokenizer());
setFieldSetMapper(new ftpDataSetMapper());
}});
return reader;
}
please suggest me any one
The URL: http://finance.yahoo.com/d/quotes.csv?s=XOM+IBM+JNJ+MSFT&f=snd1ol1p2 redirects to http://download.finance.yahoo.com/d/quotes.csv?s=XOM+IBM+JNJ+MSFT&f=snd1ol1p2 with a HTTP Response code of 301.
To go through with this approach (not that I know of any other, but this is simple HTTP protocol), just use the direct URL. It will work:
#Bean
public FlatFileItemReader<TickerData> reader() throws Exception {
FlatFileItemReader<TickerData> reader = new FlatFileItemReader<TickerData>();
reader.setResource(new UrlResource("http://download.finance.yahoo.com/d/quotes.csv?s=XOM+IBM+JNJ+MSFT&f=snd1ol1p2"));
reader.setLineMapper(new DefaultLineMapper() {{
setLineTokenizer(new DelimitedLineTokenizer());
setFieldSetMapper(new FieldSetMapper<TickerData>() {
#Override
public TickerData mapFieldSet(FieldSet fieldSet) throws BindException {
TickerData data = new TickerData();
data.setSymbol(fieldSet.readString(0));
data.setName(fieldSet.readString(1));
data.setLastTradeDate(fieldSet.readDate(2, "mm/DD/yyyy"));
data.setOpen(fieldSet.readBigDecimal(3));
data.setLastTrade(fieldSet.readBigDecimal(4));
data.setChangePct(fieldSet.readString(5));
return data;
}
});
}});
return reader;
}
These are from my logs:
2017-06-02 00:39:37.816 INFO 1898 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [convertPrice]
2017-06-02 00:39:39.159 INFO 1898 --- [ main] com.keyhole.example.LogItemWriter : TickerData [symbol=XOM, name=Exxon Mobil Corporation Common, lastTradeDate=Sun Jan 01 00:06:00 IST 2017, open=80.3700, lastTrade=80.7148, changePct=+0.2668%, openGBP=51.31, lastTradeGBP=51.53]
2017-06-02 00:39:39.160 INFO 1898 --- [ main] com.keyhole.example.LogItemWriter : TickerData [symbol=IBM, name=International Business Machines, lastTradeDate=Sun Jan 01 00:06:00 IST 2017, open=152.80, lastTrade=152.43, changePct=-0.13%, openGBP=97.54, lastTradeGBP=97.31]
2017-06-02 00:39:39.160 INFO 1898 --- [ main] com.keyhole.example.LogItemWriter : TickerData [symbol=JNJ, name=Johnson & Johnson Common Stock, lastTradeDate=Sun Jan 01 00:06:00 IST 2017, open=128.32, lastTrade=128.36, changePct=+0.09%, openGBP=81.92, lastTradeGBP=81.94]
2017-06-02 00:39:39.160 INFO 1898 --- [ main] com.keyhole.example.LogItemWriter : TickerData [symbol=MSFT, name=Microsoft Corporation, lastTradeDate=Sun Jan 01 00:06:00 IST 2017, open=70.24, lastTrade=69.77, changePct=-0.10%, openGBP=44.84, lastTradeGBP=44.54]
2017-06-02 00:39:39.175 INFO 1898 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=TickerPriceConversion]] completed with the following parameters: [{run.id=1}] and the following status: [COMPLETED]
Also refer to this SO link

Spring, JPA,JSF - null pointer exception on the access to data

I write web application with spring, jpa and jsf support. In my xhtml web page is table(primefaces) and button, which refresh database. When I try click the button i get this:
gru 23, 2014 10:01:10 PM org.apache.catalina.core.AprLifecycleListenerinit INFO: The APR based Apache Tomcat Native library which allowsoptimal performance in production environments was not found on thejava.library.path: C:\ProgramFiles\Java\jdk1.7.0_45\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\ProgramFiles (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLSClient\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\ProgramFiles (x86)\Windows Live\Shared;C:\Program Files\Intel\Intel(R)Management Engine Components\DAL;C:\Program Files\Intel\Intel(R)Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R)Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R)Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCLSDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCLSDK\2.0\bin\x64;D:\maven\bin;.
gru 23, 2014 10:01:10 PM org.apache.tomcat.util.digester.SetPropertiesRule begin WARNING:[SetPropertiesRule]{Server/Service/Engine/Host/Context} Settingproperty 'source' to 'org.eclipse.jst.jee.server:SJM' did not find amatching property.
gru 23, 2014 10:01:11 PM org.apache.coyote.AbstractProtocol init INFO: InitializingProtocolHandler ["http-bio-8081"]
gru 23, 2014 10:01:11 PM org.apache.coyote.AbstractProtocol init INFO: InitializingProtocolHandler ["ajp-bio-8010"]
gru 23, 2014 10:01:11 PM org.apache.catalina.startup.Catalina load INFO: Initializationprocessed in 1193 ms
gru 23, 2014 10:01:11 PM org.apache.catalina.core.StandardService startInternal INFO: Startingservice Catalina
gru 23, 2014 10:01:11 PM org.apache.catalina.core.StandardEngine startInternal INFO: StartingServlet Engine: Apache Tomcat/7.0.56
gru 23, 2014 10:01:16 PM org.apache.catalina.core.ApplicationContext log INFO: No SpringWebApplicationInitializer types detected on classpath
gru 23, 2014 10:01:16 PM org.apache.catalina.core.ApplicationContext log INFO:Initializing Spring root WebApplicationContext
22:01:21,254 DEBUG FlowDefinitionRegistryImpl:100 - Registering flow definition'ServletContext resource [/WEB-INF/flows/main/main-flow.xml]' under id'main'
22:01:21,280 DEBUG ConditionalFlowExecutionListenerLoader:59 -Adding flow execution listenerorg.springframework.webflow.persistence.JpaFlowExecutionListener#16495871with criteria *
22:01:21,282 DEBUGConditionalFlowExecutionListenerLoader:59 - Adding flow executionlistenerorg.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25with criteria *
gru 23, 2014 10:01:21 PM com.sun.faces.config.ConfigureListener contextInitialized INFO:Initializing Mojarra 2.1.10 (-SNAPSHOT 20120625-1354) for context'/SJM'
gru 23, 2014 10:01:22 PM com.sun.faces.spi.InjectionProviderFactory createInstance INFO:JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeansmethods marked with these annotations will have said annotationsprocessed.
gru 23, 2014 10:01:24 PM org.primefaces.webapp.PostConstructApplicationEventListenerprocessEvent INFO: Running on PrimeFaces 3.4
gru 23, 2014 10:01:24 PM org.apache.catalina.core.ApplicationContext log INFO: InitializingSpring FrameworkServlet 'Spring MVC Dispatcher Servlet'
gru 23, 2014 10:01:24 PM org.apache.coyote.AbstractProtocol start INFO: StartingProtocolHandler ["http-bio-8081"]
gru 23, 2014 10:01:24 PM org.apache.coyote.AbstractProtocol start INFO: StartingProtocolHandler ["ajp-bio-8010"]
gru 23, 2014 10:01:24 PM org.apache.catalina.startup.Catalina start INFO: Server startup in 13692 ms
22:01:25,527 DEBUG FlowHandlerMapping:108 - Mapping requestwith URI '/SJM/app/main' to flow with id 'main'
22:01:25,539 DEBUGFlowExecutorImpl:135 - Launching new execution of flow 'main' withinput null
22:01:25,539 DEBUG FlowDefinitionRegistryImpl:59 - GettingFlowDefinition with id 'main'
22:01:25,555 DEBUG DefaultFlowHolder:83- Assembling the flow for the first time
22:01:25,664 DEBUG FlowExecutionImplFactory:78 - Creating new execution of 'main'
22:01:25,680 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded[2] of possible 2 listeners for this execution request for flow'main', the listeners to attach are list[org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:25,680 DEBUG FlowExecutionImpl:215 - Starting in org.springframework.webflow.mvc.servlet.MvcExternalContext#6f98bf1with input null
22:01:25,758 DEBUG ViewState:189 - Entering state'welcome' of flow 'main' 22:01:25,774 DEBUGSessionBindingConversationManager:78 - Putting conversation attribute'name' with value main
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'caption' with value null
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'description' with value null
22:01:25,774 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'flowExecutionSnapshotGroup' with value org.springframework.webflow.execution.repository.impl.SimpleFlowExecutionSnapshotGroup#67079bb1
22:01:25,774 DEBUG FlowExecutionImpl:419 - Assigned key e1s1
22:01:25,774 DEBUG SessionBindingConversationManager:67 - Lockingconversation 1
22:01:25,774 DEBUG DefaultFlowExecutionRepository:121 -Putting flow execution '[FlowExecutionImpl#277b5201 flow = 'main',flowSessions = list[[FlowSessionImpl#1144d3e7 flow = 'main', state ='welcome', scope = map['viewScope' -map[[empty]]]]]]' intorepository
22:01:25,789 DEBUG DefaultFlowExecutionRepository:128 -Adding snapshot to group with id 1
22:01:25,789 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'scope' with value map['flashScope' -map['messagesMemento' ->map[[null] -list[[empty]]]]]
22:01:25,789 DEBUG SessionBindingConversationManager:99 - Unlocking conversation 1
22:01:25,789 DEBUG FlowHandlerAdapter:367 - Sending flow executionredirect to '/SJM/app/main?execution=e1s1'
22:01:25,961 DEBUG FlowHandlerMapping:108 - Mapping request with URI '/SJM/app/main' toflow with id 'main'
22:01:25,961 DEBUG FlowExecutorImpl:161 - Resumingflow execution with key 'e1s1 22:01:25,961 DEBUGSessionBindingConversationManager:67 - Locking conversation 1
22:01:25,961 DEBUG DefaultFlowExecutionRepository:106 - Getting flowexecution with key 'e1s1'
22:01:25,961 DEBUG FlowDefinitionRegistryImpl:59 - Getting FlowDefinition with id 'main'
22:01:25,961 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded[2] of possible 2 listeners for this execution request for flow'main', the listeners to attach arelist[org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:25,961 DEBUG FlowExecutionImpl:249 - Resuming inorg.springframework.webflow.mvc.servlet.MvcExternalContext#21d18342
22:01:26,519 DEBUG ViewState:289 - Rendering + [JSFView ='/WEB-INF/flows/main/welcome.xhtml']
22:01:26,519 DEBUG ViewState:290- Flash scope = map[[empty]]
22:01:26,520 DEBUG ViewState:291 - Messages = [DefaultMessageContext#60573326 sourceMessages = map[[null]-list[[empty]]]]
22:01:26,631 DEBUG DefaultFlowExecutionRepository:121 - Putting flow execution'[FlowExecutionImpl#3fcc8fc7 flow = 'main', flowSessions =list[[FlowSessionImpl#ef3728a flow = 'main', state = 'welcome', scope= map['viewScope' -map['flowSerializedViewState' -[FlowSerializedView#10e4c9b1 viewId ='/WEB-INF/flows/main/welcome.xhtml']]]]]]' into repository
22:01:26,636 DEBUG DefaultFlowExecutionRepository:128 - Addingsnapshot to group with id 1
22:01:26,636 DEBUG SessionBindingConversationManager:78 - Putting conversation attribute'scope' with value map['flashScope' -map['messagesMemento' ->map[[empty]]]] 22:01:26,637 DEBUG SessionBindingConversationManager:99- Unlocking conversation 1
22:01:28,327 DEBUG FlowHandlerMapping:108 - Mapping request with URI '/SJM/app/main' to flow with id 'main'
22:01:28,327 DEBUG FlowExecutorImpl:161 - Resuming flow execution withkey 'e1s1
22:01:28,327 DEBUG SessionBindingConversationManager:67 -Locking conversation 1
22:01:28,343 DEBUG DefaultFlowExecutionRepository:106 - Getting flow execution with key'e1s1'
22:01:28,343 DEBUG FlowDefinitionRegistryImpl:59 - GettingFlowDefinition with id 'main'
22:01:28,345 DEBUG ConditionalFlowExecutionListenerLoader:87 - Loaded [2] of possible 2listeners for this execution request for flow 'main', the listeners to attach are list [org.springframework.webflow.persistence.JpaFlowExecutionListener#16495871,org.springframework.faces.webflow.FlowFacesContextLifecycleListener#294d6e25]
22:01:28,345 DEBUG FlowExecutionImpl:249 - Resuming inorg.springframework.webflow.mvc.servlet.MvcExternalContext#19f6d704
22:01:28,360 DEBUG FlowExecutionImpl:590 - Attempting to handle[org.springframework.webflow.execution.FlowExecutionException:Exception thrown in state 'welcome' of flow 'main'] with root cause[java.lang.NullPointerException]
22:01:28,360 DEBUGFlowExecutionImpl:611 - Rethrowing unhandled flow execution exception22:01:28,360 DEBUG SessionBindingConversationManager:99 - Unlockingconversation 1
gru 23, 2014 10:01:28 PMorg.apache.catalina.core.StandardWrapperValve invoke SEVERE:Servlet.service() for servlet [Spring MVC Dispatcher Servlet] incontext with path [/SJM] threw exception [Request processing failed;nested exception isorg.springframework.webflow.execution.FlowExecutionException:Exception thrown in state 'welcome' of flow 'main'] with root causejava.lang.NullPointerException
at com.sjm.dao.ModelDao.findByStartTime(ModelDao.java:34)
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)
at org.apache.el.parser.AstValue.invoke(AstValue.java:278)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:273)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:81)
at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:55)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at org.springframework.faces.webflow.FlowLifecycle.invokePhase(FlowLifecycle.java:127)
at org.springframework.faces.webflow.FlowLifecycle.execute(FlowLifecycle.java:70)
at org.springframework.faces.webflow.JsfView.processUserEvent(JsfView.java:120)
at org.springframework.webflow.engine.ViewState.handleEvent(ViewState.java:226)
at org.springframework.webflow.engine.ViewState.resume(ViewState.java:196)
at org.springframework.webflow.engine.Flow.resume(Flow.java:545)
at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:258)
at org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)
at org.springframework.webflow.mvc.servlet.FlowHandlerAdapter.handle(FlowHandlerAdapter.java:183)
at org.springframework.faces.webflow.JsfFlowHandlerAdapter.handle(JsfFlowHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$Wrappingrunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:744)
NawNeHier.java
package com.sjm.model;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
#Entity
#Table(name="NAW_NE_HIER")
public class NawNeHier implements Serializable {
private static final long serialVersionUID = 1L;
#Id
private int hierId;
private int parentHierId;
private String type;
private String name;
private String display_name;
public NawNeHier() {
}
public int getHierId() {
return hierId;
}
public void setHierId(int hierId) {
this.hierId = hierId;
}
public int getParentHierId() {
return parentHierId;
}
public void setParentHierId(int parentHierId) {
this.parentHierId = parentHierId;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplay_name() {
return display_name;
}
public void setDisplay_name(String display_name) {
this.display_name = display_name;
}
}
ModelDao.java
package com.sjm.dao;
import javax.faces.bean.ManagedBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import com.sjm.model.NawNeHier;
#ManagedBean(name="modelDao")
public class ModelDao {
#PersistenceContext
private EntityManager entityManager;
private NawNeHier nawNeHier;
public ModelDao () {}
public NawNeHier getNawNeHier() {
return nawNeHier;
}
public void setNawNeHier(NawNeHier nawNeHier) {
this.nawNeHier = nawNeHier;
}
public EntityManager getEntityManager() {
return entityManager;
}
public void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
public void findByStartTime() {
String jpql = "SELECT n FROM NAW_NE_HIER n";
this.nawNeHier = entityManager.createQuery(jpql, NawNeHier.class).getSingleResult();
}
}
index.xhtml
<h:form id="myform">
<p:commandButton value="Count" action="#{modelDao.findByStartTime}" update="dataTable"/>
<p:dataTable id="dataTable" var="nawNeHier" value="#{modelDao.nawNeHier}">
<p:column headerText="hierId">
<h:outputText value="#{nawNeHier.hierId}" />
</p:column>
<p:column headerText="parentHierId">
<h:outputText value="#{nawNeHier.parentHierId}" />
</p:column>
<p:column headerText="type">
<h:outputText value="#{nawNeHier.type}" />
</p:column>
<p:column headerText="name">
<h:outputText value="#{nawNeHier.name}" />
</p:column>
<p:column headerText="display_name">
<h:outputText value="#{nawNeHier.display_name}" />
</p:column>
</p:dataTable>
</h:form>

Not able to connect to HBase from Windows

I am trying to run a HBase Java Client Program from Windows.
All I have is 1) A Java Program without any compiler error
2) hbase-site.xml
(No other HDFS or HBase config files I have. Only the above one.)
When I run the program I get the following error-given in the last block. Do I miss something?
Both I am giving here.
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>IP Address1,IPAddress2,IPAddress3</value>
</property>
</configuration>
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
import java.io.IOException;
public class HConnect
{
public static void main(String[] args)
{
try
{
Configuration aConfig = HBaseConfiguration.create();
HTable aTable = new HTable(aConfig, "TestTable");
byte[] aRowKey = Bytes.toBytes("RowKey1");
Put aPut = new Put(aRowKey);
byte[] aColFamily = Bytes.toBytes("ColumnFamily1");
byte[] aColumn = Bytes.toBytes("Column1");
byte[] aColumnVal = Bytes.toBytes("ColumnValue1");
aPut.add(aColFamily, aColumn, aColumnVal);
aTable.put(aPut);
aTable.close();
}
catch(IOException aException_in)
{
System.out.println("");
}
}
}
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Sep 27, 2013 3:16:13 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper <init>
INFO: The identifier of this process is 7948#sisavip5-600b
Sep 27, 2013 3:16:15 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper retryOrThrow
WARNING: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
Sep 27, 2013 3:16:15 PM org.apache.hadoop.hbase.util.RetryCounter sleepUntilNextRetry
INFO: Sleeping 2000ms before retry #1...
Sep 27, 2013 3:16:18 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper retryOrThrow
WARNING: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
Sep 27, 2013 3:16:18 PM org.apache.hadoop.hbase.util.RetryCounter sleepUntilNextRetry
INFO: Sleeping 4000ms before retry #2...
Sep 27, 2013 3:16:22 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper retryOrThrow
WARNING: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
Sep 27, 2013 3:16:22 PM org.apache.hadoop.hbase.util.RetryCounter sleepUntilNextRetry
INFO: Sleeping 8000ms before retry #3...
Sep 27, 2013 3:16:31 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper retryOrThrow
WARNING: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
Sep 27, 2013 3:16:31 PM org.apache.hadoop.hbase.zookeeper.RecoverableZooKeeper retryOrThrow
SEVERE: ZooKeeper exists failed after 3 retries
Sep 27, 2013 3:16:31 PM org.apache.hadoop.hbase.zookeeper.ZKUtil checkExists
WARNING: hconnection Unable to set watcher on znode (/hbase/hbaseid)
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/hbaseid
I did not have core-site.xml and later I had some connectivity issues
to the HDFS name node. Once I solved these I am able to insert data.
Also I resolved the following dependencies while I developed the client program that inserts data into HBase:
commons-lang-2.6
commons-logging-1.1.3
slf4j-1.7.5
protobuf-java-2.4.0a .

Resources