GWT Module inheritance and NO source code available on application running time - java

I am starting to use GWT for a class project and wanted to know real use cases for RPC. So, I found this example on this same website: Stack Overflow - Simple RPC Use Case Problem (Code Included)
Why I did this example? because I was getting the same errors that the user posted on my own project and I decided to try and follow his code on my computer to see if I could really face my own mistakes.
So the point is that after copying the files on an Eclipse GWT project and deploy the app, I got this two errors on running time:
1st Error
12:14:07.874 [ERROR] [test] Line 17: No source code is available for type com.google.gwt.user.server.rpc.RemoteServiceServlet; did you forget to inherit a required module?
2nd Error
12:42:54.547 [ERROR] [test] Unable to find type 'org.redboffin.worldhug.client.test.Test'
12:14:09.341 [ERROR] [test] Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
So I tried to correct Test.gwt.xml as Craig suggested on the post. Unfortunately, that solution is not working to me because still I am getting the same errors.
1st error: I don't know what is happening because, for example, in the file it is depicted, RemoteServiceServlet is imported some rows before (despite it is not seen). This file is on package "org.redboffin.worldhug.server.test;"
2nd error: If user who posted initial thread did not need to "inherit" a new package in his project, I can't understand why do I need them. Anyway, I put a new inherit line one the .gwt.xml file:
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.0.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='test'>
<inherits name="com.google.gwt.user.User" />
<entry-point class="org.redboffin.worldhug.client.test.Test"></entry-point>
<source path="client" />
<source path="shared" />
<inherits name="org.redboffin.worldhug.client.test.Test" />
</module>
And that is what I got:
Loading inherited module 'org.redboffin.worldhug.client.test.Test'
[ERROR] Unable to find 'org/redboffin/worldhug/client/test/Test.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
(of course, it didn't compile)
So, I really don't know what is going on. Please, can someone bring some light to this issue? Why is this not working? What I am doing bad? What is this type that it is needed on the 2nd error?

Hello Irene and other Web-Wanderers,
Maybe this is a double post on a already answered post or let me say it is a try to clarify about includes of Java Source code in the xml file. I got stuck at the same point, but I couldn't point out what Adrian meant. The last two source tags will tell what packages and trailed source files shall be compiled. That is why you should name each package in the attribute called "path".
The file below was auto-generated in Eclipse Indigo in Framework version: appengine-java-sdk-1.6.4.1. It is bereft of unnecessary comments.
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='wk_cms'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.google.gwt.json.JSON'/>
<inherits name='com.google.gwt.http.HTTP'/>
<inherits name='com.google.gwt.user.theme.chrome.Chrome'/>
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='de.someproject.wkcms.client.Wk_cms'/>
<!-- Specify the paths for translatable code -->
<source path='client'/> <<-- my code (package client)
<source path='communication'/> <<-- my code (package communication)
</module>
I hope this keeps everyone afar from probing and testing before having success... =)
Best regards,
Semo
PS. The file edited was not web.xml but PROJECTNAME.gwt.xml.

Think I see it:
Test.java should be in the client.test package not just client, or everything should point to client.Test rather than client.test.Test.

Your server class seems to be under the package server.test, rather than just server, which is probably wrong. Check the mapping in web.xml correctly points to this class.
I suspect the real error is probably somewhere else though - I would have expected it still to compile.

(Not sure if I have to "answer your question" or not, first try on Stack Overflow site!)
Thanks for your comment, Adrian!
This is the content of "web.xml" file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Servlets -->
<servlet>
<servlet-name>testServlet</servlet-name>
<servlet-class>org.redboffin.worldhug.server.test.TestServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>testServlet</servlet-name>
<url-pattern>/worldhug/test/testService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>test.html</welcome-file>
</welcome-file-list>
</web-app>
It seems that the servlet tag is pointing to the right place to my eyes: TestServiceImpl.java is inside package "org.redboffin.worldhug.server.test" Did you mean that?
Any other idea?
Thank you again! :)

You will have to include the following
<source path='client.test'/>

Related

Deploying Wicket CDI on TomEE with OWB

I’m facing a problem when trying do deploy on TomEE (using OWB).
I’m getting the following exception:
javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.apache.wicket.cdi.AutoConversation] is not found with the qualifiers
Qualifiers: [#javax.enterprise.inject.Default()]
for injection into Field Injection Point, field name : autoConversation, Bean Owner : [null]
at org.apache.webbeans.util.InjectionExceptionUtil.throwUnsatisfiedResolutionException(InjectionExceptionUtil.java:60)
at org.apache.webbeans.container.InjectionResolver.getInjectionPointBean(InjectionResolver.java:250)
at org.apache.webbeans.inject.AbstractInjectable.inject(AbstractInjectable.java:76)
at org.apache.webbeans.inject.InjectableField.doInjection(InjectableField.java:65)
at org.apache.webbeans.portable.InjectionTargetImpl.injectFields(InjectionTargetImpl.java:372)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:358)
at org.apache.webbeans.portable.InjectionTargetImpl.inject(InjectionTargetImpl.java:342)
at org.apache.wicket.cdi.NonContextual.postConstruct(NonContextual.java:129)
at org.apache.wicket.cdi.NonContextualManager.postConstruct(NonContextualManager.java:65)
at org.apache.wicket.cdi.ConversationPropagator.(ConversationPropagator.java:122)
at org.apache.wicket.cdi.CdiConfiguration.configure(CdiConfiguration.java:188)
…
I’ve been looking for information online, but there seems to be nothing on it. I have the seam-conversation-spi and seam-conversation-owb jars on my classpath, so that’s not a dependency issue (had some of those, but got over them).
I understand from other people that deploying an EAR with wicket-cdi on other application servers is very easy and straightforward. However, I really like TomEE (the whole "based on TomCat" concept), and wouldn't want to have to switch.
I'm at a loss here, does anyone have a clue on what's going on ?
Edit 1:
This is the contents of my application class init method:
public void init() {
super.init();
BeanManager manager = (BeanManager)new InitialContext().lookup(“java:comp/BeanManager”);
new CdiConfiguration(manager).configure(this);
}
There's really nothing more in the class.
Edit 2:
Here's the code of my application.xml file used to create the EAR file I deploy:
<application 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/application_6.xsd"
version="6">
<initialize-in-order>true</initialize-in-order>
<module>
<ejb>integration.jar</ejb>
</module>
<module>
<ejb>application.jar</ejb>
</module>
<module>
<web>
<web-uri>presentation.war</web-uri>
<context-root>app</context-root>
</web>
</module>
</application>
Edit 3:
From what I read in the code of wicket-cdi and openwebbeans, I think it has to be one of these scenarios:
OWB doesn't find the AutoConversation class (i.e. the wicket-cdi JAR) - I bundle the class inside the WAR in the lib directory using Ant's standard task, so that seems strange
OWB doesn't recognize that the wicket-cdi JAR is a beans JAR - That sounds almost impossible, especially since there's a beans.xml and MANIFEST.MF in the JAR under META-INF as request by the cdi spec
Still at a loss, any help would be appreciated.
Edit 4:
Here's the list of JARs I have in the WAR file, in case it helps:
seam-conversation-spi-3.0.0.Final.jar
velocity-1.7-dep.jar
velocity-1.7.jar
wicket-auth-roles-6.15.0.jar
wicket-bean-validation-6.15.0.jar
wicket-bootstrap-0.17.jar
wicket-cdi-6.15.0.jar
wicket-core-6.15.0.jar
wicket-datetime-6.15.0.jar
wicket-devutils-6.15.0.jar
wicket-extensions-6.15.0.jar
wicket-guice-6.15.0.jar
wicket-ioc-6.15.0.jar
wicket-jmx-6.15.0.jar
wicket-request-6.15.0.jar
wicket-spring-6.15.0.jar
wicket-util-6.15.0.jar
wicket-velocity-6.15.0.jar
Wicket expects AutoConversion bean to inject into ConversationPropagator.
See the fragment of the source of org.apache.wicket.cdi.ConversationPropagator:
#Inject
Conversation conversation_;
#Inject
AutoConversation autoConversation;
Solutions:
Add a bean of type org.apache.wicket.cdi.AutoConversation to your bean definitions.
Disable ConversationPropagator
See your modified code, how to disable ConversationPropagator
new CdiConfiguration(manager).setPropagation(ConversationPropagation.NONE).configure(this);

GWT JS *.nocache.js not generated

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 :)

Not able to use Google Maps V3 with GWT

I am trying to get Googlemaps v3 to work with Google web tool kit.
I am using GWT 2.5.1. I have been trying to search for the lastest release of Google Maps with GWT and ended up on this page.
As per there instructions I have downloaded those 3 jar files.
gwt-maps-api-v3-3.8.1-javadoc.jar
gwt-maps-api-v3-3.8.1-sources.jar
gwt-maps-api-v3-3.8.1.jar
I have placed those jar files in my WEB-inf
I have added those jar files to my class path
In my map_geolocation.gwt.xml I have inherited the module.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to="map_geolocation">
<inherits name="com.google.gwt.user.User" />
<inherits name="com.google.maps.gwt.GoogleMaps" />
<source path="client" />
<entry-point class="com.google.maps.gwt.samples.basics.client.MapGeolocation" />
</module>
When i try to run my code I get this error.
Loading modules
com.google.maps.gwt.samples.basics.map_geolocation
Loading inherited module 'com.google.maps.gwt.samples.basics.map_geolocation'
Loading inherited module 'com.google.maps.gwt.GoogleMaps'
[ERROR] Unable to find 'com/google/maps/gwt/GoogleMaps.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] Line 6: Unexpected exception while processing element 'inherits
After doing some research I inherited
<inherits name='com.google.gwt.maps.Maps' />
instead of
<inherits name="com.google.maps.gwt.GoogleMaps" />
Still it fails. Does anyone know what is going on ?
UPDATE : I am not concerned with using V3. Where can I find the stable latest
Google map plugin for GWT ?
1- You only need a jar, download last version from maven repos, and put in your classpath just one jar:
gwt-maps-api-3.10.0-alpha-6.jar
2- gwt-maps-api depends on gwt-ajaxloader so download it as well, uncompress it, and add the gwt-ajaxloader.jar file to your classpath.
3- Check that you are inheriting the correct module in your .gwt.xml file:
<inherits name='com.google.gwt.maps.Maps' />
4- Normally, in your eclipse, the classpath of the GWT sdk should be before than 3party libraries
5- The [ERROR] Unable to find '....gwt.xml' on your classpath is always a problem of classpath. There is plenty of answers in stackoverflow about this common problem.
After doing this, if your problem persists, try to remove the 'run as' configuration of your project and set it up again.

Servlet Path Error

For exercise purpose I'm making an application using GWT which consists of a login form. While running it gives an error
Loading modules com.logvin.LoginForm
[ERROR] Element 'servlet' beginning on line 19 is missing required attribute 'path'
[ERROR] Failure while parsing XML
I am using GWT-RPC and checking if the given username and password is correct or not. I've made few changes in the xml file which are:
entry-point class='com.logvin.client.LoginForm'/>
<servlet> path="/LoginForm" class="com.logvin.gwt.server.GreetingServiceImpl"/>
<servlet>
<servlet-name>GreetingServiceImpl</servlet-name>
<servlet-class>com.logvin.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>GreetingServiceImpl</servlet-name>
<url-pattern>/LoginForm</url-pattern>
</servlet-mapping>
Why i'm getting this error again?
You're mixing up two XML dialects.
All those <servlet> elements should go into your WEB-INF/web.xml file, that tells the servlet container (server where you'll deploy your app) how to serve your servlets.
The *.gwt.xml file (GWT module) is about telling the GWT compiler (see: compile-time, not runtime) how to compile your code: where to start when loading the app (the entry-point), which classes are client-side (will be compiled to JavaScript, others –server-side only– have to be excluded), which GWT modules to import (inherits), etc.
I doubt you incorrect gwt.xml
Your LoginForm.gwt.xml should be something like this.
<entry-point class="com.logvin.client.LoginForm"/>
<servlet path="/LoginForm"
class="com.logvin.gwt.server.GreetingServiceImpl" />
EDIT:
servlet entries are no longer needed in *.gwt.xml files. So you can also delete this line:
<servlet path="/LoginForm"
class="com.logvin.gwt.server.GreetingServiceImpl" />
Also, Check you have this entry in your web.xml.
Read Example here

Error: Wrapper cannot find servlet class VendorRegistration or a class it depends on

I'm a newb whose also been searching for a solution to the same problem. I've followed the steps that the Elite Gentleman and Bozho outlined here. So first of all, thanks a lot guys. But I still seem to have the same problem. Now as per my understanding and implementation, my situation is as follows:
My servlet class VendorRegistration is available in the folder: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\VendorReg\WEB-INF\classes
My web.xml is present at: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\VendorReg\WEB-INF\
However, I still seem to be getting the error:
****HTTP Status 500 -
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Wrapper cannot find servlet class VendorRegistration or a class it depends on****
I have also appended my web.xml file below for your consideration:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.5">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-class>VendorRegistration</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VendorRegistration</servlet-name>
<url-pattern>/VendorRegistration</url-pattern>
</servlet-mapping>
</web-app>
I am trying to access the servlet through the URL: http://localhost:8080/VendorReg/VendorRegistration. What am I missing ? I had compiled the .class file sometime before I installed Apache. And hence directly copied pasted the class file in the folder. Could that be a problem ?
The servlet or one of its dependencies is missing in the classpath.
First of all, always put Java classes in a package, also servlets. Packageless classes are invisible to classes in a normal package. For servlets, this works in specific environments only. You don't want to be dependent on that.
package com.example;
public class VendorRegistration extends HttpServlet {
// ...
}
With this package, the compiled .class file must end up in /WEB-INF/classes/com/example/VendorRegistration.class. Don't forget to alter the associated <servlet-class> entry in web.xml accordingly.
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-class>com.example.VendorRegistration</servlet-class>
</servlet>
If that doesn't help, then you should put the classes or JAR files containing the (in)direct classes which are specified in any of the servlet's import statements also in /WEB-INF/classes (for .class files) or /WEB-INF/lib (for JAR files). The root cause in the exception stacktrace should tell which class exactly it is. Just read the stacktrace.
See also:
Servlets info page - contains a Hello World and several useful links
From tomcat 6.0 onwards, there is change in <url-pattern>
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-name>VendorRegistration</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>VendorRegistration</servlet-name>
<url-pattern>/servlets/servlet/VendorRegistration</url-pattern>
</servlet-mapping>
It worked in my case!
In my case the problem started when I made a copy/paste of HelloWorld.java class example from another project. Finally I solved it out by simply creating a new package, then a new HelloWorld.java from scratch and copy just the code for the doGet() method.
Then I restarted the server and ran http://localhost:8080/mltest/HelloWorld
And it worked!
I faced the same problem too. Actually one of my program which was working already after few changes showed me this error. I even did undo to revert the changes, still It happened to me.
Finally I found a working solution for this for my scenario.
SIMPLE:
1.Just try to clean your project and run again. If it shows the same error and if you are sure there isn't any problem with your code then,
2.Enable the "Build Automatically" menu item under "Project" menu and try to clean your project. This time it worked for me.
Heard this is because when we make some changes and run, eclipse does some changes in its background too. So even if we revert the changes, eclipse might have not reverted the changes which it did in background. So performing these 2 steps will make sure it matches with the user change with its background change.
Hope it helps and solves your problem too.
This is how I solved the problem when I had the same exception with yours.
Ensure you add the right libraries, we need to add the Library Tomcat. At the beginning, I just added the servlet-api.jar, but someone told me it's not a right way. Maybe when you implemented the project in tomcat it had some Conflicts with Tomcat.
Ensure your project in the right folder, %Tomcat_HOME%\webapps\%projectName\WEB-INF\classes\.....
Ensure web.xml in the right folder, and with right form,
%Tomcat_HOME%\webapps\%projectName\WEB-INF\web.xml
Reload the application in Tomcat.
Access the servlet through URL:
http://localhost:port/%projectName%
I'm afraid you made a mistake to try to access a servlet class directly.
Generally, the URL should be your any txt, jsp, html files under your application folder , but the servlet is used for response your "POST" or "Get" request from client side, it's immpossible to access it directly through URL.

Categories