简体   繁体   English

URL 路径在 WebLogic 服务器中部署时不起作用

[英]URL path not working in when deployed in WebLogic server

type here在此输入

I am trying to build REST API, I have created the web application project using maven and included jersey dependencies in pom.xml file.我正在尝试构建 REST API,我使用 maven 创建了 web 应用程序项目,并在 pom.xml 文件中包含 jersey 依赖项。 Also I have included web.xml file and weblogic.xml file in web-inf folder.我还在 web-inf 文件夹中包含了 web.xml 文件和 weblogic.xml 文件。 when deployed and execute the URL path index.jsp is working fine.当部署并执行 URL 路径 index.jsp 工作正常。 but other URL is not working it show the Not found.但其他 URL 不工作,它显示未找到。 Unable to find what is wrong.找不到问题所在。

Web.xml file Web.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>Rest service</display-name>
  <servlet>
        <servlet-name>Jersey Web Application</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>jersey.config.server.provider.packages</param-name>
            <param-value>com.vno.testaddress</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey Web Application</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>
</web-app>

weblogic.xml weblogic.xml

    <?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
    xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
    <wls:weblogic-version>14.1.1.0</wls:weblogic-version>
    <wls:context-root>/address</wls:context-root>
    <wls:container-descriptor>
        <prefer-web-inf-classes>false</prefer-web-inf-classes>
        <wls:prefer-application-packages>
            <wls:package-name>org.slf4j.*</wls:package-name>

            <wls:package-name>org.glassfish.jersey.*</wls:package-name>
            <wls:package-name>io.swagger.core.*</wls:package-name>
            <wls:package-name>io.swagger.parser.*</wls:package-name>
        </wls:prefer-application-packages>
    </wls:container-descriptor>
</wls:weblogic-web-app>

Java code: Java 代码:

    import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

/**
 * Hello world!
 *
 */
@Path("myresource")
public class Testaddress 
{
     @GET
        @Produces(MediaType.TEXT_PLAIN)
        public String getIt() {
            return "Hello world!";
        }
}

Error:错误:

I am trying to use this url: http://192.168.77.10:7001/testaddress-0.0.1-SNAPSHOT/webapi/myresource and expecting the result as "Hello World."我正在尝试使用此 url: http://192.168.77.10:7001/testaddress-0.0.1-SNAPSHOT/webapi/myresource并期望结果为“Hello World”。 but it shows not found.但是显示没有找到。 在此处输入图像描述

I see 2 potential issues:我看到 2 个潜在问题:

  1. Your class TestAddress has no package defined.您的 class TestAddress 没有定义 package。 If it's defined (but not displayed here), I think it should be "com.vno.testaddress" to comply with the init-param> defined for your ServletContainer in web.xml如果它被定义了(但这里没有显示),我认为它应该是“com.vno.testaddress”以符合 web.xml 中为您的 ServletContainer 定义的 init-param>
  2. The value defined for your "wls:context-root" parameter is "/address".为“wls:context-root”参数定义的值是“/address”。 So, to access your class and make it work, I think your URL should be "http://192.168.77.10:7001/address/webapi/myresource "因此,要访问您的 class 并使其正常工作,我认为您的 URL 应该是“http://192.168.77.10:7001/address/webapi/myresource”

Let me know让我知道

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么Spring Security在Tomcat中可以工作,而在部署到Weblogic时却不能工作? - Why is Spring Security working in Tomcat but not when deployed to Weblogic? 在Weblogic Server中查看已部署的应用程序 - Viewing Deployed Apps in Weblogic Server Weblogic 服务器中的应用程序路径 - Application path in Weblogic server 使用部署在oracle weblogic服务器上的Java代码,数据泵目录中的chmod命令第二次不起作用 - chmod command in data pump directory not working second time using Java code deployed on oracle weblogic server 获取部署在 weblogic 服务器上的所有应用程序的列表 - Get list of all applications deployed on a weblogic server GET在Weblogic Server中不起作用 - GET not working in Weblogic Server JOptionPane.showMessageDialog(null,ExNull)部署到Weblogic服务器时不显示 - JOptionPane.showMessageDialog(null,ExNull) doesn't show when deployed to Weblogic server 在 Weblogic 服务器中部署时,未加载新字体以使用动态报告生成 pdf - New fonts are not getting loaded for generating pdf using Dynamic Reports when deployed in Weblogic server 应用程序在开发服务器上运行,而在GAE上部署后则无法运行 - App working on the Dev server, not working when deployed on GAE 如何定义在Weblogic中部署为Ear的上下文URL Rest Web服务 - How to define context url rest web service deployed as ear in weblogic
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM