How to fix that error?
Exception in thread "main" java.io.FileNotFoundException: E:\n\demo%20(1)\demo\target\classes\serviceAccountKey.json (The system cannot find the path specified)
File file = new File(Objects.requireNonNull(classLoader.getResource("serviceAccountKey.json")).getFile());
FirebaseOptions options;
try (FileInputStream serviceAccount = new FileInputStream(file.getAbsolutePath())) {
options = new Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setDatabaseUrl("https://springboot-c7d7e-default-rtdb.firebaseio.com")
.build();
}
i*m using Corda 4.0 RC1 and have a clone of the cash-issuer repository; there i have a Corda-ResponderFlow which should do a business test; currently it throws an exception; the flow is programmed in this way
class ReceiveBankAccount(val otherSession: FlowSession) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
logger.info("Starting ReceiveBankAccount flow...")
val signedTransactionFlow = object : SignTransactionFlow(otherSession) {
#Suspendable
override fun checkTransaction(stx: SignedTransaction) = requireThat {
val bankAccountState = stx.tx.outputsOfType<BankAccountState>().single()
val result = getBankAccountStateByAccountNumber(bankAccountState.accountNumber, serviceHub)
if (result != null) {
val linearId = result.state.data.linearId
throw IllegalArgumentException("Bank account $bankAccountState already exists with linearId ($linearId).")
}
}
}
subFlow(signedTransactionFlow)
if (!serviceHub.myInfo.isLegalIdentity(otherSession.counterparty)) {
subFlow(ReceiveFinalityFlow(otherSession))
}
}
}
after the execution of the parent corda-flow AddBankAccount i get the following error net.corda.core.flows.UnexpectedFlowEndException: Tried to access ended session SessionId(toLong=8223329095323268472) with empty buffer
what do i wrong? can anybody help me?
my stack trace is
net.corda.core.flows.UnexpectedFlowEndException: Tried to access ended session SessionId(toLong=8017581909056924623) with empty buffer
at net.corda.node.services.statemachine.FlowStateMachineImpl.processEventsUntilFlowIsResumed(FlowStateMachineImpl.kt:161) ~[corda-node-4.0-RC01.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.suspend(FlowStateMachineImpl.kt:407) ~[corda-node-4.0-RC01.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:67) ~[corda-node-4.0-RC01.jar:?]
at net.corda.node.services.statemachine.FlowSessionImpl.receive(FlowSessionImpl.kt:71) ~[corda-node-4.0-RC01.jar:?]
at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:294) ~[corda-core-4.0-RC01.jar:?]
at net.corda.core.flows.SignTransactionFlow.call(CollectSignaturesFlow.kt:198) ~[corda-core-4.0-RC01.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.subFlow(FlowStateMachineImpl.kt:290) ~[corda-node-4.0-RC01.jar:?]
at net.corda.core.flows.FlowLogic.subFlow(FlowLogic.kt:311) ~[corda-core-4.0-RC01.jar:?]
at com.r3.corda.finance.cash.issuer.service.flows.ReceiveBankAccount.call(ReceiveBankAccount.kt:31) ~[classes/:?]
at com.r3.corda.finance.cash.issuer.service.flows.ReceiveBankAccount.call(ReceiveBankAccount.kt:12) ~[classes/:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:228) ~[corda-node-4.0-RC01.jar:?]
at net.corda.node.services.statemachine.FlowStateMachineImpl.run(FlowStateMachineImpl.kt:45) ~[corda-node-4.0-RC01.jar:?]
at co.paralleluniverse.fibers.Fiber.run1(Fiber.java:1092) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.Fiber.exec(Fiber.java:788) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.doExec(RunnableFiberTask.java:100) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at co.paralleluniverse.fibers.RunnableFiberTask.run(RunnableFiberTask.java:91) ~[quasar-core-0.7.10-jdk8.jar:0.7.10]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_131]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_131]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_131]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_131]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_131]
at net.corda.node.utilities.AffinityExecutor$ServiceAffinityExecutor$1$thread$1.run(AffinityExecutor.kt:63) ~[corda-node-4.0-RC01.jar:?]
#Suspendable
override fun call(): SignedTransaction {
logger.info("Starting AddBankAccount flow...")
val accountNumber = bankAccount.accountNumber
logger.info("Checking for existence of state for $bankAccount.")
val result = getBankAccountStateByAccountNumber(accountNumber, serviceHub)
if (result != null) {
val linearId = result.state.data.linearId
throw IllegalArgumentException("Bank account $accountNumber already exists with linearId ($linearId).")
}
logger.info("No state for $bankAccount. Adding it.")
progressTracker.currentStep = TX_BUILDING
val bankAccountState = bankAccount.toState(ourIdentity, verifier)
val notary = serviceHub.networkMapCache.notaryIdentities.first()
val verifierSsession = initiateFlow(bankAccountState.verifier)
// The node running this flow is always the only signer.
val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey))
val outputStateAndContract = StateAndContract(bankAccountState, BankAccountContract.CONTRACT_ID)
val unsignedTransaction = TransactionBuilder(notary = notary).withItems(command, outputStateAndContract)
progressTracker.currentStep = TX_SIGNING
val partiallySignedTransaction = serviceHub.signInitialTransaction(unsignedTransaction)
progressTracker.currentStep = TX_VERIFICATION
partiallySignedTransaction.verify(serviceHub)
progressTracker.currentStep = SIGS_GATHERING
val sessionsForFinality = if (serviceHub.myInfo.isLegalIdentity(bankAccountState.verifier)) emptyList() else listOf(verifierSsession)
val fullySignedTx = subFlow(CollectSignaturesFlow(partiallySignedTransaction, sessionsForFinality, SIGS_GATHERING.childProgressTracker()))
progressTracker.currentStep = VERIFYING_SIGS
fullySignedTx.verifyRequiredSignatures()
progressTracker.currentStep = FINALISATION
// Share the added bank account state with the verifier/issuer.
return subFlow(FinalityFlow(fullySignedTx, sessionsForFinality, FINALISATION.childProgressTracker()))
}
ERROR in InitiatorFlow:
flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer: exception: Collection contains no element matching the predicate.
Fri Jan 18 11:14:03 CET 2019>>> [ERROR] 11:14:03+0100 [pool-8-thread-2] command.CRaSHSession.execute - Error while evaluating request 'flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer' flow start AddBankAccount bankAccount: { accountId: "12345", accountName: "Roger's Account", accountNumber: { sortCode: "442200" , accountNumber: "13371337", type: "uk" }, currency: "GBP" }, verifier: Issuer: exception: Collection contains no element matching the predicate. [errorCode=hf0q78, moreInformationAt=https://errors.corda.net/OS/4.0-RC01/hf0q78]
WARNs in InitiatorFlow:
[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.
[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.
[WARN] 11:14:07+0100 [rpc-client-observation-pool-1] internal.RPCClientProxyHandler.onRemoval - A hot observable returned from an RPC was never subscribed to. This wastes server-side resources because it was queueing observations for retrieval. It is being closed now, but please adjust your code to call .notUsed() on the observable to close it explicitly. (Java users: subscribe to it then unsubscribe). If you aren't sure where the leak is coming from, set -Dnet.corda.client.rpc.trackRpcCallSites=true on the JVM command line and you will get a stack trace with this warning.
You will have to add key of bankAccountState.verifier to command.
In your initiator flow change command from:
val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey))
to:
val command = Command(BankAccountContract.Add(), listOf(ourIdentity.owningKey,bankAccountState.verifier.owningKey))
I want to use kotlin's object as dto
#ResponseBody
fun getBindCar(coachId: Long): List<Any> {
val coach = coachRepository.findById(coachId).get()
var result = mutableListOf<Any>()
coach?.cars.forEach { it ->
var o = object : Serializable {
var id: Long = 0L
var licenceNum = ""
}
o.id = it.id
o.licenceNum = it.licenceNum
result.add(o)
}
return result
}
when it return ,throw exception
2018:04:106:18:35:36.936 [http-nio-8080-exec-4] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Resolved exception caused by Handler execution: java.lang.ClassCastException: org.appsugar.archetypes.web.controller.oa.CoachController$getBindCar$1$o$1 cannot be cast to org.springframework.core.io.support.ResourceRegion
2018:04:106:18:35:36.950 [http-nio-8080-exec-4] ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalStateException: getOutputStream() has already been called for this response] with root cause
java.lang.IllegalStateException: getOutputStream() has already been called for this response
When I update the return type from List<Any> to Any , it works
I'm using Spring MVC NamedParameterJdbcTemplate, when i call "userService.addAndSendAccountActivationEmail(user, request)" from controller, i got error. But if i don't use named parameter(like: private static final String ADD = "insert into user_(user_id, email, username, password, create_date, modified_date, status_) values(?, ?, ?, ?, ?, ?, ?)"), everything work fine for me.
When this line has been called on BaseDao "jdbcTemplate.getJdbcOperations().update(sql, param, keyHolder)", i see nothing in "param" object.
I've added "org.springframework.jdbc" level to track, see my error log below.
Any help will be greatly appreciated.
#Service("userService")
public class UserService implements Serializable {
private static final long serialVersionUID = 1L;
#Resource
private UserDao userDao;
#Transactional
public void addAndSendAccountActivationEmail(User user, HttpServletRequest request) throws SystemException {
add(user);
// sendAccountActivationEmail(user, request);
}
}
public class UserDao extends BaseDao {
*/
private static final long serialVersionUID = 1L;
public UserDao(NamedParameterJdbcTemplate jdbcTemplate) {
super(jdbcTemplate);
}
private static final String ADD = "insert into user_(user_id, email, username, password, create_date, modified_date, status_) values(:userId, :email, :username, :password, :createDate, :modifiedDate, :status)";
public void add(User user) throws SystemException {
long userId = updateForLongKey(ADD, user);
user.setUserId(userId);
}
}
public class BaseDao implements Serializable {
private static final long serialVersionUID = 1L;
protected NamedParameterJdbcTemplate jdbcTemplate;
protected BaseDao(NamedParameterJdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
protected <T> long updateForLongKey(final String sql,T t){
SqlParameterSource param = new BeanPropertySqlParameterSource(t);
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.getJdbcOperations().update(sql, param, keyHolder);
return keyHolder.getKey().longValue();
}
}
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Creating new transaction with name [com.htws.account.service.UserService.addAndSendAccountActivationEmail]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT; ''
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Acquired Connection [com.mchange.v2.c3p0.impl.NewProxyConnection#6589127] for JDBC transaction
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Switching JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection#6589127] to manual commit
DEBUG: org.springframework.jdbc.core.JdbcTemplate - Executing prepared SQL update
DEBUG: org.springframework.jdbc.core.JdbcTemplate - Executing prepared SQL statement [insert into user_(user_id, email, username, password, create_date, modified_date, status_) values(:userId, :email, :username, :password, :createDate, :modifiedDate, :status)]
TRACE: org.springframework.jdbc.core.StatementCreatorUtils - Setting SQL statement parameter value: column index 1, parameter value [org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource#1dafb644], value class [org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource], SQL type unknown
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
INFO : org.springframework.jdbc.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase]
DEBUG: org.springframework.jdbc.support.SQLErrorCodesFactory - Looking up default SQLErrorCodes for DataSource [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 5000, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge16h8tu21anplw8eof|6469cee6, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge16h8tu21anplw8eof|6469cee6, idleConnectionTestPeriod -> 3000, initialPoolSize -> 10, jdbcUrl -> jdbc:mysql://localhost:3306/htws?useUnicode=true&characterEncoding=UTF-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 1800, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 50, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]]
DEBUG: org.springframework.jdbc.support.SQLErrorCodesFactory - Database product name cached for DataSource [com.mchange.v2.c3p0.ComboPooledDataSource#bd9f0537]: name is 'MySQL'
DEBUG: org.springframework.jdbc.support.SQLErrorCodesFactory - SQL error codes for 'MySQL' found
DEBUG: org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '0', will now try the fallback translator
DEBUG: org.springframework.jdbc.support.SQLStateSQLExceptionTranslator - Extracted SQL state class 'S1' from value 'S1009'
TRACE: org.springframework.jdbc.datasource.DataSourceTransactionManager - Triggering beforeCompletion synchronization
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Initiating transaction rollback
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Rolling back JDBC transaction on Connection [com.mchange.v2.c3p0.impl.NewProxyConnection#6589127]
TRACE: org.springframework.jdbc.datasource.DataSourceTransactionManager - Triggering afterCompletion synchronization
DEBUG: org.springframework.jdbc.datasource.DataSourceTransactionManager - Releasing JDBC Connection [com.mchange.v2.c3p0.impl.NewProxyConnection#6589127] after transaction
DEBUG: org.springframework.jdbc.datasource.DataSourceUtils - Returning JDBC Connection to DataSource
ERROR: com.htws.account.web.UserController - PreparedStatementCallback; SQL [insert into user_(user_id, email, username, password, create_date, modified_date, status_) values(:userId, :email, :username, :password, :createDate, :modifiedDate, :status)]; Invalid argument value: java.io.NotSerializableException; nested exception is java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
org.springframework.dao.TransientDataAccessResourceException: PreparedStatementCallback; SQL [insert into user_(user_id, email, username, password, create_date, modified_date, status_) values(:userId, :email, :username, :password, :createDate, :modifiedDate, :status)]; Invalid argument value: java.io.NotSerializableException; nested exception is java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.doTranslate(SQLStateSQLExceptionTranslator.java:107)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:72)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:603)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:868)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:876)
at com.htws.core.dao.BaseDao.updateForLongKey(BaseDao.java:34)
at com.htws.account.dao.UserDao.add(UserDao.java:86)
at com.htws.account.service.UserService.add(UserService.java:65)
at com.htws.account.service.UserService.addAndSendAccountActivationEmail(UserService.java:58)
at com.htws.account.service.UserService$$FastClassByCGLIB$$4b2f4817.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at com.htws.account.service.UserService$$EnhancerByCGLIB$$78d9a26a.addAndSendAccountActivationEmail(<generated>)
at com.htws.account.web.UserController.processRegister(UserController.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:827)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801)
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.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:259)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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 com.springsource.insight.collection.tcserver.request.HttpRequestOperationCollectionValve.invoke(HttpRequestOperationCollectionValve.java:64)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:409)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)
Caused by: java.sql.SQLException: Invalid argument value: java.io.NotSerializableException
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.PreparedStatement.setSerializableObject(PreparedStatement.java:4412)
at com.mysql.jdbc.PreparedStatement.setObject(PreparedStatement.java:4083)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setObject(NewProxyPreparedStatement.java:365)
at org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:365)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:217)
at org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:145)
at org.springframework.jdbc.core.ArgPreparedStatementSetter.doSetValue(ArgPreparedStatementSetter.java:65)
at org.springframework.jdbc.core.ArgPreparedStatementSetter.setValues(ArgPreparedStatementSetter.java:46)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:816)
at org.springframework.jdbc.core.JdbcTemplate$2.doInPreparedStatement(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
... 63 more
Caused by: java.io.NotSerializableException: org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at com.mysql.jdbc.PreparedStatement.setSerializableObject(PreparedStatement.java:4401)
... 73 more
try to use NamedParameterJdbcTemplate instead of SqlParameterSource .
Jdbc template dont have method which uses a SqlParameterSource
I am new to Queues. I had setup my queue in JBOSS 5.1 EAP and now while trying to inject in tho the queue am getting a ClassCastException (in lookup of JNDI), I use flex on my front end and use Spring framework for flex. When injected into the queue using quartz job it runs well and good. The quartz job is a separate project and has nothing to do with flex and spring.
I read over some where that this could be a jar issue, I had JMS jars in my spring and i tried removing, replacing all types of jars, no luck.
// Step 1. Create an initial context to perform the JNDI lookup.
InputStream in = this.getClass().getResourceAsStream(
"/clv2.properties");
Properties configProp = new Properties();
configProp.load(in);
IpAddress = configProp.getProperty("ipaddress");
port = configProp.getProperty("port");
inQueueName = configProp.getProperty("inQueueName");
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming");
// props.setProperty("java.naming.provider.url", host + ":" + port);
props.setProperty("java.naming.provider.url", "localhost" + ":"
+ 1099);
// props.setProperty("java.naming.provider.url",
// "16.181.233.61:1399");
initialContext = new InitialContext(props);
// Step 3. Perform a lookup on the Connection Factory
QueueConnectionFactory cf = (QueueConnectionFactory) initialContext
.lookup("/ConnectionFactory");
Queue queue = (Queue) initialContext
.lookup(/* "/queue/CLVInboundQueue" */inQueueName);
// Step 4.Create a JMS Connection
connection = (QueueConnection) cf.createConnection();
// Step 5. Create a JMS Session
session = (QueueSession) connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
// Step 6. Create a JMS Message Producer
// MessageProducer producer = session.createProducer(queue);
QueueSender queueSender = session.createSender(queue);
TextMessage textMessage = session.createTextMessage(message);
textMessage.setLongProperty("Rejected_Message_ID",
rejected_Message_Id);
/*
* BufferedReader reader = new BufferedReader(new
* InputStreamReader(ClassLoader.class.getResourceAsStream(file)));
* StringBuilder sb = new StringBuilder(); String line = null;
*
*
* while ((line = reader.readLine()) != null) { sb.append(line +
* "\n"); } String announcementmsg = sb.toString();
*/
commonlogger.info(textMessage);
connection.start();
// producer.send(session.createTextMessage(announcementmsg));
queueSender.send(textMessage);
This is my piece of coding to inject into the queue. I get the Exception in "//Step 3. Perform a lookup on the Connection Factory" and this is my stack trace.
09:22:20,730 ERROR [STDERR] java.lang.ClassCastException: org.jboss.jms.client.JBossConnectionFactory cannot be cast to javax.jms.QueueConnectionFactory
09:22:20,731 ERROR [STDERR] at com.cat.clv.util.InQueueReinjectMessage.sendMessage(InQueueReinjectMessage.java:63)
09:22:20,731 ERROR [STDERR] at com.cat.clv.util.RejectedMessageReinject.reProcessedMessage(RejectedMessageReinject.java:65)
09:22:20,731 ERROR [STDERR] at com.cat.clv.service.ReinjectMessagesServiceImpl.reinjectRejectedMessages(ReinjectMessagesServiceImpl.java:106)
09:22:20,731 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
09:22:20,731 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
09:22:20,732 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
09:22:20,732 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
09:22:20,732 ERROR [STDERR] at flex.messaging.services.remoting.adapters.JavaAdapter.invoke(JavaAdapter.java:421)
09:22:20,732 ERROR [STDERR] at flex.messaging.services.RemotingService.serviceMessage(RemotingService.java:183)
09:22:20,732 ERROR [STDERR] at flex.messaging.MessageBroker.routeMessageToService(MessageBroker.java:1503)
If you look at the source of JBossConnectionFactory then you will see it implements QueueConnectionFactory.
So this class cast exception can be because of :
Erroneous installation of JBoss
Different jms.jar in client and server
Can you first try out option 2 and see if it works, if not can you check if the examples work in your jboss installation.
Getting classCast Exception at lookup :
classcastexception: weblogic.jms.client.JMSconnectionFactory cannot be cast to javax.jms.QueueConnectionFactory
initialContext = new InitialContext(props);
// Step 3. Perform a lookup on the Connection Factory
QueueConnectionFactory cf = (QueueConnectionFactory) initialContext
.lookup("/ConnectionFactory");
Queue queue = (Queue) initialContext
.lookup(/* "/queue/CLVInboundQueue" */inQueueName);
// Step 4.Create a JMS Connection
connection = (QueueConnection) cf.createConnection();
// Step 5. Create a JMS Session
session = (QueueSession) connection.createSession(false,
Session.AUTO_ACKNOWLEDGE);
// Step 6. Create a JMS Message Producer
// MessageProducer producer = session.createProducer(queue);
QueueSender queueSender = session.createSender(queue);
TextMessage textMessage = session.createTextMessage(message);
textMessage.setLongProperty("Rejected_Message_ID",
rejected_Message_Id);
/*
* BufferedReader reader = new BufferedReader(new
* InputStreamReader(ClassLoader.class.getResourceAsStream(file)));
* StringBuilder sb = new StringBuilder(); String line = null;
*
*
* while ((line = reader.readLine()) != null) { sb.append(line +
* "\n"); } String announcementmsg = sb.toString();
*/
commonlogger.info(textMessage);
connection.start();
// producer.send(session.createTextMessage(announcementmsg));
queueSender.send(textMessage);