Tomcat and Eclipse: image files and css files blank - eclipse

I am developing a Java EE project in Eclipse, and deploying it on Apache Tomcat. (Inside Eclipse, I right-click the project, and then "Run as" -> "Run on Server".)
For some reason however (my guess is Eclipse misconfiguration), the browser cannot locate any JavaScript or CSS files. For instance, the web page has this code:
<link rel="stylesheet" style="text/css" type="text/css" href="generated-res/css/main.css">
<script src="generated-res/scripts/all.js" type="text/javascript" ></script>
Clicking them in Firefox source view, however, just opens up a blank page. My Eclipse project has a WebContent directory, which contains, among other things, generated-res directory. I uploaded an image (about Eclipse Web Deployment Assembly) on http://imagepaste.nullnetwork.net/viewimage.php?id=4185 . Can anyone spot what is causing this problem?
I have Eclipse "Indigo Service Release 2," which contains Apache Tomcat v6.0.
Much oblige!

This seems to be a molgenis specific issue. In the molgenis.properties file you should add the service that is responsible for delivering the files (this is done in a seperate service to allow for application level security rules). The service you need is 'core.servlets.FileService'
In your molgenis.properties a typical set of services would look as follows:
services = app.servlet.GuiService#/molgenis.do,\
org.molgenis.framework.server.services.MolgenisXrefService#/xref,\
org.molgenis.auth.service.MolgenisCaptchaService#/captchaImg,\
org.molgenis.framework.server.services.MolgenisTmpFileService#/tmpfile,\
core.servlets.FileService#/
This includes:
- the user interface
- services for Ajax based lookups
- captcha service for new registrations
- tmp files
- the files in WebContent

From your query it looks like you mean you are using the open source molgenes project, so I would think asking them would be a good bet.
However, as a brief look I would say the css is generated as /css/main.css so to test try the address of:
localhost:8080/molgenis_apps/css/main.css

Related

AngularJS file not loading in browser using Eclipse?

i am very new to Eclipse, Spring and AngularJS, This is my first project in Spring and i have referenced AngualarJS and LoginPage.js as below in Eclipse.
But when this application is compiled and Run in Chrome, it throws an error like "server responded with error (resource not found)" as shown below
And my Web.xml is as follows
Is there any setting in Eclipse which i am missing?. Please note it works fine with VisualStudio or if done in normal folder structure. Only when done through Eclipse we get the issue.
If you're using Spring WebMVC, you can put a line like this in your context.xml.
<mvc:resources mapping="/resources/**" location="/resources/" />
This maps your resources folder in WebApp Root (so src/main/webapp/resources) to the /resources/* url. Put your CSS, JS, Images in the Resources folder and then change the link.
i got the answer, it was quite simple, i had to place the js file under WebContent folder and not web-inf, and had to give the reference as follows
<script type="text/javascript" src="appScripts/angular.js"></script>

Import directory structure into eclipse

I've recently gotten the source code to a jsp application (I'm primarily a c# guy, so apologies for any terminology that doesn't fit). I'm trying to use Eclipse to make changes and run the application locally, but am having some problems getting started.
The folder structure is as follows
/Admin
/css
/js
/jsp
...more folders that look like your typical web site
/WEB-INF
/classes
/lib
web.xml
taglib-i18n.tld
build.xml
index.jsp
I've tried creating an empty dynamic web application and dragging the folders in, but there are ton's of build errors saying that the code found in the sub directories under /classes/ isn't recognized.
I can run a very simple jsp tutorial locally, so I'm confident that tomcat and the jsp framework is installed.
The source code is coming straight from (sorry) Source Safe and the current methodology is to make changes and deploy and test on a development server.
Is there something obvious that I'm missing or need to configure?
Sounds like you are not telling Eclipse about your dependencies. Go to Project > Properties > Java Build Path > Libraries and make sure you have all your dependency JARs referenced there.

eclipse dynamic web project file locations

I'm creating a new dynamic web project in Eclipse and was wondering what best practices are for folder taxonomy. Here's what I believe it is <> are folders. Can someone please verify?
<Eclipse project name>
<src>
-- .java files
<WebContent>
-- .html pages
<images>
<css>
<js>
<META-INF>
MANIFEST.MF
<WEB-INF>
web.xml
<app name>
-- .jsp pages
Here is a sample folder structure of a dynamic web project:
As you can see all static files are placed as sub-folders under the WebContent folder. By naming conventions .css files are places in the css sub-folder. JavaScript .js files are placed under the js sub-folder and any image files such as .jpeg or .png are placed in the images sub-folder. I also have an extra lib sub-folder where I placed an angularjs library to be used.
By default after creation of a dynamic web project your web.xml file looks like so:
`<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>`
meaning it will first call the listed default name files when you run your application. This is why most projects will name the files as index.html or index.jsp. NOTE: that my index.html file is directly below the WebContent folder and not in a sub-folder
Finally you can call/include your static files (.css .js and image files) from your 'index' file like so:
<link rel="stylesheet" href=css/bootstrap.min.css>
<link rel="stylesheet" href=css/bootstrap-theme.min.css>
<script type="text/javascript" src="lib/angular.min.js"></script>
<script src="js/contactsApp.js"></script>
Also your .java files will properly go in the Java Resources -> src -> {place java files here}
Put your pages under WEB-INF folder, in that way they cannot be accessed directly.
Also look at maven directory layout http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html.
To what Aleksandr M said,
WebContent folder:
The mandatory location of all web resources, including HTML, JSP, graphic files, and so on. If the files are not placed in this directory(or in a sub directory structure under this directory), the files will not be available when the application is executed on the server.
WEB-INF
Based on the Sun Microsystems Java Servlet 2.3 Specification, this directory contains the supporting Web resources for a Web application, including the web.xml file and the classes and lib directories.
Source: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.wst.webtools.doc.user%2Ftopics%2Fccwebprj.html
I am not sure why having an app-name directory under WebContent would be considered a "best practice".
Other than that, one primary rule you should be following when coming up with a directory structure is to have all static resources under one directory. In your example, I would have a subdirectory called static under WebContent, and place the js, css and images directories under it.
That way, it'd be easier for you to (later on) configure your HTTP server to pick static resources directly from the file system rather than route requests for static resources through the servlet container.
I had this question too and can't comment yet, but Upendra Bittu's answer helped me.
http://help.eclipse.org/neon/index.jsp
Search 'jsp', click on "Creating JavaServer Pages (JSP) files"
Create a dynamic Web project if you have not already done so.
In the Project Explorer, expand your project and right click on your WebContent folder or on a subfolder under WebContent. Note that
if you choose any other folder in which to create the JSP, then it
will not be included in the WAR file that is deployed to the server.
In addition, link validation will not encompass files that are not
under the WebContent folder.
From the context menu, select New > JSP. The New Java Server Page window appears with your folder selected
I'm trying out tutorials and get lost when people don't say where they create their files, and this helped me understand what's going on, so I'm just passing it on.

Which folders or files i need to transfer Gwt compile outputs into phonegap" www" folder?

Which folders or files i need to transfer to work fine in phonegap. I succeed in GWT but the problem is :I only transfer "war" folder in GWT into Phonegap's "www" folder. And it did not work as in GWT. (i guess javascript applications does not work). My project was default GWT first tutorial.
Anyway, is there a any way first create in GWT and run applications in phonegap platform?
You can run your GWT Applications just fine in phonegap ( take a look at http://www.m-gwt.com ). This open source project is all about running mobile gwt.
Basically what you need to do is copy the GWT output to the www folder of your phonegap project.
lets say your module has the name "greet". Then the gwt compiler is going to create a folder "greet" as its output folder containing all files that you need to run your app.
What you also want to do is change the index.html file from phonegap to include your GWT app.
So somewhere after:
<script type="text/javascript" language="javascript" src="cordova-version.js"></script>
You need to include your gwt module:
<script type="text/javascript" language="javascript" src="greet/greet.nocache.js"></script>
If you want to take a look at http://www.m-gwt.com there is a lot of documentation there on how to get started with GWT / Phonegap.

SpiffyUI: help configuring existing GWT project; in particular, how exactly is spiffyui.min.js being found?

I feel as if I must be missing something obvious here. The Getting
Started page here http://www.spiffyui.org/?getStarted
says, among other things:
Add the Spiffy project dependency You can have Spiffy automatically downloaded through a Nexus server, or you can manually download JARs
from our downloads page. . . . .
Ok, I just use Apache Ant the way it was configured by the GWT
project generator. I downloaded the two .jar files and told the
build.xml file to copy them into war/WEB-INF/lib when I build.
(also setting spiffyui.sdk at the top)
<!-- Add any additional server libs that need to be copied -->
<copy todir="war/WEB-INF/lib" file="${spiffyui.sdk}/spiffyui-0.7.8.jar" />
<copy todir="war/WEB-INF/lib" file="${spiffyui.sdk}/spiffytasks-0.7.8.jar" />
Reference Spiffy in your HTML Now the CSS and JavaScript files are included in your project when you build. The next step is to reference
them in your HTML file. The Spiffy UI framework includes many
JavaScript and CSS files, but they are all combined into two files for
faster application loading. Reference this one file and the JQuery
library in the head section of your HTML files like this:
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="spiffyui.min.js"></script>
...
</head>
Ok, done.
Import Spiffy in your GWT module The last step is to import the Spiffy UI framework GWT module. Add the following line to your GWT
module file:
<inherits name="org.spiffyui.spiffyui" />
Ok, done
That's all it takes.
Really?
So now I am serving html file that refers to spiffyui.min.js as a
local file. It seems to me that I should tell my web server to serve
that file. I could not figure out where I was supposed to get that
file until I looked in the .jar files and found org/spiffyui/public/js/
spiffyui.js . Hmm, well maybe these Java web containers automatically
look for files down in the .jar libraries and serve them??! Sounds
odd, but ok.
I tried running under dev mode and then I manually went to the URL
that the script tag src property should imply:
http://127.0.0.1:8888/spiffyui.min.js
result: 404 Not found
maybe I need to special modified URL for dev mode?:
http://127.0.0.1:8888/spiffyui.min.js?gwt.codesvr=127.0.0.1:9997
result: nope, 404 Not found
What am I missing here?
The magic you're missing is the GWT compiler. When you add the module dependency to your GWT project for Spiffy UI you're giving the framework a chance to be part of your projects complication. Part of that means it will copy the spiffyui.min.js file out of the JAR files and into to the same directory in your project output as the rest of your GWT code.
Once the file is copied out the reference you added to your HTML file works because it can pick up spiffyui.min.js with a relative URL. Once the JavaScript loads Spiffy UI can import CSS and anything else it needs to make the framework run.
I hope this helps,
Zack