关于这个问题似乎有几个话题,但是找不到答案。我对JSF不太熟悉,并且想使用以下方法创建一个postgresql连接池:
但是tomcat总是给我一个HTTP Status 500-实例化servlet类错误的错误(帖子末尾的堆栈跟踪)您能帮我吗?
我的文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>Postgresql</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
<resource-ref>
<description>Postgres Test</description>
<res-ref-name>jdbc/einfuehrungsaufgabe</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Run Code Online (Sandbox Code Playgroud)
<context>
<Resource name="jdbc/einfuehrungsaufgabe" auth="Container"
type="javax.sql.Datasource" maxActive="20" maxIdle="5" maxWait="10000"
username="foo" password="foo" driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://foo.de/foo">
</Resource>
</context> …
Run Code Online (Sandbox Code Playgroud) 我想在我的网络应用程序中每五秒发布一条消息,我正在使用 Quatz 来安排这个任务。这是我的代码
public class InvoiceGenerationSchedular implements ServletContextListener {
@Override
public void contextDestroyed(ServletContextEvent arg0) {
System.out.println("Listener is off");
}
@Override
public void contextInitialized(ServletContextEvent servletContextEvent) {
System.out.println("Listener initialized.");
JobDetail job = JobBuilder.newJob(HelloJob.class)
.withIdentity("dummyJobName", "group1").build();
Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity("dummyTriggerName", "group1")
.withSchedule(
CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).build();
//schedule it
Scheduler scheduler;
try {
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
} catch (SchedulerException e) {
e.printStackTrace();
}
}
class HelloJob implements Job
{
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException …
Run Code Online (Sandbox Code Playgroud) 假设我有一个Web服务/一个使用某些HTTP标头参数调用的REST资源。resource方法构建一个复杂的数据对象(当前为POJO),并最终将其返回给客户端(通过Gson作为JSON,但这无关紧要)。
所以我有这个调用层次结构:
@Path(foo) ProjectResource @GET getProject()
-> new Project()
-> new List<Participant> which contains lots of new Participant()s
-> new Affiliation()
Run Code Online (Sandbox Code Playgroud)
如果我想Affiliation
根据标题参数以英语或德语填充对象,则必须将其作为参数传递给链下。我想避免这样做。也许这从根本上讲是不可能的,但是感觉太不对了。所有这些对象仅存在于请求中,因此能够从任何地方访问与请求相关的信息是否方便?
我希望我可以例如定义一个CDI @RequestScoped
对象,该对象会初始化自身(或由某些WebFilter填充),然后可以在可能需要的位置注入。
但是显然,这在POJO内部是行不通的,而且我也很难从请求范围的对象内部获取标头。
我已经阅读了许多关于EJB,JAX-RS上下文和CDI的SO问题/答案,但是我无法解决。
我期望太多了吗?传递参数确实是首选选项吗?
添加安全性问题,以便用户在超过最大尝试次数时可以重置密码。对身份验证机制执行诸如此类的隐藏字段是否不好?
<input type="hidden" name="securityAnswered" value=true>
<input type="hidden" name="exceededAttempts" value=true>
Run Code Online (Sandbox Code Playgroud)
用户可以从客户端进入并编辑这些隐藏字段吗?
我有以下代码行初始化Stanford词法分析器。
lp = LexicalizedParser.loadModel("edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz");
Run Code Online (Sandbox Code Playgroud)
仅当我将代码从Java SE应用程序移动到Java EE应用程序时,我才会遇到异常。
Caused by: java.lang.NoSuchMethodError: edu.stanford.nlp.util.Generics.newHashMap()Ljava/util/Map;
at edu.stanford.nlp.parser.lexparser.BinaryGrammar.init(BinaryGrammar.java:223)
at edu.stanford.nlp.parser.lexparser.BinaryGrammar.readObject(BinaryGrammar.java:211)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
Run Code Online (Sandbox Code Playgroud)
这是怎么引起的,我该如何解决?
我看到很多教程,有些人使用maven dependency
这样的方式
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
有些人用maven dependency
这样的方式
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.3.RELEASE</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
maven <version>${spring.version}</version>
和<version>4.3.3.RELEASE</version>
maven 之间的主要区别是什么?
我正在处理一个 spring 项目,我想向我的视图添加一些 css,但是 css 文件(在 webapp 文件夹中)创建为 Java 源文件:所以没有自动完成,它无法识别为 css 文件。
这是 css 文件的显示方式:
我正在尝试在JSP中将列表的内容打印为单个字符串,并用逗号分隔。
<div>${myList.stream().map(e->e.getStringValue()).collect(Collectors.joining(", "))}</div>
Run Code Online (Sandbox Code Playgroud)
我收到错误:
javax.el.MethodNotFoundException: Method not found: class org.apache.el.stream.Stream.collect(null)
Run Code Online (Sandbox Code Playgroud)
为什么Tomcat使用它自己的版本Stream
?有没有一种方法可以避免这种情况,并确保当我将它们放在JSP的EL中时,我在java类中编写的内容具有相同的行为?
我找到了这个答案/sf/answers/3005143991/ 但这不能解决我的问题。它使用Tomcat Streams的自定义方法。
我试图从这样的资源中获取图像:
<img src="#{resource['img/bla.svg']}"/>
Run Code Online (Sandbox Code Playgroud)
像这样工作
但是现在我想对此文件进行一般化,因此它将来自这样的java类:
LogoHandler.getLogo(String type)
Run Code Online (Sandbox Code Playgroud)
我试图像这样将它们放在一起:
<img src="#{resource["#{logoHandler.getLogo("A1")}"]}"/>
Run Code Online (Sandbox Code Playgroud)
但是它当然不起作用,只是为了向您展示我想要达到的目标。
你能帮我吗?
在特殊情况下,从部署在 Apache TomEE 中的应用程序调用我的无状态 EJB 类之一可能需要很长时间,并且事务会被服务器回滚。
如何增加 Apache TomEE 中的 EJB 事务超时?
谢谢你。
java ×3
el ×2
spring ×2
tomcat ×2
apache-tomee ×1
cdi ×1
css ×1
eclipse ×1
ejb ×1
exception ×1
hibernate ×1
hidden-field ×1
html ×1
jakarta-ee ×1
java-ee ×1
java-stream ×1
jax-rs ×1
jndi ×1
jsf ×1
maven ×1
resources ×1
security ×1
servlets ×1
spring-mvc ×1
stanford-nlp ×1
transactions ×1