如何列出wildfly部署的http servlet

问题描述 投票:0回答:1

如何从 Web 控制台端口 8080 或 CLI 列出 Wildfly(版本 16)部署的 http servlet? 我已经部署了一个工作示例:

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 列表

配置选项卡:

运行时选项卡:

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

更新:

Runtime -> Server -> Web -> Deployment -> deployment -> view
确实显示了已部署的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 中失败的调用:

public class LoginServlet extends 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 Environment

  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);
    }
}
servlets jboss ejb wildfly ejb-3.0
1个回答
2
投票

在 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)
© www.soinside.com 2019 - 2024. All rights reserved.