在tomcat中具有命名参数的IllegalStateException [英] IllegalStateException with naming parameters in tomcat

查看:135
本文介绍了在tomcat中具有命名参数的IllegalStateException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用tomcat和spring很长时间了(一年多了).一切都很好. 今天,突然我在启动tomcat时收到一个奇怪的错误:

I've been using tomcat and spring for a long time (more than a year). Everything worked out great. Today, all of a sudden I get a weird error when starting tomcat:

Caused by: java.lang.IllegalStateException: Using named parameters for method public abstract java.util.List com.securegion.monitorcenter.dao.IncidentsViewRepository.getFixedIncidents(java.lang.String,java.util.List,java.lang.String,java.lang.String,int,int) but parameter 'text' not found in annotated query 'select * from siemincidents where fixed = 1 and descriptioninfo like %?1% and incidentseverity in ?2 and starttimestamp >= ?3 and endtimestamp <= ?4 order by starttimestamp desc limit ?5, ?6'!

我不知道该怎么做,但是没人使用该方法,所以我删除了它.然后我重新启动了tomcat,并得到

I didn't knew what to do, but no one used the method so I deleted it. Then I restarted tomcat, and got

Using named parameters for method public abstract java.util.List com.securegion.monitorce nter.dao.IncidentsViewRepository.getFixedIncidents(int,int) but parameter 'start' not found in annotated query 'select * from siemincidents where fixed = 1 order by starttimestamp desc limit ?1, ?2'!

Using named parameters for method public abstract java.util.List com.securegion.monitorce nter.dao.IncidentsViewRepository.getFixedIncidents(int,int) but parameter 'start' not found in annotated query 'select * from siemincidents where fixed = 1 order by starttimestamp desc limit ?1, ?2'!

同样,我不知道这是什么,所以我完全从eclipse中删除了tomcat服务器,并再次创建了它.这个工作了半个小时,然后我遇到了同样的问题!而且,删除tomcat并没有帮助. 奇怪的是DAO中的服务以"get"而不是"find"开头.我以为可能是tomcat感到困惑,所以我将"get"更改为"fetch".没有帮助.我在这里读到,而不是写?1",我应该写:text".但是明白用?"写工作了一年多,所以我有许多带有?"的参数-烦人的bug太多了(工作了一年多).我已经检查了所有文件,今天没有什么重要的更改,所以我不知道是什么文件引起的.

Again I didn't know what is this, so I deleted the tomcat server entirely from eclipse and created it again. This worked for half an hour, and then I got the same problem! Than, deleting tomcat doesn't help. What is weird is the the service in the DAO starts with "get" and not "find". I thought that maybe tomcat is confused, so I changed "get" to "fetch". Didn't help. I read here that instead of writing "?1" I should write ":text". But understand that writing with "?" worked for over a year, so I have MANY parameters with "?" - too much work for an annoying bug (it worked for over a year). I've checked all my files, and nothing important is changed today, so I don't know what file caused it.

乞讨只是发生在我身上,但现在发生在一位同事身上.我们使用JENKINS部署服务器,并且JENKINS在

At the begging it only happened to me, but now it happens to a colleague. We use JENKINS to deploy our server, and JENKINS crashes in

ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to deploy [/etc/jenkins/jobs/mcg_DeployToDev/workspace/mcg/target/mcg.war]
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:107)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
    at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
    at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
    at hudson.FilePath.act(FilePath.java:989)
    at hudson.FilePath.act(FilePath.java:967)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:721)
    at hudson.model.Build$BuildExecution.post2(Build.java:183)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Deployed application at context path /mcg but context failed to start

    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)
    ... 17 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: FAIL - Deployed application at context path /mcg but context failed to start

    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:566)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:611)
    at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:291)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:102)
    at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:185)
    at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:73)
    at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:116)
    at hudson.plugins.deploy.CargoContainerAdapter$1.invoke(CargoContainerAdapter.java:103)
    at hudson.FilePath.act(FilePath.java:989)
    at hudson.FilePath.act(FilePath.java:967)
    at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:103)
    at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:61)
    at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:761)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:721)
    at hudson.model.Build$BuildExecution.post2(Build.java:183)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:670)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:374)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

如果有关系,我正在使用tomcat 8.

If it matters, I'm using tomcat 8.

我该怎么办?这是一个很大的问题,也许我只是想念一个小毛病……是什么?

What can I do? It is such a huge problem that perhaps I'm just missing a minor glitch... What is it?

推荐答案

更改'?到:param并在方法中的参数之前添加@Param("param").

What fixed it is changing the '?' to :param and adding @Param("param") before the parameter in the method.

表示选择方法:

@Query(value = "SELECT * FROM agents limit ?1, ?2", nativeQuery = true)
public List<AgentEntity> getAll(int start, int length);

已更改为

@Query(value = "SELECT * FROM agents limit :start, :length", nativeQuery = true)
public List<AgentEntity> getAll(@Param("start") int start, @Param("length") int length);

那解决了这个问题.

这篇关于在tomcat中具有命名参数的IllegalStateException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆