I am getting the following error when running a basic servlet on Eclipse Kepler (Windows 7) with GAE SDK 1.9.3 and Java 7:
java.lang.NoClassDefFoundError: javax.servlet.http.HttpServlet is a restricted class.
Please see the Google App Engine developer's guide for more details.
To reproduce:
install Java 7 SDK
install Kepler
install the GAE Eclipse plugin
create a GAE web project
implement the init method of a basic servlet and set load-on-startup to 1 in web.xml
then run the web application
I tried on 2 machines and I got the same error.
Create a servlet by extending HttpServlet, then Override doPost() and doGet() methods in your servlets. For example:
public class FileServlet extends HttpServlet {
#Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// do something
}
Well, I found what was wrong and it was my mistake. Sorry. When I installed Java 7, I specified a different directory for the JDK and the JRE, which is fine, except that I gave the same location twice and the files got mixed up. My GAE issue was a side effect.
Related
I'm trying to make some simple project with AngularJs using ES6 with Traceur compiler and with Spring Boot as my backend. I already managed to configure my project so it works as I expected. I only have some problems with configuring IntelliJ to see my resources properly.
I put my static resources in src/main/resources/public and configure ResourceHandlerRegistry so that it redirects any unknown request to the main angular application file (I want to use html5 location mode, so it was necessary. I found working configuration in the second answer of this question Spring Boot with AngularJS html5Mode).
The error occurs when I import any of my ES6 modules:
import {appModule as app} from 'resources/app/main.js'; // <- here IntelliJ sees an error, it cannot find such file, but when I run the application it all works as expected
Here I uploaded my whole project: http://www.filedropper.com/spring-boot-test
Could anyone tell me what should I do to get rid of this error in IntelliJ or check what I've done wrong with my project?
btw. I use IntelliJ 14.
Edit:
I had error in StaticResourceConfigurator. It should be:
/* ... */
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/resources/**").addResourceLocations("classpath:/public/");
Instead of:
/* ... */
#Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/public/**").addResourceLocations("classpath:/resources/");
But it didn't solve my problem.
Kindly help me with this. I am using blob store for saving images and it is working perfectly fine on my local environment. But when I deploy the same code the cloud it is throwing me the exception : java.lang.NoClassDefFoundError: com/google/appengine/api/blobstore/BlobstoreServiceFactory
I am using GAE 1.8.4
Most likely, appengine-api.jar is missing from your war/WEB-INF/lib/ folder.
If you use Eclipse, click on the Problems tab. You may see a warning saying that this jar is not available on a server. Right click on this warning, select QuickFix, select "Copy..." option. Or copy this jar to this directory manually.
In my case the required jar was inside the WEB-INF/lib folder but the error was still occuring... I found that this error was occuring because Jetty 9 was not done yet with class loading startup process while one of my initialization class was requiring BlobstoreService:
public class InitializeAppContextListener implements ServletContextListener {
private BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
So I had to postpone instance variable initialization once context is fully loaded as follow:
public class InitializeAppContextListener implements ServletContextListener {
private BlobstoreService blobstoreService;
public void contextInitialized(ServletContextEvent event) {
blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
Then the webapp was able to start normally again. This new behavior appeared after we had upgraded from servlet-api 2.5 to 3.1 with JDK 1.8...
I get this warning in the console while running my Google App Engine application in the development server :
WARNING: Fail to load endpoint class class com.mydomain.MyClassEndpoint with ApiConfigSource class com.google.api.server.spi.config.datastore.ApiConfigDatastoreReader
The warning seem to appear when the Android app accesses the endpoint not when I start the development server.
What does it mean and how can I solves it ?
I am using :
GAE-J : 1.8.3, JDO, Eclipse Kepler + GPE
As per google guys, you can ignore this warning. It's a 1.8.3 bug. "The message shouldn't be appearing, and will be correctly hidden in a future release"
https://code.google.com/p/googleappengine/issues/detail?id=9824
I'm trying to learn how to deploy an GWT application to Google App Engine.
I'm using GWT 2.4 + eclipse with Java 7.
I have basically a static page with a button that doesn't do anything.
public class Test1 implements EntryPoint {
public void onModuleLoad() {
final Button sendButton = new Button("Send");
RootPanel.get().add(sendButton);
}
}
I have created my application istoeumtestedenome, and in localhost it works. I have deployed it to App Engine with no errors. But when I try to access the page http://istoeumtestedenome.appspot.com/, a 404 error is displayed.
What can I do?
There are many things that could have gone wrong. The first things that come to mind:
Your static HTML file (host page) is in the wrong place (folder).
You did not specify a welcome page - or there are some other problems - in your web.xml file.
Go to your Admin Console for App Engine, and click on the logs to see what goes wrong.
This is my first time working with GAE and I'm trying to get CDI working. Long story short: The #Inject field in my servlet is not getting injected (it's always null).
I'm working in Eclipse and debug the application on the local test server included in the GAE SDK (which is started by Eclipse as well). When I access the servlet on localhost, I get a null-pointer exception for someService. I've also output the value of someService to verify it is really null, which it is.
Edit: When I added a #Named("skldjfx") qualifier to the injection point, Weld complained the dependency is unsatisfied (in the validation phase), so that's a good sign. However, the field is still always null.
Servlet:
public class BlogServlet extends HttpServlet {
#Inject private SomeService someService;
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello. " + someService.getSomeValue());
// \
// always null
}
}
SomeService class:
#ApplicationScoped
public class SomeService {
private String someValue = "some value";
public String getSomeValue() {
return someValue;
}
}
I've configured Weld's Listener in web.xml:
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
The listener is properly loaded because it logs its initialization message: org.jboss.weld.environment.servlet.Listener contextInitialized.
I've included (an empty) beans.xml in both war/WEB-INF and war/META-INF. I also tried it without META-INF. Maybe beans.xml isn't processed? Other contents in the WEB-INF folder (such as web.xml) are processed properly.
How can I verify if beans.xml is processed and/or fix SomeService not getting injected?
It looks like it's not possible to use CDI with GAE, because GAE's Jetty fork ignores jetty-web.xml, which is needed to specify the BeanManager. See this link and this link. Really strange GAE is not supporting the use of CDI.
Note that these links are really old, but so far I haven't found any evidence to the contrary.
Anyway, my next step will be to use Google's own dependency injection framework Guice. Using it with GAE is described here. I'd prefer CDI though.