I am trying to learn this new GWT part of java...
I made my first simple app
I named
my module:- HelloWorld
my entry point class :- hello
and my html: index.html
I am getting this error:
Apr 18, 2014 4:00:53 PM java.util.prefs.WindowsPreferences
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs
at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Loading modules com.test.GWTTestProject
Loading inherited module 'com.test.GWTTestProject'
[ERROR] Unable to find 'com/test/GWTTestProject.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a
classpath entry for source? [ERROR] shell failed in doStartup method
module:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.6.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.6.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="Hello">
<inherits name="com.google.gwt.user.User" />
<source path="client" />
<entry-point class="com.test.client.Home"></entry-point>
</module>
entry point class
package com.test.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
public class Home implements EntryPoint {
public void onModuleLoad() {
RootPanel.get().add(new Label("Hello World"));
}
}
index file
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>index</title>
<script type="text/javascript" language="javascript" src="Hello/Hello.nocache.js"></script>
</head>
<body>
</body>
</html>
Error code 5 is "access denied".
Probably the key does not exist, and the user does not have the required permissions to create it.
Log on as administrator, start regedit, create a key named "Prefs" under HKEY_LOCAL_MACHINE\Software\JavaSoft (if it does not exist already) and assign full permissions to the key for the normal account you use.
Caveat emptor: messing up the registry will crash Windows, be careful.
In the Eclipse's Project properties, in the GWT pane, remove the GWTTestModule that must have been added automatically at some point (if you renamed your module after creation, it might be that the Google Plugin for Eclipse forgot to take the rename into account everywhere)
Whenever you rename a GWT project there are possibilities that all of the things are not renamed and you will notice that some of things are stop working. In that case you have to rename it manually.
I use a simple way to identify all the references of my last GWT project name by using Eclipse Search tool as shown below snapshots.
I think you have renamed it to HelloWorld from GWTTestProject. Most probably you will find the matches in *.xml, .classpath, .project, *.html etc. Look at the matches and replace it manually as per your new project name.
Remove all the previous stub and re-compile the project again. I have highlighted all the stubs that needs to be deleted as shown in below snapshots.
Related
I have been searching all day, moved the style.css everywhere and still not managed to get it loaded. The images wont load as well.
My structure:
But if i click the firefox button, it loads:
This is how the style.css is imported in the head of the index:
(tried all kind of combinations)
When i check the developer tools, it says 404 for GET request (style.css and the pictures)
Spring Boot knows where the static directory is, so you don't need to use the ../ technique to get to the files within. The other part is that you should be using an annotation to get there. It may depend on what view template you are using, but for thymeleaf this is how you would achieve pulling in the css file:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Your Title</title>
<link rel="stylesheet" th:href="#{/css/style.css}" />
</head>
Notice the annotation in th:href="#{/css/style.css}"
Make sure you include the namespace of your view template, th in the example.
Images work the same way:
<img th:src="#{/img/stanev2.png}" />
Learning JSP and have an issue with the css/js content not loading. I have a jsp page, where I have bootstrap css and js referenced using standard html link and script tags:
<link rel="stylesheet" type="text/css" link="/bootstrap/css/bootstrap.css" />
and
<script src="/WebIntro/bootstrap/js/bootstrap.js"></script>
neither of them work and Chrome is giving me the following on the console:
Resource interpreted as Stylesheet but transferred with MIME type text/plain:
If I use an include directive, it works for the css but pulls all the content into the file:
<%#include file="/bootstrap/css/bootstrap.css"%>
The jsp has the following #page and meta tags:
<%#page contentType="text/html" %>
and
<meta http-equiv = "Content-Language" content = "en"/>
<meta http-equiv = "Content-Type" content="text/html; charset=utf-8">
I tried googling and found the mime-mapping element for the web.xml but the following seems to have no affect:
<mime-mapping>
<extension>css</extension>
<mime-type>text/css</mime-type>
</mime-mapping>
<mime-mapping>
<extension>js</extension>
<mime-type>application/javascript</mime-type>
</mime-mapping>
If there is some standard Tomcat config that needs to happen I am unaware as I am new to Tomcat; using Tomcat 7, and eclipse and this is in a maven project.
The solution for me was very strange. The changes to the web.xml file that was present since I built the project in eclipse/maven, weren't reflected in the web.xml within tomcat webapp application directories. Everything else in the package updates fine (as far as I can tell), except for the web.xml?
So I found the web.xml file within eclipse inside target >> project-SNAPSHOT >> WEB-INF >> web.xml (which is supposed to be derived). Forced changes there and it worked, changes were picked up and my original issue gone.
I am guessing I had inadvertently broken some type of dependency link or something along the way somehow, but once I added the servlet, mappings, etc back in, everything worked fine.
Weird.
Removing this line in jsp resolved the error for us.
We were facing the issue when using Tomcat 8.5.59
After browsing through the whole internet I ended up asking this question, although I find it a bit difficult to describe the situation.
I have a little application here which runs on embedded Tomcat server (v7), and uses servlets and JSPs; I try to internationalize them with JSTL tags. The final project is deployed as JAR, and when I run it from the console with java -jar, the embedded server starts nicely, everything works just fine.
The problem is when I try to run it in the IDE (I use IntelliJ Idea v13.1.2): again, it starts, but instead of the values from the bundle, the pages show values such as ???default.username???.
Here is how my JSPs mostly look like:
<!DOCTYPE html>
<%# taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%# page contentType="text/html;charset=UTF-8" %>
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="language"
value="${not empty param.language ? param.language : not empty language ? language : pageContext.request.locale}"
scope="session"/>
<fmt:setLocale value="${language}"/>
<fmt:setBundle basename="messages" scope="session" var="bund"/>
<html>
<head>
<title><fmt:message bundle="${bund}" key="default.title" /></title>
<link rel="stylesheet" type="text/css" href="../css/tdb.css" media="all">
</head>
And so on. The <fmt:message bundle="${bund}" key="default.title" /> and similar parts work perfectly fine when I use the JAR, and result in ???default.title??? when from IDE. In one case I use the bundle file from the servlet, and when ran from JAR, it works fine, and when from IDE, it causes java.util.MissingResourceException.
What have I tried so far? I added my messages.properties and messages_en_US.properties files in various locations (in resources folder, on the same level with the java and webapp folders; in separate package in the com.my.example package; as simple properties files in the com.my.example package), tried to refer to it only with the basename (resourceBundle = ResourceBundle.getBundle("messages", locale);), or with the fully qualified path; also, I set the fallbackLocale and localizationContext parameters in the web.xml file.
What am I missing?
Code looks well.
I was checking in some of my projects and I have this attributes:
<fmt:setBundle basename="org.juanitodread.msg.label" var="label"/>
<fmt:message key="common.title" bundle="${label}" />
I have my projects in Eclipse, but you can try without "scope" attribute. My label.properties file is in "org.juanitodread.msg" package.
I also use the Intellij Idea and had the similar problems, here are my conclusions. You should put your 'messages file' to
yourproject/src/main/java/resources
folder (as a rule, Idea will highlight the resources folder icon with the specified sign). I have no fallback locale configuration and localization context parameters in web.xml. My bundle file is named messages_en.properties and I use it the way
<fmt:setBundle basename="messages" var="labels" />
and not add "resources.messages" to basename attribute.
I'm running IntellijIdea version 2016.2, and my application works fine on:
embedded Tomcat v 7.0.73 , using bmuschko gradle-tomcat plugin https://github.com/bmuschko/gradle-tomcat-plugin
remote Tomcat v 7.0.73 deployment with Tomcat Server Idea configuration
To check your resources are really loading (if your properties are not loaded to the page that means you're obviously missing the file), use the following code, as mentioned in https://stackoverflow.com/a/4137991/2759640
ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
URL propsURL = ctxLoader.getResource("opto-mapping.properties");
URLConnection propsConn = propsURL.openConnection();
In case you have your resources loaded, openConnecton will throw an exception, that connection to the messages.properties has been already opened (at least I've done that way and tried to make my bundle work also for a long time).
I'm trying to compile my gwt application. I'm having a parent project 'admin' and a maven module 'admin-app' with my web.xml *.gwt.xml admin.html.
Looks like:
admin package = com.admin
admin-app
src/main/resources
package=com.admin file=admin.gwt.xml
src/main/webapp
++ js
++ admin.css
++ admin.html
++ WEB-INF
+++ jsp
+++ lib
+++ applicationContextx.xml
+++ web.xml
The problem is my entry point or my paths and defaults names.
I included
<script type="text/javascript" src="admin/admin.nocache.js"></script>
To to generate the JS code for my application.
But My problem is within my *gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module SYSTEM "gwt-module.dtd">
<module rename-to='admin'>
<inherits name='com.google.gwt.user.User'/>
<!-- Specify the app entry point class. -->
<entry-point class='com.admin.client.AdminEntryPoint'/>
<source path='client'/>
</module>
My entry path is correct but I always get the error msg:
Loading modules
com.admin.admin
Loading inherited module 'com.admin.admin'
[ERROR] Unable to find 'com/admin/admin.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] shell failed in doStartup method
Without the entry point I can successfully compile my project, so the problem is within the entry-point.
thx for any help :)
I fixed this problem by renaming the module to app like the project-module, the *.gwt.xml to app.gwt.xml and also the path in my admin-html to app/app.nocache.xml. It's running know but the main idea was to use another namespace. So if anybody can help me there i would be very happy.
app should be named admin, for easier searching and so on.
thx :)
I've been researching on which to use between <applet>,<object>, or <embed>, but none seem to work.
When I tried to load JApplet through HTML I am got RuntimeException error java.lang.NoClassDefFoundError: com/sforce/ws/ConnectionException.
When I tried to run number1.class with the number1.class being in myfile.jar it needs the other 3 jar files for the library and that is what the error is. The files look like this:
tomcat-->webapps-->applet-->newhtml.html
applet-->lib-->(wsc-23,enterprise,partner)
applet-->applet_class-->(number1.class,myfile.jar)
Any help would be appreciated.
I've also looked through majority of stackoverflow questions as well as other places, but still no luck!
<!DOCTYPE html>
<html>
<body>
<html type="application/x-java-applet;version=1.6"
width="512" height="512"
code="applet_class.number1.class"
src="myfile.jar,applet/lib/wsc-23.jar,
applet/lib/enterprise.jar,
applet/lib/partner.jar"/></html>
</body>
</html>
The best way to deploy a JWS app. or applet is to use the Deployment Toolkit Script.
But looking at that element..
<html type="application/x-java-applet;version=1.6"
width="512" height="512"
code="applet_class.number1.class"
src="myfile.jar,applet/lib/wsc-23.jar,
applet/lib/enterprise.jar,
applet/lib/partner.jar"/></html>
The most basic form of the applet element (deprecated in HTML 4.01 is):
<applet
width="512" height="512"
code="applet_class.number1"
archive="myfile.jar,applet/lib/wsc-23.jar,applet/lib/enterprise.jar,applet/lib/partner.jar"/>
</applet>
Change html to applet.
Remove the type attribute.
Remove the .class from the end of the code attribute.
Change src to archive, and have all the archives in one line.