Can't access Intellij auto created RestFul web service server - java

After creating RestFul Web service (let's say helloworld) using Intellij Idea, When I run the server, it runs correctly(it says Server is running). But when I try to access it using my web browser, it says "the web page you are requested is not available".
What is wrong with my web service.?
I just created a basic project.
output -
com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class example.HelloWorld
Dec 26, 2013 3:16:09 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Dec 26, 2013 3:16:09 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.3 06/17/2010 05:04 PM'
Server running
Visit: http ://localhost:9998/helloworld
Hit return to stop...

In your helloworld class,there may be a line like following
HttpServer server = HttpServerFactory.create("http://localhost:9998/");
change the port number to 8080 and try to run again

Related

War deployment in Embedded Tomcat

I have an embedded tomcat (7.0.64) on MAC and am deploying a war file, running on java 1.7.067. For some reason my tomcat server hangs on the call "Tomcat.start()".
I know for sure that it's getting stuck deploying the war file. The way i figured this i plugged in a different war file(a simple hello world) and that worked.
I tried hooking up tomcat log.properties and got the logs directed to file with hope of getting any clues. But i don't see any exception, the logging stops at these lines,
FINE: Loading class from parent
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: Loading class from parent
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl, false)
Nov 16, 2015 9:30:01 PM org.apache.catalina.loader.WebappClassLoader loadClass
FINE: loadClass(com.sun.org.apache.xerces.internal.impl.dv.dtd.DTDDVFactoryImpl, false)
Not sure if it can't find "DTDDVFactoryImpl", since this is part of the jdk libraries itself as well as i am including xercesimpl.jar as well.
Basically i am looking for ways that can help me figure out, what or which class is blocking from the web deployment from happening.
Any ideas/pointers?
TIA
Updated - My log.properties looks like,
handlers=java.util.logging.ConsoleHandler, org.apache.juli.FileHandler
org.apache.juli.FileHandler.level=ALL
org.apache.juli.FileHandler.directory=./logs
org.apache.juli.FileHandler.prefix=tomcat-
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
org.apache.catalina.level=FINEST
org.apache.catalina.handlers=org.apache.juli.FileHandler
the line -
FINE: loadClass(com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl, false)
The above message means that a web application have already been
stopped, but the TimerTask tries to load a class from it.
What web application has started this timer?
If the timer was started by this web application, then it is your
fault. You should have configured a
javax.servlet.ServletContextListener to stop (cancel) the timer when
the web application stops. You cannot load classes when web
application have already been stopped.
OR
If the timer was started by a different web application, it means
that you have PermGen memory leak somewhere. Ensure that you have
JreMemoryLeakPreventionListener configured in server.xml.
It is known that there was a PermGen memory leak in Java XML APIs. A
workaround to suppress it was added to JreMemoryLeakPreventionListener
in r884341 [1]
Mark has a presentation on Memory Leaks
http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf
OR
Bundling a separate copy of Apache Xerces with the web application
may help. It will not help if the root cause is your failure to cancel
the timer.
[1] http://svn.apache.org/viewvc?view=revision&revision=r884341
hope this helps.

Issue with deploying application using tomcat7

I am trying to deploy an application using spring in tomcat7 running on ubuntu12. When I drop the war file in the webapps directory, the directory is created for the application inside webapps - yet the application does not load up. Latest issue is copied below. Any thoughts on troubleshooting this will be appreciated.
Java versions are the same on the computers where the war file was generated vs the one where I am deploying the application. I do not see a file permission issue - there is a logging.properties file in tomcat7.
Jan 31, 2014 10:43:05 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 31, 2014 10:43:05 AM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/test-webapp] startup failed due to previous errors
Jan 31, 2014 10:43:05 AM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/test-webapp] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
Update:
I missed an error message. I will update this ticket shortly.
Update:
I was missing a file in tomcat meant for the application deployment - pilot error. Thanks to everyone for sharing their thoughts- much appreciated!
It looks like a known issue of MySQL over tomcat, have you tried yet any of the suggested solutions in
http://bugs.mysql.com/bug.php?id=69526
http://bugs.mysql.com/bug.php?id=68556
?

Liferay installed but localhost:8080 return "No data received"

I have downloaded liferay bundle with tomcat.
I unpack it to my mac Applications/Administrating/liferay....
I have run ./startup.sh
And at the exnd I get: INFO: Server startup in 47781 ms
But when I open localhost:8080 in browser I get "No data received" like there is no site installed.
This is whole log:
Using CATALINA_BASE: /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40
Using CATALINA_HOME: /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40
Using CATALINA_TMPDIR: /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/temp
Using JRE_HOME: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Using CLASSPATH: /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/bin/bootstrap.jar:/Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/bin/tomcat-juli.jar
STSiMacVVU:bin vladimirvucetic$ tail -f ../logs/catalina.out
Oct 21, 2013 2:30:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 21, 2013 2:30:04 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 665 ms
Oct 21, 2013 2:30:04 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 21, 2013 2:30:04 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
Oct 21, 2013 2:30:04 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/conf/Catalina/localhost/ROOT.xml
Loading jar:file:/Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/system.properties
Loading jar:file:/Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/ROOT/WEB-INF/lib/portal-impl.jar!/portal.properties
Oct 21, 2013 2:30:16 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
14:30:21,037 INFO [localhost-startStop-1][DialectDetector:71] Determine dialect for HSQL Database Engine 2
14:30:21,040 WARN [localhost-startStop-1][DialectDetector:86] Liferay is configured to use Hypersonic as its database. Do NOT use Hypersonic in production. Hypersonic is an embedded database useful for development and demo'ing purposes. The database settings can be changed in portal-ext.properties.
14:30:21,084 INFO [localhost-startStop-1][DialectDetector:136] Found dialect org.hibernate.dialect.HSQLDialect
14:30:36,629 WARN [localhost-startStop-1][PDFProcessorImpl:235] Liferay is not configured to use ImageMagick. For better quality document and image previews, install ImageMagick and enable it in portal-ext.properties or in the Server Administration control panel at: http://<server>/group/control_panel/manage/-/server/external-services
Starting Liferay Portal Community Edition 6.1.2 CE (Paton / Build 6102 / August 2, 2013)
14:30:41,605 INFO [localhost-startStop-1][BaseDB:478] Database supports case sensitive queries
14:30:42,056 INFO [localhost-startStop-1][ServerDetector:169] Server supports hot deploy
14:30:42,064 INFO [localhost-startStop-1][PluginPackageUtil:1046] Reading plugin package for the root context
14:30:44,914 INFO [localhost-startStop-1][AutoDeployDir:144] Auto deploy scanner started for /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/deploy
Oct 21, 2013 2:30:48 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'Remoting Servlet'
Oct 21, 2013 2:30:49 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/marketplace-portlet
Oct 21, 2013 2:30:50 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/portal-compat-hook
Oct 21, 2013 2:30:51 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/resources-importer-web
Oct 21, 2013 2:30:51 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /Applications/Administrating/liferay-portal-6.1.2-ce-ga3/tomcat-7.0.40/webapps/welcome-theme
Oct 21, 2013 2:30:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 21, 2013 2:30:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 47781 ms
What am I missing here?
A good starting point is to check if tomcat is receiving requests on port 8080 ; in your command-line type:
telnet localhost 8080
If you get a black/empty screen then tomcat is indeed listening on that port, otherwise you get a connection failure, then you need to doublecheck you tomcat configuration.
It looks like Liferay started up normally (but add more information - catalina.out or others, as gamerson requested in a comment)
Also:
Check Firewall settings (8080 might be blocked)
Your lsof output lists IPV6 (it's been long since I interpreted lsof
output and commandline - this might be normal, or not. You don't say
if you attempt an IPV4 connection)
Try to connect with a browser from that server. If it's a shell-only
server, use w3m or lynx on http://localhost:8080/
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
passenger_root /var/lib/gems/1.9.1/gems/passenger-4.0.5;
passenger_ruby /usr/bin/ruby1.9.1;
passenger_max_pool_size 10;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
access_log /var/www/access.log;
error_log /var/www/error.log;
location / {
root /var/www/demo/public;
passenger_enabled on;
rails_env production;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
You haven't configured a connector port 8080 so you won't get a response. The only connector you have configured is for AJP on port 8009 as can be seen from the logs.
Oct 21, 2013 2:30:04 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
If you're running the server from Eclipse, Go to Servers -> ports and set 8080 for HTTP/1.1
If you're running a standalone Tomcat, go and edit tomcat/conf/server.xml and set
<Connector URIEncoding="UTF-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
Make sure that the port 8080 is allowed from the server, and it's not used from another application
When the Server start, you should be able to read in the log this :
org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
My expectation would be to find this in the log:
24.10.2013 13:43:14 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
24.10.2013 13:43:14 org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
this would indicate the protocol handler for 8080 to start.
My advice to find the root cause of your problem is:
Access localhost:8080 before you start Liferay. This might give you the same result, indicating that there's some other software running on port 8080.
If this didn't help: Download a Liferay tomcat bundle again, unzip unchanged to a new location, run that one unchanged as well - if this one works, compare both directories, especially tomcat's /conf/ directory.
If that doesn't work, check if your environment defines any of the variables CATALINA_HOME, CATALINA_BASE, LIFERAY_HOME.
You'll be able to see more of the logs that you posted by running just a single command like ./bin/catalina.sh run. This will run tomcat in the foreground, showing the logs from the beginning without the chance to miss something because the tail command came too late
There is probably some other process using port 8080. Check it with this command:
sudo netstat -lnp | grep ':8080'
Kill that running process
sudo kill -9 {PID}
For example
sudo kill -9 1234
Restart Tomcat (if installed as service)
service tomcat7 restart
I mistakenly had a environment variable for CATALINA_HOME setup a few months back pointing to a different tomcat setup this caused the port 8080 to be invoked by that older setup and thus getting reserved before its used by Liferay. Make sure your CATALINA_HOME variable is configured to point at the tomcat bundled with Liferay.

Tomcat JAASRealm : Getting "Class not added" after starting server

I am using http://blog.frankel.ch/custom-loginmodule-in-tomcat tutorial for tomcat JAASRealm.I have added below in server.xml
Realm className="org.apache.catalina.realm.JAASRealm" appName="CustomLogin"
userClassNames="ch.frankel.blog.loginmodule.PlainUserPrincipal"
roleClassNames="ch.frankel.blog.loginmodule.PlainRolePrincipal"
/>
while starting server i am getting
INFO: Starting Servlet Engine: Apache Tomcat/5.5.27
Jun 8, 2012 1:18:24 PM org.apache.catalina.realm.JAASRealm parseClassNames
SEVERE: Class ch.frankel.blog.loginmodule.PlainUserPrincipal not found! Class no
t added.
Jun 8, 2012 1:18:24 PM org.apache.catalina.realm.JAASRealm parseClassNames
SEVERE: Class ch.frankel.blog.loginmodule.PlainRolePrincipal not found! Class no
t added.
Jun 8, 2012 1:18:24 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
Jun 8, 2012 1:18:24 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive CustomLogin.war
I am using tomcat 5.5.27. When i call my servlet authentication is working fine but authorization is having some issue and might be due to "Class not added."
Please help....
It got resolved...I added a jar containing above classes in /server/lib folder and its working fine.

Accessing newrelic API through my application

.I'm using Newrelic for java agent.I install the newrelic.yml file using the command "java -jar newrelic.jar install" in my prompt. When running, it shows the message as INSTALL SUCCESSFUL and some other information. I also find the newrelic.yml setup in running the run.bat file.But i'm not able to see the newrelic API in my browser when running the port as "localhost:8080/newrelic" . I'm started my server in the port 8080.
The log folder in newrelic diectory.My newrelic_agent.log containing the following lines...,
Feb 8, 2012 05:49:07 PM NewRelic INFO: Writing to New Relic log file: D:\work\software\jboss-6.0.0.Final\newrelic\logs\newrelic_agent.log
Feb 8, 2012 05:49:09 PM NewRelic INFO: Configured to connect to New Relic at collector.newrelic.com:80
Feb 8, 2012 05:49:09 PM NewRelic INFO: Setting protocol to "http"
Feb 8, 2012 05:49:09 PM NewRelic INFO: Configuration file is D:\work\software\jboss-6.0.0.Final\newrelic\.\newrelic.yml
Feb 8, 2012 05:49:09 PM NewRelic WARN: The apdex_t setting is obsolete and is ignored! Set the apdex_t value for an application in New Relic UI
Feb 8, 2012 05:49:09 PM NewRelic INFO: New Relic Agent v2.3.0 has started
Feb 8, 2012 05:49:09 PM NewRelic INFO: Java version: 1.6.0_12
Feb 8, 2012 05:49:30 PM NewRelic INFO: JVM is shutting down
Feb 8, 2012 05:49:30 PM NewRelic INFO: New Relic Agent has shutdown
I'm sure not yet started the newrelic API in my browser.It shows an error as "HTTP 404 the request resource /k12/newrelic is not available.I'm using j.d.k 1.6
Help me please..?
The New Relic Ruby agent has a Developer Mode that lives at the /newrelic path you're trying to reach, but the Java agent does not. Developer Mode would give you a detailed trace of each individual web request your app makes that's similar to what the normal New Relic product does with Transaction Traces.
To use New Relic and report performance data, it looks like you've got everything configured correctly. You should be able to log in to https://rpm.newrelic.com and see what your app is doing.
You mentioned "the newrelic API", but I'm not sure what you are looking for exactly. There is an API for the Java agent that lets you configure the agent. There's also a New Relic HTTP REST API that will let you retrieve data reported by your applications.

Categories

Resources