requested operation is not supported on forward only Hibernate JEE - java

I have a query that works fine but when i want to visit the second page of the results i get this exception:
org.hibernate.exception.GenericJDBCException:The requested operation is not supported on forward only result sets
Caused by : com.microsoft.sqlserver.jdbc.SQLServerException: The requested operation is not supported on forward only result sets
Here is my code
logger.info("Req�ete de recherche avanc�e des contrats: " + requete.toString());
Query query = genericDAO.createQuery(requete.toString());
setDateParameters(query, rechercheContratBean);
return HibernatePage.getHibernatePageInstance(query, rechercheContratBean.getPageNumber(), rechercheContratBean.getObjectsPerPage());
My getHibernatePageInstance()
protected static HibernatePage getHibernatePageInstance(Query query, int pageNumber, int pageSize) {
HibernatePage sp = new HibernatePage(pageNumber, pageSize);
try {
sp.scrollableResults = query.scroll(ScrollMode.FORWARD_ONLY);
sp.totalElements = sp.calculateTotalElementsByList(query);
sp.determineElements(query);
} catch (HibernateException e) {
if (log.isErrorEnabled())
log.error("Failed to create ScrollPage by getScrollPageInstanceWithTotalByQuery: " + e.getMessage());
throw e;
}
return sp;
}
with determineElement(query)
private void determineElements(Query query) throws HibernateException {
if (Integer.MAX_VALUE == this.pageNumber)
this.pageNumber = (getTotalNumberOfElements() / this.pageSize);
elements = query.setFirstResult((this.pageNumber * this.pageSize)-this.pageSize).setMaxResults(this.pageSize + 1).list();
}
I'm using hibernate.dialect=org.hibernate.dialect.SQLServer2008Dialect
Her is the stacktrace
org.hibernate.exception.GenericJDBCException: The requested operation is not supported on forward only result sets
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:52)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:108)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at com.sun.proxy.$Proxy48.absolute(Unknown Source)
at org.hibernate.loader.Loader.advance(Loader.java:1651)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1982)
at org.hibernate.loader.Loader.doQuery(Loader.java:829)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2463)
at org.hibernate.loader.Loader.doList(Loader.java:2449)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2279)
at org.hibernate.loader.Loader.list(Loader.java:2274)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1115)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at ma.softwork.commons.dao.impl.HibernatePage.determineElements(HibernatePage.java:205)
at ma.softwork.commons.dao.impl.HibernatePage.getScrollPageInstanceWithTotalByList(HibernatePage.java:180)
at ma.softwork.commons.dao.impl.HibernatePage.getHibernatePageInstance(HibernatePage.java:127)
at ma.softwork.commons.dao.impl.HibernatePage.getHibernatePageInstance(HibernatePage.java:116)
at ma.softwork.dao.impl.QueryBuilderFactory.rechercheContratsPagination(QueryBuilderFactory.java:332)
at ma.per.service.contrat.ContratService.rechercheContratsPagination(ContratService.java:250)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Am i missing something ?

Related

Database Operation Using JPA

The code works fine but as I tried to add commit command the code start giving exception. Any suggestion will be helpful.
The line transaction.commit(); is causing problem.
public class MovieDAO
{
/**
* Adds an movie record to database from the given {#link Movie}
* Displays a success message upon successful execution
* #param movie
* #throws Exception
*/
public void addMovie(Movie movie) throws Exception
{
EntityManagerFactory factory = null;
EntityManager manager = null;
MovieEntity movieobj = null;
try
{
factory = Persistence.createEntityManagerFactory("Demo");
manager = factory.createEntityManager();
movieobj = new MovieEntity();
movieobj.setLanguage(movie.getLanguage());
movieobj.setMovieId(movie.getMovieId());
movieobj.setMovieName(movie.getMovieName());
movieobj.setReleasedIn(movie.getReleasedIn());
movieobj.setRevenueInDollars(movie.getRevenueInDollars());
EntityTransaction transaction = manager.getTransaction();
transaction.begin();
manager.persist(movieobj);
transaction.commit();
}
catch(Exception e)
{
DOMConfigurator.configure("src/resources/log4j.xml");
Logger logger = Logger.getLogger(this.getClass());
logger.error(e.getMessage(), e);
//throw new Exception("DAO.TECHNICAL_ERROR");
e.printStackTrace();
}
finally
{
if(manager != null)
manager.close();
if(factory != null)
factory.close();
}
}
}
The error I am getting is:
javax.persistence.RollbackException: Error while committing the transaction
at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:94)
at dao.MovieDAO.addMovie(MovieDAO.java:44)
at ui.UserInterface.addMovie(UserInterface.java:23)
at ui.UserInterface.main(UserInterface.java:39)
Caused by: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1763)
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:82)
... 3 more
Caused by: org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:80)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:126)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:112)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:211)
at org.hibernate.engine.jdbc.batch.internal.NonBatchingBatch.addToBatch(NonBatchingBatch.java:62)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3124)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:465)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:77)
... 3 more
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:943)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1150)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:4875)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1361)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:208)
... 16 more
Seems like you are missing a table:
ORA-00942: table or view does not exist
Check the declared table for your entity and verify if this table exists in your Oracle database.

How to omit the header when reading a CSV file using Apache Drill 1.3.0 but without installing Apache Drill?

I'm trying to get the aggregate values on numeric fields using Apache Drill 1.3.0 without installing Hadoop and Apache Drill on the file system.
Now the issue is- I would like to omit the header when reading a CSV file but I am not able to find any option to tell Apache Drill, please skipFirstLine using java program as I have not installed Apache Drill.
The program terminates with the error and throws NumberFormatException because of the column name.
pom.xml
<dependency>
<groupId>org.apache.drill.exec</groupId>
<artifactId>drill-jdbc</artifactId>
<version>1.3.0</version>
</dependency>
Sample CSV File:
"ffe92de2-e633-4741-bc4b-83e91dce665a.csv"
"A"
"100"
Sample Java Program:
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
/*
* Created By: Ashish Pancholi
* On: 16-12-2015
* */
public class DrillExample {
private static final String DRILL_JDBC_LOCAL_URI = "jdbc:drill:zk=local";
private Connection con = null;
public DrillExample() throws SQLException {
con = new org.apache.drill.jdbc.Driver().connect(DRILL_JDBC_LOCAL_URI, getDefaultProperties());
}
public int getArchiveNumFieldSUM(String filepath) throws Exception {
//query to be executed
String query = "select sum(cast(columns[0] as int)) from dfs.`"+filepath+"`";
try {
// creating statement
Statement stmt = con.createStatement();
// executing query
ResultSet rs = stmt.executeQuery(query);
// get the number of rows from the result set
rs.next();
return rs.getInt(1);
} catch (Exception ex) {
throw ex;
}
}
private Properties getDefaultProperties() {
final Properties properties = new Properties();
properties.setProperty(org.apache.drill.exec.ExecConstants.HTTP_ENABLE, "false");
return properties;
}
public void shutdownApacheDrill(){
if (con != null) {
try {
con.close();
} catch (SQLException e) {
//ignore
}
}
}
public static void main(String[] arg){
try {
int count = 0;
DrillExample local = new DrillExample();
String filePath = "C:/Workarea/Project/xyz/Structured Data/ffe92de2-e633-4741-bc4b-83e91dce665a.csv";
try {
count = local.getArchiveNumFieldSUM(filePath);
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(count);
}catch(Exception ex){
ex.printStackTrace();
}
}
}
I'm getting the following Error:
SYSTEM ERROR: NumberFormatException: A
Fragment 0:0
[Error Id: 72dec3db-8f28-462d-838d-dcb60663e389 on ashish:31010].
java.sql.SQLException: SYSTEM ERROR: NumberFormatException: A
Fragment 0:0
[Error Id: 72dec3db-8f28-462d-838d-dcb60663e389 on ashish:31010]
at org.apache.drill.jdbc.impl.DrillCursor.nextRowInternally(DrillCursor.java:247)
at org.apache.drill.jdbc.impl.DrillCursor.loadInitialSchema(DrillCursor.java:290)
at org.apache.drill.jdbc.impl.DrillResultSetImpl.execute(DrillResultSetImpl.java:1359)
at org.apache.drill.jdbc.impl.DrillResultSetImpl.execute(DrillResultSetImpl.java:74)
at net.hydromatic.avatica.AvaticaConnection.executeQueryInternal(AvaticaConnection.java:404)
at net.hydromatic.avatica.AvaticaStatement.executeQueryInternal(AvaticaStatement.java:351)
at net.hydromatic.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:78)
at org.apache.drill.jdbc.impl.DrillStatementImpl.executeQuery(DrillStatementImpl.java:97)
at org.openskye.core.structured.DrillExample.getArchiveNumFieldSUM(DrillExample.java:30)
at org.openskye.core.structured.DrillExample.main(DrillExample.java:61)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
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 com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)
Caused by: org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: NumberFormatException: A
Fragment 0:0
[Error Id: 72dec3db-8f28-462d-838d-dcb60663e389 on ashish:31010]
at org.apache.drill.exec.rpc.user.QueryResultHandler.resultArrived(QueryResultHandler.java:118)
at org.apache.drill.exec.rpc.user.UserClient.handleReponse(UserClient.java:112)
at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:47)
at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:32)
at org.apache.drill.exec.rpc.RpcBus.handle(RpcBus.java:69)
at org.apache.drill.exec.rpc.RpcBus$RequestEvent.run(RpcBus.java:400)
at org.apache.drill.common.SerializedExecutor$RunnableProcessor.run(SerializedExecutor.java:105)
at org.apache.drill.exec.rpc.RpcBus$SameExecutor.execute(RpcBus.java:264)
at org.apache.drill.common.SerializedExecutor.execute(SerializedExecutor.java:142)
at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:298)
at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:269)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
20:07:26.097 [USER-rpc-event-queue] INFO o.a.d.j.i.DrillResultSetImpl$ResultsListener - [#1] Query failed:
org.apache.drill.common.exceptions.UserRemoteException: SYSTEM ERROR: NumberFormatException: A
Fragment 0:0
[Error Id: 72dec3db-8f28-462d-838d-dcb60663e389 on ashish:31010]
at org.apache.drill.exec.rpc.user.QueryResultHandler.resultArrived(QueryResultHandler.java:118) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.user.UserClient.handleReponse(UserClient.java:112) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:47) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.BasicClientWithConnection.handle(BasicClientWithConnection.java:32) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.RpcBus.handle(RpcBus.java:69) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.RpcBus$RequestEvent.run(RpcBus.java:400) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.common.SerializedExecutor$RunnableProcessor.run(SerializedExecutor.java:105) [drill-common-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.RpcBus$SameExecutor.execute(RpcBus.java:264) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.common.SerializedExecutor.execute(SerializedExecutor.java:142) [drill-common-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:298) [drill-java-exec-1.3.0.jar:1.3.0]
at org.apache.drill.exec.rpc.RpcBus$InboundHandler.decode(RpcBus.java:269) [drill-java-exec-1.3.0.jar:1.3.0]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254) [netty-handler-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242) [netty-codec-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) [netty-transport-4.0.27.Final.jar:4.0.27.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) [netty-common-4.0.27.Final.jar:4.0.27.Final]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:254)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:242)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:339)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:324)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:847)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
at java.lang.Thread.run(Thread.java:744)
20:07:26.105 [USER-rpc-event-queue] DEBUG o.a.drill.exec.rpc.user.UserClient - Sending response with Sender 1145498900
0
UPDATE:
I found one class which sets SkipFirstLine property but I am not able to understand where I have to pass it?
TextParsingSettings textParsingSettings = new TextParsingSettings();
textParsingSettings.setSkipFirstLine(true);
Queries that change storage plugin configuration options can now be written with Drill 1.4 (check Release Notes)
You can modify your query:
String query = "SELECT sum(cast(A as int)) FROM TABLE(dfs.`"+filepath+"`(type => 'text', fieldDelimiter => '^', extractHeader => true))";
Note: I am using cast(A as int) not cast(columns[0] as int).
After extracting header, you need to use column names mentioned in header not columns[] to extract column names.

Hibernate issue java.lang.Boolean cannot be cast to java.lang.String Using JDK 1.7

I am facing issue with Hibernate.
Using Hibernate 3.2.6 and JDK 1.7.0_21
Is this issue coming due to JDK compatibility with Hibernate version?
This issue is random. I still unable to find steps to reproduce.
2014-07-14 06:09:10,661 [DEBUG] EventExpenseAreaService.getEventSummary:654 - Revenue Value (Hari) --> 1166.15
2014-07-14 06:09:18,665 [ERROR] EventSetupService.getEventById:1451 - java.lang.Boolean cannot be cast to java.lang.String
java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String
at org.hibernate.type.StringType.toString(StringType.java:44)
at org.hibernate.type.NullableType.nullSafeToString(NullableType.java:93)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:140)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:107)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2002)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2376)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2312)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2612)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:96)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.sibisoft.northstar.events.service.EventSetupService.getEventById(EventSetupService.java:1441)
at com.sibisoft.northstar.events.struts.EventAction.load(EventAction.java:1037)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
Code getEventById
public EventDTO getEventById(Integer eventId,boolean logActivity, Session session)throws Exception {
EventDTO event = null;
Transaction transaction = null;
try {
if (session == null) {
session = HibernateSessionFactory.getSession();
if(logActivity){
transaction = session.beginTransaction();
}
}
event = (EventDTO) super.getByPrimaryKey(EventDTO.class, eventId,session);
if(transaction!=null){
transaction.commit();
}
} catch (HibernateException e) {
LOGGER.error(e.getMessage(), e);
if(transaction!=null){
transaction.rollback();
}
throw e;
}catch (Exception e) {
LOGGER.error(e.getMessage(), e);
if(transaction!=null){
transaction.rollback();
}
throw e;
}
return event;
}
Method : getByPrimaryKey
protected BaseEventDTO getByPrimaryKey(Class clazz, Integer pk,Session session) throws Exception{
BaseEventDTO dto = null;
Transaction tx = null;
try {
if (session == null) {
session = HibernateSessionFactory.getSession();
}
dto = (BaseEventDTO) session.get(clazz, pk);
return dto;
}
catch(Exception e){
LOGGER.error(e);
if (tx !=null) {
tx.rollback();
}
throw e;
}
}
JDK 7 have changed Class.getDeclaredMethods() so the order is not guaranteed. [click here]
You might have a property in Object mapping that have getter method String getProperty() as well as Boolean isPropery() that is causing problem intermittently.
Hibernate 3 BasicPropertyAccessor.getterMethod(...) some time finds getProperty() and some time isProperty() due to unspecified ordering in JDK 7 by getDeclaredMethods(). which confuses hibernate and it invokes Boolean Type method for String type property.
You need to rename one method to get expected results.
Similar question on Hibernate Forum: https://forum.hibernate.org/viewtopic.php?p=2474641

java.lang.StackTraceElement does not have a no-arg default constructor [duplicate]

This question already has answers here:
Unable to create JAXBContext creating my wsdl
(8 answers)
Closed 4 years ago.
I'm trying to deploy a webservice and when I do it I have the next error:
avax.xml.ws.WebServiceException: Unable to create JAXBContext
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:171)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:99)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:250)
at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:343)
at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:205)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:513)
at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:568)
at org.glassfish.webservices.WSServletContextListener.registerEndpoint(WSServletContextListener.java:260)
at org.glassfish.webservices.WSServletContextListener.contextInitialized(WSServletContextListener.java:99)
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:4750)
at com.sun.enterprise.web.WebModule.contextListenerStart(WebModule.java:550)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5366)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
java.lang.StackTraceElement does not have a no-arg default constructor.
this problem is related to the following location:
at java.lang.StackTraceElement
at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
at java.lang.Throwable
at java.lang.Exception
at java.sql.SQLException
at public java.sql.SQLException com.parkinsoncontrol.jaxws.SQLExceptionBean.nextException
at com.parkinsoncontrol.jaxws.SQLExceptionBean
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:158)
... 49 more
And the code I'm trying to deploy is this one:
#WebService(serviceName = "WsParkinsonControl")
public class WsParkinsonControl {
private Connection conectar(){
this.conexion = Conector.getConnection(Conector.getCibertec());
return this.conexion;
}
/**
* Web service operation
*/
#WebMethod(operationName = "registerUser")
public TDataReturn registerUser(#WebParam(name = "user") TDataUser user) throws Exception {
//TODO write your implementation code here:
TDataReturn data= new TDataReturn();
this.conexion = Conector.getConnection( Conector.getCibertec() );
try {
this.conexion.setAutoCommit(false);
SQL="INSERT INTO user (name,patronimic,surname,phone,address,country,city,village,isPacient,isDoctor,licensenumber,email,password,licenseNumberDoctor,birthdate,parkinson_idparkinson) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
this.pstm = this.conexion.prepareStatement(SQL);
// `iduser` INT NOT NULL AUTO_INCREMENT,
this.pstm.setString(1,user.getName());
this.pstm.setString(2,user.getPatronimic());
this.pstm.setString(3,user.getSurname());
this.pstm.setString(4,user.getPhone());
this.pstm.setString(5,user.getAddress());
this.pstm.setString(6,user.getCountry());
this.pstm.setString(7,user.getCity());
this.pstm.setString(8,user.getVillage());
this.pstm.setBoolean(9,user.isIsPacient());
this.pstm.setBoolean(10,user.isIsDoctor());
this.pstm.setString(11,user.getLicenseNumber());
this.pstm.setString(12,user.getEmail());
this.pstm.setString(13,user.getPassword());
this.pstm.setString(14,user.getLicenseNumberDoctor());
this.pstm.setString(15, user.getBirthdate());
this.pstm.setInt(16,user.getParkinson());
int ejecutado = this.pstm.executeUpdate();
System.out.println("Ejecutado es:"+ejecutado);
if(ejecutado==0){
data.setMiss(1);
data.setDescription_m("Error after recording an user");
throw new Exception("Error after recording an user");
}
System.out.println("Voy a hacer el commit");
this.conexion.commit();
} catch (SQLException ex) {
System.out.println("Ejecutado es despues:0");
Logger.getLogger(WsParkinsonControl.class.getName()).log(Level.SEVERE, null, ex);
}
this.conexion.close();
data.setMiss(0);
data.setDescription_m("");
System.out.println("Data miss es:"+data.getMiss());
return data;
}
/**
* Web service operation
*/
#WebMethod(operationName = "modifyUser")
public TDataReturn modifyUser(#WebParam(name = "user") TDataUser user) {
//TODO write your implementation code here:
TDataReturn data= new TDataReturn();
return data;
}
/**
* Web service operation
*/
#WebMethod(operationName = "logon")
public Boolean logon(#WebParam(name = "login") String login, #WebParam(name = "password") String password) throws SQLException {
//TODO write your implementation code here:
this.conexion=conectar();
System.out.println("Login is "+login);
System.out.println("Password is "+password);
try {
SQL="SELECT idusuario from user where email=? AND password=?";
this.pstm = this.conexion.prepareStatement(SQL);
this.pstm.setString(1, login);
this.pstm.setString(2, password);
this.rs = this.pstm.executeQuery();
if(this.rs.getFetchSize()!=0){
return true;
}
else{
return false;
}
} catch (SQLException ex) {
Logger.getLogger(WsParkinsonControl.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Login correcto");
this.conexion.close();
return true;
}
/**
* Web service operation
*/
#WebMethod(operationName = "list_users")
public TAnswerUsers list_users(#WebParam(name = "iduser") int iduser) {
//TODO write your implementation code here:
TAnswerUsers result = new TAnswerUsers();
this.conexion=conectar();
try {
//this.stm = this.conexion.createStatement();
if(iduser==0){
SQL="SELECT t1.id_cuenta as id_cuenta,t1.id_cuenta_padre as id_cuenta_padre,";
SQL.concat("t1.nombre as nombre,t1.cif as cif,t1.impuesto as impuesto,t1.descuento as descuento,");
SQL.concat("t1.nivel as nivel,t1.borrado as borrado,t1.cod_cliente as cod_cliente FROM cuentas t1");
SQL.concat("WHERE t1.nivel >=?");
SQL.concat("AND t1.borrado=?");
this.pstm = this.conexion.prepareStatement(SQL);
this.rs = this.pstm.executeQuery();
if(this.rs.getFetchSize()!=0){
load_data_user(rs,result.getDataUser());
}
result.setMiss(0);
result.setDescription_miss("");
return result;
}else{
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
result.setMiss(-1);
result.setDescription_miss(e.getMessage());
return result;
}
result.setMiss(0);
result.setDescription_miss("");
return result;
}
private void load_data_user(ResultSet rs2, TFieldsUser[] dataUser) throws SQLException {
int index=0;
dataUser=resizeFieldsUser(dataUser,rs2);
while(rs2.next()){
dataUser[index]=new TFieldsUser();
dataUser[index].setName(rs2.getString("name"));
dataUser[index].setPatronimic(rs2.getString("patronimic"));
dataUser[index].setSurname(rs2.getString("surname"));
dataUser[index].setPhone(rs2.getString("phone"));
dataUser[index].setAddress(rs2.getString("address"));
dataUser[index].setCountry(rs2.getString("country"));
dataUser[index].setCity(rs2.getString("city"));
dataUser[index].setEmail(rs2.getString("email"));
dataUser[index].setPassword(rs2.getString("password"));
index++;
}
}
private TFieldsUser[] resizeFieldsUser(TFieldsUser[] dataUser, ResultSet rs2) throws SQLException {
int tam=rs.getFetchSize();
int n=++tam;
TFieldsUser [] newArray= new TFieldsUser[n];
for(int cnt=0;cnt<rs.getFetchSize();cnt++){
newArray[cnt]=dataUser[cnt];
}
return newArray;
}
}
I'm working with netbeans 7.2.1 and GlassFish 3.1.2 as you can check it is a simple code but when I try to deploy it I crash, please how can I do to fix this thing?. Thanks so much
I have changed one throws SQLExecption, I have changed it by one try catch and voilá, it dissapeared, why?, I don't know but it Works.

ibi.telnet.api.TnDriverException: Connection is closed

I'm trying to connect to a mainframe via java using iway telnet, this is the connection code:
public static Session conexion(String nodo,int port) throws TnDriverException {
TnDriver driver = new TnDriver();
driver.setHost(nodo);
driver.setPort(port);
driver.setEmulation(Terminal.TN_3270);
driver.setTraceOn(false);
driver.setExtendedAttributes(true);
driver.setLanguage("Cp037");
driver.setTimerTimeout(25);
driver.setTimerOn(true);
session = driver.getSession();
logger.info("CONNECTED TO MAINFRAME.");
return session;
}
During the process of connecting to the mainframe I'm getting the next exception in the first screen:
ibi.telnet.api.TnDriverException: Connection is closed...
at ibi.telnet.api.Session.waitFor(Session.java:453)
at ibi.telnet.api.Session.waitFor(Session.java:393)
at ibi.telnet.api.Session.waitFor(Session.java:312)
at
tn3270.GestionPantallas.identificaPantalla(GestionPantallas.java:73)
at
tn3270.CertificacionSindo.getTransaccion(CertificacionSindo.java:67)
at
ws.Pensiones.obtenerCertificacion(Pensiones.java:41)
at sun.reflect.GeneratedMethodAccessor486.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.wsee.component.pojo.JavaClassComponent.invoke(JavaClassComponent.java:99)
at weblogic.wsee.ws.dispatch.server.ComponentHandler.handleRequest(ComponentHandler.java:64)
at weblogic.wsee.handler.HandlerIterator.handleRequest(HandlerIterator.java:137)
at weblogic.wsee.ws.dispatch.server.ServerDispatcher.dispatch(ServerDispatcher.java:109)
at weblogic.wsee.ws.WsSkel.invoke(WsSkel.java:80)
at weblogic.wsee.server.servlet.SoapProcessor.handlePost(SoapProcessor.java:66)
at weblogic.wsee.server.servlet.SoapProcessor.process(SoapProcessor.java:44)
at weblogic.wsee.server.servlet.BaseWSServlet$AuthorizedInvoke.run(BaseWSServlet.java:257)
at weblogic.wsee.server.servlet.BaseWSServlet.service(BaseWSServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3395)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2140)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2046)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1366)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
And this is the method identificaPantalla in the class GestionPantallas, where the conexion method is.
public static int identificaPantalla(ScreenDesc[] pantallas) throws TnDriverException {
int result = -1;
try {
result = session.waitFor(pantallas);
}
catch(TnDriverException e) {
throw e;
}
return result;
}
Any idea about this issue?

Categories