要运行 Spring 应用程序,我应该使用 Tomcat (Servlet 引擎)还是像 Glassfish 这样的应用程序服务器?多谢
我尝试在我的网络项目上使用 REST。POST 有效,但 DELETE 和 PUT 不起作用,我会看到错误:HTTP 状态 405 - 不允许方法。并且 GET 根本不起作用:
“‘id’:RFC 2068 中未定义,且 Servlet API 不支持。描述:服务器不支持满足此请求所需的功能。”
这是我的代码:
package rest;
import domain.model.Client;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.ws.rs.core.GenericEntity;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
@XmlRootElement
@Path("/clients")
@Stateless
public class ClientResources {
@PersistenceContext
EntityManager entityManager;
@GET
@Consumes(MediaType.APPLICATION_JSON)
public Response getAll() {
List<Client> matchHistories = new ArrayList<>();
for (Client m : entityManager
.createNamedQuery("client.all", Client.class)
.getResultList())
matchHistories.add(m);
return Response.ok(new GenericEntity<List<Client>>(matchHistories) {
}).build();
} …Run Code Online (Sandbox Code Playgroud) 我试图制作一个休息应用程序,它会返回一个食谱列表,count 方法有效,但是当我尝试获取其中一个或全部时,它给了我这个错误
javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: java.util.ServiceConfigurationError: javax.json.bind.spi.JsonbProvider: Provider org.eclipse.yasson.JsonBindingProvider not found
Run Code Online (Sandbox Code Playgroud)
我有
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>yasson</artifactId>
<version>1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
在我的 pom.xml
功能看起来像这样
@GET
@Path("/{id : \\d+}")
@Produces(APPLICATION_JSON)
public Response getBook(@PathParam("id") @Min(1) int id) {
Recipe recipe = recipeRepository.findOneByID(id);
if (recipe == null)
return Response.status(Response.Status.NOT_FOUND).build();
return Response.ok(recipe).build();
}
Run Code Online (Sandbox Code Playgroud)
这是通过 ID 返回配方的函数
public Recipe findOneByID(int id) {
return entitymanager.find(Recipe.class, id);
}
Run Code Online (Sandbox Code Playgroud)
并且配方具有以下属性
@Id
private int id;
private String complexity;
private int cookingTime;
private String description;
private int estimatedTime;
private String imageUrl;
private String information;
private …Run Code Online (Sandbox Code Playgroud) GF5 build1,Java EE7 + Primefaces 6.1,尝试在 p:textEditor 组件中上传 ~ 2MB 的照片我总是收到错误:
严重:java.lang.IllegalStateException:GRIZZLY0205:帖子太大
在配置 - 服务器配置 - 网络配置 - 网络侦听器 - http-listener-1 中将“最大帖子大小”设置为 -1 或任何 >1mljn 值没有帮助。GF 4.1 也一样
我花了大部分时间设置 Glassfish 5.0.1 服务器,配置 JDBC 连接池并部署应用程序。我一直遇到的问题:无法从 Glassfish和GlassFish 连接池连接到 JDBC连接池
在 Glassfish for MySQL 中,到处都声明要使用Resource Type: javax.sql.DataSource和Datasource Classname: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
无论我将 MySQL Connector jarglassfish/lib或domain/domain1/bin/lib. 我每次都删除我拥有的池,清除缓存并重新启动服务器。
我最终切换到java.sql.Driver和Driver Classname: com.mysql.jdbc.Driver
问题是如何使数据源工作?
另外,驱动程序和数据源之间有什么区别?
编辑
Payara-5 也有同样的问题。我把罐子放进去,lib/ext但驱动程序以同样的方式失败,并在那里解决了。
MySQLConnPool2 的 Ping 连接池失败。类名错误或类路径未设置为: com.mysql.jdbc.jdbc2.optional.MysqlDataSource 请检查 server.log 以获取更多详细信息。
我在 linux (ubuntu 18.04) 上有一个 glassfish 服务器版本 5.1。我可以毫无问题地启动它,但是在通过以下方式启用安全管理员之后
asadmin --host localhost --port 4848 enable-secure-admin
服务器似乎无法永久启动。我不能stop-domain或restart-domain,虽然start-domain说有一些东西在端口 4848 上运行。所以我必须手动终止该进程。
服务器日志:
[2020-08-01T18:02:53.647+0000] [glassfish 5.1] [SEVERE] [] [] [tid: _ThreadID=58 _ThreadName=Thread-9] [timeMillis: 1596304973647] [levelValue: 1000] [[
java.lang.NoClassDefFoundError: sun/security/ssl/HelloExtension
at sun.security.ssl.SSLExtension.<clinit>(SSLExtension.java:225)
at sun.security.ssl.SSLConfiguration.getEnabledExtensions(SSLConfiguration.java:369)
at sun.security.ssl.ClientHello$ClientHelloKickstartProducer.produce(ClientHello.java:562)
at sun.security.ssl.SSLHandshake.kickstart(SSLHandshake.java:509)
at sun.security.ssl.ClientHandshakeContext.kickstart(ClientHandshakeContext.java:110)
at sun.security.ssl.TransportContext.kickstart(TransportContext.java:234)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:393)
at sun.security.ssl.SSLSocketImpl.ensureNegotiated(SSLSocketImpl.java:727)
at sun.security.ssl.SSLSocketImpl.access$200(SSLSocketImpl.java:74)
at sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1012)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at java.io.DataOutputStream.flush(DataOutputStream.java:123)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:229)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:202)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:342)
at sun.rmi.registry.RegistryImpl_Stub.rebind(RegistryImpl_Stub.java:150)
at com.sun.jndi.rmi.registry.RegistryContext.rebind(RegistryContext.java:175)
at com.sun.jndi.toolkit.url.GenericURLContext.rebind(GenericURLContext.java:251)
at javax.naming.InitialContext.rebind(InitialContext.java:433) …Run Code Online (Sandbox Code Playgroud) 我希望关于标题的问题有意义,如果没有,请说:机器A,通过我登录的Web浏览器admin,我转到机器B,然后登录admin,机器A中的Web浏览器应该强制注销用户admin.我给了这个想法,我认为如果我尝试手动实现它会很难看.我有一种感觉,这可以在Glassfish中完成.
我使用Java EE 6 + Glassfish v3.0.1.身份验证和授权是通过Glassfish中设置的jdbcRealm实现的
好的,所以这是交易:
我试图安装java jdk所以我可以在这台计算机上的eclipse上运行一个android项目,但是有这么多不同的java安装是不可能的,至少对我来说,要弄明白我需要哪一个.所以我选择了"带Java EE的JDK 7u3".但是这也安装了这个GlassFish的东西,我不知道它是什么或它做什么,当我经历所有的日食时我决定让我的另一台电脑工作.所以我删除了eclipsed和所需的东西,我删除了java的东西,但是当我尝试卸载GlassFish时,它不能,并给我错误:
"无法在'(null)'中找到所需的Java(TM)2运行时环境版本."
我现在已经尝试了几个小时,在网上搜索找出一些删除它的方法,安装各种java东西,再次删除它,重新安装,但没有任何作用.我真的不在乎GlassFish是什么或它做什么,我只是想要它,并且所有的java东西都不错.
我怎么能做到这一点?
我正在使用GlassFish服务器的Java项目.项目中没有错误但是当我试图运行它时,它显示此错误_
SEVERE: DPL8015: Invalid Deployment Descriptors in Deployment descriptor file WEB-INF/web.xml in archive [web].
Line 9 Column 22 -- cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element is expected at this point.
SEVERE: DPL8005: Deployment Descriptor parsing failure : cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element is expected at this point.
SEVERE: Exception while deploying the app
java.io.IOException: org.xml.sax.SAXParseException: cvc-complex-type.2.4.d: Invalid content was found starting with element 'description'. No child element …Run Code Online (Sandbox Code Playgroud) 我试图通过ExceptionHandler处理未捕获的异常.遵循JSF2完整参考中的代码,我已经为我的处理程序创建了类.但是当我部署我的应用程序时,它会抛出下一个stackTrace:
SEVERE: Critical error during deployment:
com.sun.faces.config.ConfigurationException: Factory 'javax.faces.context.ExceptionHandlerFactory' was not configured properly.
at com.sun.faces.config.processor.FactoryConfigProcessor.verifyFactoriesExist(FactoryConfigProcessor.java:305)
at com.sun.faces.config.processor.FactoryConfigProcessor.process(FactoryConfigProcessor.java:219)
at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:360)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:225)
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:2019)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669)
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:301)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:461)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at …Run Code Online (Sandbox Code Playgroud)