[英]Resource URIs not working in Java RESTful web service on tomcat 8 server
I created a RESTful web service using auto generated entity classes with netbeans. 我使用带有Netbeans的自动生成的实体类创建了RESTful Web服务。 I also used maven. 我也用过Maven。 I deployed this in tomcat 8 as localhost. 我将它部署在tomcat 8中作为localhost。 I do see the index page, but I cannot access any endpoints. 我确实看到了索引页面,但是无法访问任何端点。 I initially ran this locally on Glassfish server and it worked fine. 最初,我在Glassfish服务器上本地运行此程序,并且运行良好。 I tried test resource uri in netbeans but it says, 我尝试在netbeans中测试资源uri,但是它说,
Unable to open resource URL : localhost:8080//api/activity 无法打开资源URL:localhost:8080 // api / activity
Here is my server.xml file from apache tomcat. 这是我来自apache tomcat的server.xml文件。
<?xml version="1.0" encoding="UTF-8"?>
--><Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener"/>
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log" suffix=".txt"/>
<Context antiJARLocking="true" docBase="C:\xxx\yyyy\apache-tomcat-8.0.36\apache-tomcat-8.0.36\wtpwebapps\xxDBWithMaven" path="/VoyateDBWithMaven" reloadable="true" source="org.eclipse.jst.jee.server:VoyateDBWithMaven"/></Host>
</Engine>
</Service>
</Server>
Is there anyway I can fix this so the resources can be accessed? 无论如何,我可以解决这个问题,以便可以访问资源吗? It's confusing because the application gets deployed and the index file is displayed. 这很混乱,因为已部署了应用程序并显示了索引文件。
Unable to open resource URL : localhost:8080//api/activity 无法打开资源URL:localhost:8080 // api / activity
You have two slashes between "localhost:8080" and "api/activity". 在“ localhost:8080”和“ api / activity”之间有两个斜杠。 Remove one in the configuration where you specify the path: api/activity
instead of /api/activity
. 在您指定路径的配置中删除一个: api/activity
而不是/api/activity
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.