lost in deployment: session.getAttribute() returns NULL in some Tomcat configurations - eclipse

I am experiencing several issues that I can't understand from the first glances. The story is pretty simple, but I guess that the solution is behind some real configuration/deployment problem(s)/inconsistencies.
I have defined a JSP and two servlets. The JSP puts something in the session and the servlets are supposed to fetch the data and to manipulate it. The main symptom is that the servlets do not see the session data, when seeing JSPs in Chrome and Firefox. Interesting, that the JSP/servlets do share the data, when using Eclipse internal browser and also when using Internet Explorer (working on Win7).
Here is a bit long description along with some information (and subsequent symptoms) regarding the local configuration (and, as I believe, there lies the problem): I have installed Eclipse (Helios) under c:\labs\eclipse and unpacked Tomcat (7.0.12) under c:\labs\tomcat. I have also installed the Sysdeo plugin that launches Tomcat.
First, when I launch Tomcat with Sysdeo Eclipse plugin button and then try to access some application-related URL from an external browser - then the main Tomcat page is found, but not the application JSP/pages. However, when I launch Tomcat using the "play/run" Eclipse button (when some JSP page from the Eclipse web project is being selected) - then I can see the rendered JSP page both from Eclipse internal browser AND from any external browser. What is the difference between those two launch modes?
Second, when launching Tomcat via "play/run" Eclipse button only, and calling JSP and servlets either from an internal Eclipse browser or from external Internet Explorer browser, then all the data is being shared correctly by JSP and servlets. However (just for the same launch mode) if I am trying to access the JSP/servlets from external Chrome/Firefox browsers - then the JSP/servlets ARE found, but the data seems NOT to be shared via http session (printed the session id and verified that it is correct).
Third, when I launch Tomcat via "pay/run" button, then I can see the servlet log() printings in Eclipse console ONLY when using the internal Eclipse browser. When JSP/servlets are called from the external browsers - I couldn't find the log printings (but only a few access-related lines in files that reside in Tomcat logs directory).
Tried to summarize the tech issues that look odd to me - I most probably miss some valuable deployment/configuration-related info. Please advice what I am doing wrong and which is the better / correct configuration that will allow the session data to be shared when calling the application resources from all the external browsers. If you need any additional details regarding my configuration/environment - just ask.
Appreciate

Ensure that you're using Eclipse for Java EE developers, not Eclipse for Java developers. It already ships with a Tomcat server plugin builtin. The Sysdeo plugin is pretty old, you don't need it at all and I won't be surprised if that is after all the culprit some of the described problems.
As to running JSP/Servlet using the internal Eclipse browser versus a normal webbrowser, I have myself had bad experiences with the internal browser, I wouldn't recommend to use it for other than "quick testing". However, that it doesn't share the session with another browser is normal behaviour. They do not share the same browser instance anyway. Sessions are not computer-specific, they are browser-specific.
I'd just integrate Tomcat in Eclipse using the EE-provided plugin, start and stop it by the server properties (and not by rightclicking JSP/Servlet and choosing Run or something) and use a real webbrowser to access the pages. To properly getting started with developing JSP/Servlet using Eclipse and Tomcat, I warmly recommend you to use the Coreservlets.com tutorials. At the bottom of our servlets wiki page you can find several direct links.

Related

I get "Can't find any GWT Modules on this page"

I am trying to set up my eclipse with gwt and after I installed Jdk 8 and eclipse 2019-06 and gwt eclipse plugin 3.0 I created the sample project with code generated and when I try to run the sample code in GWT Development mode it gives me url http://localhost:9876 and when I open it I get "Can't find any GWT Modules on this page" Can you please help why It is giving me Can't find any GWT Modules on this page. I am assuming if I am running it in development mode I don't need to set up web server so I didn't. I didn't used gwt for long time and I am lost why it is giving me this can't find gwt module message when I load the page. Can you please help?
You still need a server, if you want to run any java code on your server. Such as code for talking to your database.
Gwt only does 2 things:
1: is is handling the client side, where it generate javascript from your java code.
2: It includes a .jar file, which can be used together with a java servlet server such as apache tomcat to serialize java objects which can then be send between the client and the server. And this .jar file will serialize all needed objects. And gwt will generate the needed javascript code.
Gwt does not itself include any http server. The address http://localhost:9876 is only used to configure gwt. It is just a page with 2 buttons to turn dev mode on/off.
The eclipse plugin does include a embeded webserver which can be used for gwt development. I have newer done this and I think that installing an independent java tomcat server is the best solution.
But if you want to use the eclipse embeded webserver you need the "Run in development mode with Jetty." - Jetty is the name of the embeded java servlet server.
Are you using the plugin from Google ?
If so, this is outdated. I advice you to use the plugin from branflake. You can find this plugin on GitHub : https://github.com/gwt-plugins/gwt-eclipse-plugin
Also on that GitHub page a lot of documentation is available. Like a link to a very helpfull YouTube playlist: https://www.youtube.com/watch?v=DU7ZQVLR5Zo&list=PLBbgqtDgdc_TqzA-qXrjgTFMC_6DKAQyT
My advice is to watch these YouTube videos to get you started. If you follow them all should be working without a problem.
I haven't used this plugin for a while since I switched to IntelliJ. But I did use it in GWT2.8.2 so it should still work fine.

How to run on JBoss html file with Eclipse

I am creating a Static Web Project using Eclipse Juno Service Release 2.
My problem is that I have an HTML file (very simple, created automatically with Eclipse with HTML5 template) in this project and I would run it in an external browser (for example, Chrome) using as Server JBoss 7.1.
I have already configured properly JBoss in Eclipse, I can run/stop it without problems.
I have configured as Web Browser Chrome.
I don't know how run the single html file in my localhost:8080.
Someone can help me?
If you have created the project then you would have to deploy it.
Refer to http://www.mastertheboss.com/eclipse/jboss-eclipse/jboss-and-eclipse?showall=&start=1 which describes how to deploy an application.
And your URL to the file would be http://localhost:8080/yourProjectName/htmlFileName
Example: http://localhost:8080/TestApp/index.html

Encoding problems running jsp web pages on Apache Tomcat

Sorry for my English.
I'm not a web page developer - I use already created jsp (I can not change them by my own), placing them together with different URL parameters - that way I create some complicated web project.
I have been using Apache Tomcat for a long time and had an error - cyrillic (cp1251) symbols doesn't show well in some places (not everywhere!) of project. Developers of jsp said, that it is a bug and they will fix it. Time goes by, but they do not.
Recently, I have imported EAR as project in Eclipse, created Tomcat server there. Before that I read this article:
http://www.vogella.de/articles/EclipseWTP/article.html
and installed all soft, specified in article to be able to work well with Tomcat project in Eclipse.
And I noticed, that when I publish project to Tomcat Server (created in Eclipse - it has it's own server) I had no errors with encoding! I think this is somehow connected to Eclipse & Eclipse Tomcat Server settings.
Question: Can I copy this settings to a real Tomcat Server (not Eclipse) for correct encoding everywhere? And what are this settings?
I also had a similar problem. My war was running on Eclipse Tomcat but when deployed manually on Tomcat, some web service involving currency symbol was facing encoding issues. Eclipse Indigo has some encoding for server.
This can be seen/edited through Run Configrations -> Common Tab. Changing this attribute produced consistent results for manual deploy and Eclipse deploy. I am not sure what this encoding is of, but it may set JVM's encoding.

Gwt and eclipse with jetty for production mode

Is there a standard easy way to launch Jetty from eclipse for the production mode?
I followed the instructions at http://code.google.com/webtoolkit/usingeclipse.html to setup a new project using gwt and eclipse.
The hosted (debug) mode seems to be already configured to work properly and involves one click in eclipse using "Debug as".
I would like to configure "Run as" to run the production mode in jetty. Is there a good tutorial on the standard way to set this up?
You have to compile your GWT-project before you can "Run As". It's the button with a red box and "G" on it.
Since GWT compiles to java script you don't need jetty if you don't have server-side logic... anyway, in a normal scenario you'll have some server interaction, BUT you're not sticked to jetty; tomcat or other server side technology could be used.
You can deploy the compiled JS to a web server and the server side logic to tomcat, jboss, jetty... even you could interact with php at the server.
Deployment to Google AppEngine is another option, a natural option if you use the eclipse plugin since it's tightly integrated with it.
In eclipse, Jetty is no more than a java process started like any normal java main.
Go to [Run]->[Run Configurations]->[Web Application]->[Your GWT Project] and you'll see a normal java main exec config.
Look at the [Main Class] option -> this is the embeded jetty ..or at
the [VM arguments] for the JVM
The ?gwt.codesvr= param in the URL only instruct the browser plugin to interact with the eclipse plugin embeded jetty in a way that only the modified code is re-compiled to JS and sent to the browser.
If you do not use the ?gwt.codesvr= probabilly you'll have to recompile all the project every time you change a single line of code.
I recommend you to clearly separate the compiled-to-js code and the server side code in different eclipse projects.
I also run the embeded jetty only for the client-side code; the server side code is run in tomcat.
That way I have a clear separation of layers at the time I can debug client-side GWT code and server-side java code.

JSP client for Axis2 web service in Eclipse

I am new to web services and have managed to convert an Axis1 web service to Axis2. I can get data back from it using the Web Service Explorer with Eclipse. I am using Eclipse 3.6.1, Tomcat 5.5, and Windows XP. Problem is I am missing the JSP client to test with.
When you generate a web service using Eclipse and Axis 1, you get the generic 3-frame JSP test client with the methods on the left, input and results on the right. Can't seem to get this to happen with Axis 2. I have tried the Dynamic Web Project, Web Service, Web Service Client, and Axis2 CodeGen wizards in Eclipse, in various combinations, and all I get is a xxxCallbackHandler.java and xxxStub.java. I am able to test using the Web Service Explorer, but I need the JSP client because we have folks doing testing who aren't developers and don't have Eclipse.
I tried converting the JSP test client from the old Axis 1 service. This didn't go well because there are lots of references to org.apache.axis stuff that isn't part of Axis 2 (or at least reorganized to the point I couldn't find it).
Any suggestions on how to get a JSP client to generate or, if I need to build one, maybe an example? I have Googled to the point where every search I do for jsp, client, webservice, and eclipse, all the results come back purple. Somebody's got to have had this problem before...
If you need some UI tool for testing, I do not necessarily need JSP generated by Axis but can use some tools like SoapUI.
This is their guide how to do functional testing with SoapUI: http://www.soapui.org/Getting-Started/functional-testing.html
I came across the same problem using Eclipse Helios and Indigo on a Win 2003 server. The issue seems to be a bug, see here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=341525.
I am using the Web Services>Create Client wizard to do my testing by letting Eclipse test the client with it's automatically generated JSPs at the end of the wizard.