Glassfish: java.net.BindException: No free port within range - glassfish-3

Good evening, i'm facing a weird problem in glassfish 3.1.2, whenever i run my application(it doesn't run) and i looked at eclipse console, i found these strange exception:
SEVERE: doSelect IOException java.net.BindException: No free port within range: 8181=com.sun.enterprise.v3.services.impl.monitor.MonitorableSSLSelectorHandler#188fcca7
at com.sun.grizzly.TCPSelectorHandler.initSelector(TCPSelectorHandler.java:432)
at com.sun.grizzly.TCPSelectorHandler.preSelect(TCPSelectorHandler.java:378)
at com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:188)
at com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:132)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
SEVERE: doSelect IOExceptionjava.net.BindException: No free port within range: 3700=com.sun.enterprise.v3.services.impl.ServiceInitializerHandler#1b42f99d
at com.sun.grizzly.TCPSelectorHandler.initSelector(TCPSelectorHandler.java:432)
at com.sun.grizzly.TCPSelectorHandler.preSelect(TCPSelectorHandler.java:378)
at com.sun.grizzly.SelectorHandlerRunner.doSelect(SelectorHandlerRunner.java:188)
at com.sun.grizzly.SelectorHandlerRunner.run(SelectorHandlerRunner.java:132)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
i changed some configuration in domain.xml inside glassfish\domains\domain1\config i increased the following 2 elements but nothing changed
<jvm-options>-XX:MaxPermSize=512m</jvm-options>
<jvm-options>-XX:PermSize=512m</jvm-options>
could anyone help me.
Note: i killed java.exe from process list as sehrope suggests and the exception resolved but the server redirects me to the HTTP Status 404 page, the requested resource is not available(), for more clarity, here's my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Gambak</display-name>
<welcome-file-list>
<welcome-file>login.jsf</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
and the file login.xhtml is located under WebContent

You probably have an existing server running on that port. Check your process list ot see if anything is running in the background and listening on those ports.
$ sudo netstat -lpn | grep 8181
If there is something running the kill the process and try restarting your server.

I had this issue and in the domain.xml was a wrong IP configured as address attribute in the <network-listener tag...

Related

'No suitable driver' exception implementing Olap4J XMLA Server

I'm trying to implement olap4j-xmlaserver to access Mondrian via HTTP/XMLA. I compiled the project, created a war file (including a web.xml file) and deployed it in Tomcat 7. Problem is that I'm getting an exception when the pivot client application sends an XMLA request:
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=xxx;Catalog=/WEB-INF/FoodMart.xml'
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
at mondrian.xmla.impl.Olap4jXmlaServlet$Olap4jPoolingConnectionFactory.getConnection(Olap4jXmlaServlet.java:300)
at mondrian.xmla.XmlaHandler.getConnection(XmlaHandler.java:2917)
... 33 more
Caused by: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getDriver (DriverManager.java:315)
at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
... 37 more
The web.xml I put together (I couldn't find a sample in the olap4j-xmlaserver project). I'm sure this web.xml file needs to be fixed to solve the problem, especially the connection string:
<web-app ....
<display-name>olap4j-xmlaserver</display-name>
<description>
Olap4J XML/A server
</description>
<servlet>
<servlet-name>xmla</servlet-name>
<servlet-class>mondrian.xmla.impl.Olap4jXmlaServlet</servlet-class>
<init-param>
<param-name>OlapDriverClassName</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</init-param>
<init-param>
<param-name>OlapDriverConnectionString</param-name>
<param-value>
jdbc:mondrian:Jdbc=jdbc:mysql://localhost:3306/foodmart?user=root&password=xxx;Catalog=/WEB-INF/FoodMart.xml
</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>xmla</servlet-name>
<url-pattern>/xmla</url-pattern>
</servlet-mapping>
</web-app>
Any ideas how to fix the web.xml configuration or pointers to relevant documentation will be greatly appreciated.
You are missing the Java driver for MySQL in your classpath. Add it to your webapp in the folder named 'WEB-INF/lib'.

Web.xml servlet-class references to non-existent class "ClassName"

I am working on a project and hit a brick wall. I couldn't find any resources or bug reports to solve this issue. I have a maven project setup as maven-archetype-webapp. I am new to JEE and it took me sometime to get this far but I have a better understanding of how some of this works. I have hit a brick wall and don't know how to solve the problem below.
I get the following warnings within the web.xml file
servlet-class references to non-existent class "servlets.RegisterServlet"
servlet-class references to non-existent class "servlets.HomePageServlet"
file name references to "index" that does not exist in web content
I get the following error in WildFly 10.x.
Caused by: java.lang.ClassNotFoundException: servlets.RegisterServlet from [Module "deployment.PracticeProject.war:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService.createServletConfig(UndertowDeploymentInfoService.java:723)
... 6 more
The java classes appear in the directory structure of the war so its packaging it correctly. For the entities, session beans and servlets I have a scope of provided for the dependencies of the pom.xml file.
My directory structure is as follows:
My web.xml file:
<?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_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>PracticeProject</display-name>
<servlet>
<servlet-name>RegisterServlet</servlet-name>
<servlet-class>servlets.RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/register</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>HomePageServlet</servlet-name>
<servlet-class>servlets.HomePageServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HomePageServlet</servlet-name>
<url-pattern></url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index</welcome-file>
</welcome-file-list>
</web-app>
edit:
CHKJ3013E: The URL Mapping "" is invalid. web.xml /PracticeProject/src/main/webapp/WEB-INF org.eclipse.jst.j2ee.webapplication.internal.impl.ServletMappingImpl#53667dce (urlPattern: , name: null) Validation Message

getting SERVICE_UNAVAILABLE Google Web Toolkit

When I run the project I see in my browser a page with "HTTP ERROR: 503 / Problem accessing /EmployeeTracker.html. Reason: SERVICE_UNAVAILABLE"
HTTP ERROR: 503
Problem accessing /EmployeeTracker.html. Reason:
Service Unavailable
Powered by Jetty://
Below is my web.xml file :
<?xml version="1.0" encoding="UTF-8"?>
<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_2_5.xsd"
version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee">
<!-- Servlets -->
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>EmployeeTracker.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>JsonStockData</servlet-name>
<servlet-class>com.teamcenter.awc.employee.server.JsonStockData</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name></servlet-name>
<url-pattern>/employeetracker/stockPrices</url-pattern>
</servlet-mapping>
</web-app>
Below is the stack trace:
[WARN] Server class 'org.eclipse.jetty.servlet.listener.ELContextCleaner' could not be found in the web app, but was found on the system classpath
[WARN] Adding classpath entry 'file:/F:/workdir/eclipse-SDK-4.4.1-win32-x86_64/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/gwt-dev.jar' to the web app classpath for this session
For additional info see: file:/F:/workdir/eclipse-SDK-4.4.1-win32-x86_64/plugins/com.google.gwt.eclipse.sdkbundle_2.6.0/gwt-2.6.0/doc/helpInfo/webAppClassPath.html
Starting Jetty on port 0
[WARN] Failed startup of context c.g.g.d.s.j.WebAppContextWithReload{/,file:/D:/workdir/devunits/AWS/aw2.4.latest/eclipse/EmployeeTracker/war/},D:\workdir\devunits\AWS\aw2.4.latest\eclipse\EmployeeTracker\war
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:85)
at org.eclipse.jetty.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:72)
at org.eclipse.jetty.webapp.MetaData.resolve(MetaData.java:367)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1240)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:717)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:494)
at com.google.gwt.dev.shell.jetty.JettyLauncher$WebAppContextWithReload.doStart(JettyLauncher.java:518)`enter code here`
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.handler.RequestLogHandler.doStart(RequestLogHandler.java:162)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95)
at org.eclipse.jetty.server.Server.doStart(Server.java:282)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.google.gwt.dev.shell.jetty.JettyLauncher.start(JettyLauncher.java:717)
at com.google.gwt.dev.DevMode.doStartUpServer(DevMode.java:522)
at com.google.gwt.dev.DevModeBase.startUp(DevModeBase.java:1104)
at com.google.gwt.dev.DevModeBase.run(DevModeBase.java:844)
at com.google.gwt.dev.DevMode.main(DevMode.java:322)
Caused by: java.lang.IllegalStateException: No such servlet:
at org.eclipse.jetty.servlet.ServletHandler.updateMappings(ServletHandler.java:1320)
at org.eclipse.jetty.servlet.ServletHandler.setServletMappings(ServletHandler.java:1414)
at org.eclipse.jetty.servlet.ServletHandler.addServletMapping(ServletHandler.java:896)
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.addServletMapping(StandardDescriptorProcessor.java:1199)
at org.eclipse.jetty.webapp.StandardDescriptorProcessor.visitServletMapping(StandardDescriptorProcessor.java:632)
... 23 more
Have you got any clue how to solve it?
the servlet-name of your servlet-mapping is empty. try this :
<servlet-mapping>
<servlet-name>JsonStockData</servlet-name>
<url-pattern>/employeetracker/stockPrices</url-pattern>
</servlet-mapping>

Failed to load resource files when mapping Servlet on URL pattern of /

I use NetBeans and Tomcat 7.0.4.2 and would like to change URL address of my project from localhost:8080/Servlet to localhost:8080/. In web.xml I changed servlet URL address from <url-pattern>/Servlet</url-pattern> to <url-pattern>/</url-pattern>.
The problem is I can't load resource files now and get errors in browser console log:
Failed to load resource: the server responded with a status of 404 (Not Found) (11:45:14:149 | error, network)
at src/main/webapp/scripts/aui-min_2.0.0.js
The path to resource files is src/main/webapp/scripts and in JSP file I use this path
<script type="text/javascript" src="scripts/aui-min_2.0.0.js"></script>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<servlet>
<servlet-name>Servlet</servlet-name>
<servlet-class>socialgraphui.Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
The url pattern / is is used by default servlet which is capable of loading static resources that isn't mapped by other servlets. When you switched to this pattern it's stopped working. So, you should keep a servlet mapping.
<servlet-mapping>
<servlet-name>Servlet</servlet-name>
<url-pattern>/Servlet</url-pattern>
</servlet-mapping>
If you want to start from the index page use a index.jsp that is listed in <welcome-file-list> configuration. The index page can redirect to the servlet using
response.sendRedirect(request.getContextPath() +"/Servlet");
To load static resource use servlet context path like that
<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/aui-min_2.0.0.js"></script>

JSP Site web.xml issue Page not found for url-pattern /MyController in sevlet-mapping

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
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_2_5.xsd">
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>MyController</servlet-name>
<servlet-class>com.pk.MyController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyController</servlet-name>
<url-pattern>/MyController</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
I have this configuration, but unable to access hzhfyp.com/MyController (PAGE NOT FOUND)
The Path for MyController servelet is WEB-INF/classes/com/pk/MyController.class
Although index.jsp is loaded accuratelty. Demo here http://hzhfyp.com/ Clicking any button will generate js error visible in Firebug(firefox) as Page not Found.
URLs are case sensitive. You've mapped it on /MyController with M, but your jQuery code is calling it by /myController with m. Fix it accordingly.
As to the servlet returing a 404 in spite of the correct URL, this can happen when the servlet failed to initialize or when you didn't deploy the correct web.xml at all. Read the server startup logs for any errors during servlet initialization and verify if you're deploying with the right web.xml.

Resources