小编Sti*_*n.V的帖子

java.text.ParseException:无法解析的日期

我收到以下错误:'java.text.ParseException:Unparseable date:"Aug 31 09:53:19 2011"'使用以下格式: new SimpleDateFormat("MMM dd HH:mm:ss yyyy");

有谁看到这个问题?

java android date parseexception

9
推荐指数
3
解决办法
2万
查看次数

缺少HttpClient的依赖项

我在Java桌面应用程序中使用HttpClient.我已经将httpclient-4.0.1.jarhttpmime-4.0.1.jar添加到构建路径中,但是我收到错误'org.apache.http.HttpResponse类型无法解析.它是从所需的.class文件中间接引用的.有谁知道我错过了哪个依赖/ jar?

java httpclient

6
推荐指数
1
解决办法
1万
查看次数

Hibernate java.lang.ClassCastException:org.hibernate.action.EntityIdentityInsertAction无法强制转换为org.hibernate.action.EntityInsertAction

我正在使用Hibernate和EntityManager.我用的时候

    Session session = (Session)entityManager.getDelegate();  
    session.flush();
    session.clear();
Run Code Online (Sandbox Code Playgroud)

我明白了

java.lang.ClassCastException: org.hibernate.action.EntityIdentityInsertAction cannot be cast to org.hibernate.action.EntityInsertAction
at org.hibernate.engine.ActionQueue$InsertActionSorter.sort(ActionQueue.java:636)
at org.hibernate.engine.ActionQueue.sortInsertActions(ActionQueue.java:369)
at org.hibernate.engine.ActionQueue.sortActions(ActionQueue.java:355)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:224)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
Run Code Online (Sandbox Code Playgroud)

既然它没有说明哪个实体导致问题,我就被困在这里.有谁知道是什么原因引起的?

hibernate flush entitymanager classcastexception

6
推荐指数
1
解决办法
2168
查看次数

将边距应用于运行CSS位置

我正在使用以下CSS代码将我的页脚放在页面底部:

<style type="text/css">
    @page {
        @bottom-center { content: element(footer); }
    }
    #footer {position: running(footer);}
</style>
Run Code Online (Sandbox Code Playgroud)

有没有办法将它显示得稍微高一点?添加margin-bottom: 50px似乎没有效果.

更新:页面将使用iText转换为PDF

css footer itext

4
推荐指数
1
解决办法
2894
查看次数

DAO中的ThreadLocal JPA EntityManager

在我的DAO课程中,我有一个参考EntityManager.我想EntityManager通过使用来访问线程安全的ThreadLocal.

到目前为止,我的尝试只导致了NullPointerExceptions,我似乎无法找到一个体面的例子.

有人可以给我一个例子或指出我正确的方向吗?

更新:我已经尝试过BalusC的建议,但是当我同时通过JSF和JAX-RS webservice访问DAO时,我仍然遇到错误:

 org.hibernate.exception.GenericJDBCException: could not load an entity
 java.sql.SQLException: You can't operate on a closed Connection!!!
 java.lang.NullPointerException
    at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement
Run Code Online (Sandbox Code Playgroud)

我正在使用C3P0,所以我不知道为什么闭合连接是个问题.

update2:BalusC的最后评论似乎解决了我的问题:At least, you should not have a single instance of the DAO class shared throughout the application. Create a new one on every request.

dao jpa entitymanager thread-local

2
推荐指数
1
解决办法
4271
查看次数