在使用 Atmosphere servlet 的测试 WebSocket 应用程序中,我收到以下异常:
SEVERE: Servlet.service() for servlet AtmosphereServlet threw exception
java.lang.ClassNotFoundException: javax.servlet.AsyncContext
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
at org.atmosphere.cpr.AtmosphereServlet.doPost(AtmosphereServlet.java:191)
at org.atmosphere.cpr.AtmosphereServlet.doGet(AtmosphereServlet.java:177)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
Run Code Online (Sandbox Code Playgroud)
从下面的帖子中我了解到这可能是由 Servlet 容器版本早于 Servlet 3.0 引起的:
ClassNotFoundException:Jetty hello world 中的 javax.servlet.AsyncContext
ClassNotFoundException:eclipse 中 Jetty hello world 中的 javax.servlet.AsyncContext
Grails 项目 - Servlet 调用 - ClassNotFoundException:javax.servlet.AsyncContext
然而应用程序运行在Tomcat7上,并且在pom.xml中添加了以下依赖项:
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
我检查了项目中的所有其他依赖项,但无法找到与 Servlet 相关的任何其他内容。我仍然遇到例外。
问题:如何找到应用程序实际使用的jar文件?如何找到导致使用旧版本的依赖关系?
我有一个实体类,它从四级继承继承,其中顶级父级定义主键(@Id),当我收到此错误时,我无法弄清楚我做错了什么:
实体类 [D 类] 没有指定主键。它应该定义 @Id、@EmbeddedId 或 @IdClass。如果您使用任何这些注释定义了 PK,请确保您的实体类层次结构中没有混合访问类型(注释的字段和属性)。
这是层次结构:
A->B->C->(实体)D
这是我的非实体类,它将值赋予其子级:
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@MappedSuperclass
public class A implements Serializable {
@Id
@GeneratedValue
protected Long id;
@Temporal(javax.persistence.TemporalType.TIMESTAMP)
protected Date deleted;
public Date getDeleted() {
return deleted;
}
public void setDeleted(Date deleted) {
this.deleted = deleted;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
这是它的孩子之一:
@MappedSuperclass
public abstract class B extends A implements Serializable {
}
B->C …
Run Code Online (Sandbox Code Playgroud) Kotlin编译器插入@Nullable
and @NotNull
from org.jetbrains.annotations
,是否也可以插入javax.validation.constraints.NotNull
?
请不要将其视为重复请求,因为我已经浏览了 stackoverflow 中的所有帖子,但没有人回答。我没有找到任何回应。
问题是:
我面临一个非常奇怪的问题,通过独立应用程序(在 main() 内)使用相同的代码段发出 GET 请求。它的工作原理就像将相同的代码放在 Java EE 应用程序中并部署在 Wildfly 10 服务器上一样,它会给出错误
“无法找到内容类型为 text/html 且类型为接口 java.util.List 的 MessageBodyReader”
代码:
ClientConfig configuration = new ClientConfig();
configuration.property(ClientProperties.CONNECT_TIMEOUT, 10000);
configuration.property(ClientProperties.READ_TIMEOUT, 10000);
Client iexRestClient=ClientBuilder.newClient(configuration);
WebTarget webTarget =
iexRestClient.target("https://api.iextrading.com/1.0/ref-data/symbols/");
Response response =
webTarget.request().accept(MediaType.APPLICATION_JSON).get(Response.class);
System.out.println("response status "+response.getStatus());
List<IEXTicker> tickers = response.readEntity(new
GenericType<List<IEXTicker>>(){});
System.out.println("size of tickers "+tickers.size());
Run Code Online (Sandbox Code Playgroud)
所需的 jars(pom.xml 文件)
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>2.26</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.26</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
模型类:IEX_Ticker.java
@Entity
@Table(name = "IEX_Ticker")
@JsonIgnoreProperties(ignoreUnknown = true)
public …
Run Code Online (Sandbox Code Playgroud) 我需要验证POJO中的字段,该字段必须为min length = 2,忽略开头和结尾的空格
class User {
@NotBlank
@Size(min = 2)
private String name;
}
Run Code Online (Sandbox Code Playgroud)
它不适用于“ A”
应该如何?
是否有任何其他工作来解决javax.inject,version=[0.0,1) -- Cannot be resolved
OSGI包中的问题
我已经尝试了下面论坛中提供的所有方法.但我的捆绑仍未解决.
我使用的是AEM 6.2 + Java版本:1.8.0_121 + Apache Maven 3.3.9和archetypeVersion = 10
我的代码可以在我的GDrive中找到
我有我的自定义validator
,我想为它添加一些错误消息.所以我有下一个代码:
@Override
public boolean isValid(final String label,
final ConstraintValidatorContext constraintValidatorContext) {
constraintValidatorContext.disableDefaultConstraintViolation();
if(label.length() > MAX_LENGTH) {
constraintValidatorContext
.buildConstraintViolationWithTemplate("{error.maxLength}")
.addConstraintViolation();
return false;
}
...
}
Run Code Online (Sandbox Code Playgroud)
我的消息看起来像error.maxLength=You have exceeded max length of {0}
,所以它有参数maxLength
.
在构建约束违规时可以添加它吗?
将org.apache.poi poi-ooxml依赖项添加到我的项目后,我现在收到以下错误:
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI无法解析或不是字段
当我尝试查看源代码时,不再有代码,eclipse正在寻找源代码:.m2/repository/stax/stax-api/1.0.1/stax-api-1.0.1-sources.jar