微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何列出 Wildfly 部署的 http servlet

如何解决如何列出 Wildfly 部署的 http servlet

如何列出wildfly(版本16)部署的http servlets?来自 Web 控制台端口 8080 还是 cli? 我已经部署了一个工作示例:

2021-04-07 19:10:28,579 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "h2-console.war" (runtime-name: "h2-console.war")
2021-04-07 19:10:28,719 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 124) WFLYUT0021: Registered web context: '/h2-console' for server 'default-server'

这有效:http://172.21.93.102:8080/h2-console/console/login.jsp?jsessionid=bf0d51b655f42eb956ba4f2bf98a1de9

是否可以列出已部署的 http servlet,类似于已部署的 EJB 列表? 是否必须部署 EJB,而可以说 http servlet 在 web.xml 中的“load-on-startup”中在启动时关闭

<servlet>
    <servlet-name>H2Console</servlet-name>
    <servlet-class>org.h2.server.web.WebServlet</servlet-class>
    
    <init-param>
        <param-name>webAllowOthers</param-name>
        <param-value></param-value>
    </init-param>
    <init-param>
        <param-name>trace</param-name>
        <param-value></param-value>
    </init-param>
    
    <load-on-startup>1</load-on-startup>
</servlet>

在 Web 控制台的配置/运行时选项卡中,有一些用于“undertow”http 服务器会话的内容,但我找不到 servlet 列表

配置选项卡:

configuration

运行时选项卡:

runtime

已部署的 EJB 列表(它另外显示了哪个 jar/war):

enter image description here

更新:

运行时 -> 服务器 -> Web -> 部署 -> 部署 -> 视图确实显示了已部署的 servlet,如正确答案所示,除此之外,我需要从 servlet 调用 EJB 3.0 bean,但我有这个错误

javax.naming.NameNotFoundException: mfproLoginBean/remote -- 服务 jboss.naming.context.java.mfproLoginBean.remote

这个 EJB 列在 wildfly 16 的 web 控制台中,并且可以通过 wget 获取:http://wildfly:8080//TServerXmlRpc/login/PreLoginServlet

EJB(似乎是 EJB 3.0?):

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.noresultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.jboss.annotation.ejb.Clustered;
import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.RemoteBindings;

@Clustered
@Stateless
@RemoteBindings({
        @RemoteBinding(jndiBinding = "mfproLoginBean/remote"),@RemoteBinding(jndiBinding = "mfproLoginBean/httpremote",clientBindUrl = "servlet://${tserver.ejb3.client.address}${tserver.ejb3.client.port}${tserver.ejb3.client.url}",factory = it.company.tserver.ejb3.StatelessClusterProxyFactory.class) })
public class mfproLoginBean implements mfproLogin,mfproLoginLocal {

在 servlet 中失败的调用

公共类 LoginServlet 扩展了 HttpServlet {

private void process(HttpServletRequest request,HttpServletResponse response) throws servletexception,IOException {

javax.naming.Context ctx = InitialContextFactory.create(); mfproLogin loginBean = (mfproLogin) ctx.lookup("mfproLoginBean/remote");

TUserSession userSession = loginBean.loginUser(authReq,new TInfoRequest(launcherVersion,descriptorVersion,environmentPath));

这些变量是在 wildfly 启动脚本中设置的:

JBoss Bootstrap 环境

JBOSS_HOME:/opt/wildfly

Java:/usr/bin/java

JAVA_OPTS: -server -xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n -Dtserver.ejb3.client.address=jbosscollaudomfpro.classlocale.it -Dtserver.ejb3.client.port=:8080 -Dtserver.ejb3.client.url=//unified-invoker/Ejb3ServerInvokerServlet?return-exception=true
-Dtserver.http.client.address=jbosscollaudomfpro.classlocale.it -Dtserver.http.client.port=8080 -Dtserver.jms.http.client.url=/jmsmessaging/connector
-Dorg.jboss.logging.Log4jService.catchSystemOut=false -Dlogmanager.log4jimpl.properties=tserver-log4j.properties -DpropsDomain=

自 AS 7 起不再使用“unified-invoker.sar”?

这似乎替代了java变量? :

package it.company.tserver.ejb3;

import org.jboss.annotation.ejb.RemoteBinding;
import org.jboss.annotation.ejb.RemoteBindingImpl;

public class StatelessClusterProxyFactory extends org.jboss.ejb3.stateless.StatelessClusterProxyFactory 
{
    @Override
    public void setRemoteBinding(RemoteBinding binding) {
        String uri = binding.clientBindUrl();
        if (uri!=null && uri.indexOf("${")>=0) {
            uri = ReplacePropertiesUtil.replace(uri);
            RemoteBindingImpl b = new RemoteBindingImpl(binding.jndiBinding(),binding.interceptorStack(),uri,binding.factory());
            super.setRemoteBinding(b);
        }
        else
            super.setRemoteBinding(binding);
    }
}

解决方法

在 Web 控制台中,转到运行时 -> 服务器 -> Web -> 部署,然后选择所需的部署并单击“查看”。从那里您可以看到左侧 Servlet 选项卡中的 servlet。

在 CLI 中,您可以执行如下所示的操作来列出名称。

/deployment=YOUR.war/subsystem=undertow:read-children-names(child-type=servlet)

或类似以下内容以列出更多详细信息:

/deployment=helloworld-html5.war/subsystem=undertow:read-children-resources(child-type=servlet,include-runtime=true)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。