In my GWT project running in glassfishv3, everything is worked properly, but when I change my servlet url patterns mapping from web.xml to #WebServlet annotation inside servlet classes, GWT rpc cand find the servlet!
note that, other usual servlets work with this annotation(WebServlet) and just GWT RPC doesnt work.
what is the reason?
RGDS
Did you set the version number of web-app in the web.xml to the correct servlet version, because this feature is available only since 3.0:
<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_3_0.xsd"
version="3.0">
Ok, I finally got this working but with some caveats. I was able to get it working in Tomcat within Intellij and as a deployed WAR to a Tomcat 7 container.
I was NOT able to get it working in dev-mode without using -noserver. I believe this is because the built-in Jetty server is not JSR315 compatible but have no evidence of this as I've not tried to determine what version of jetty is in the gwt-dev jar.
The trick is you need to fully qualify the path in WebServlet. So if your remote service interface has the relative path of "bar" and your module name (rename-to in gwt.xml) is "foo" then the path you need to set the path of "/foo/bar" in WebServlet and it will work.
Related
I'm trying to implement a simple login using Spring Security (I'm a newbie in Spring Security). I've started with Spring Security reference that contains a simple "Hello world" example (link). I've prepared a web project in Eclipse (with EAR project), file structure looks like this:
SecurityConfig and SecurityWebApplicationInitializer classes are identical to those in a link above ("Hello world" example). I've also added Log4j 2 configuration file and home page (login.xhtml) that (for now) just prints "test". Later it will be used as a custom login page.
web.xml contains only a welcome-file element:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>SpringSecurity</display-name>
<welcome-file-list>
<welcome-file>pages/login.xhtml</welcome-file>
</welcome-file-list>
</web-app>
EAR's deployment assembly looks like this:
When I deploy my EAR on a JBoss AS 7.1.1, there's no error, but when I access http://localhost:8080/SpringSecurity, my home page is displayed normally.
I'm guessing that the configuration above should generate a default login page. When I access my home page, that login page should appear, right? It looks like that Spring Security is not even loaded and there's no protection when accesing my home page.
I don't really understand why is this simple example not working. Any help?
I do not have JBoss on my machine currently. But I was able to deploy this example on tomcat.
The issue certainly is that the war classloader is not able to see the spring jars at runtime.
There can be two possible solutions to resolve this.
If the spring jars are only required by war module (not by any other module in the ear), then you can shift these spring jars from ear's lib directory to war's WEB-INF/lib directory.
If the spring jars are also required by the other modules than you can to explicitly set the Class-Path entry in the MANIFEST.MF file of the war and the other modules that require these jars in a portable way.
e.g.
Manifest-Version: 1.0
Class-Path: lib/spring-beans-4.3.9.RELEASE.jar lib/spring-context-4.3.9.RELEASE.jar
Add all the required jars in this way separated by sapce (' ').
Note:- I used following jars to make this example run.
spring-aop-5.0.2.RELEASE.jar
spring-beans-5.0.2.RELEASE.jar
spring-context-5.0.2.RELEASE.jar
spring-core-5.0.2.RELEASE.jar
spring-expression-5.0.2.RELEASE.jar
spring-jcl-5.0.2.RELEASE.jar
spring-security-config-5.0.0.RELEASE.jar
spring-security-core-5.0.0.RELEASE.jar
spring-security-crypto-5.0.0.RELEASE.jar
spring-security-web-5.0.0.RELEASE.jar
spring-web-5.0.2.RELEASE.jar
And with this version of spring and spring-security you may have to make a small change in your code.
User.withDefaultPasswordEncoder().username("user").password("user").roles("USER").build();
or
User.withUsername("user").password("{noop}user").roles("USER").build();
Refer - Spring Boot PasswordEncoder Error for more details about the code change required.
I have a weblogic server with a cluster of two SOA servers.
I am deploying a servlet to this server with a SOAP servlet created with the JDeveloper wizard (Create Java Web Service from WSDL -> Java EE 1.5, with support for JAX-WS Annotations)
It is deployed as a standalone application.
During the development of the application I have changed the WSDL in various ways including changing the port name.
I have gone into the weblogic interface, deleted the previous instalisation and re-deployed through JDeveloper. I get the following error message:
[08:44:59 PM] weblogic.management.DeploymentException: Error encountered during prepare phase of deploying WebService module 'RJMTestBannerAdapter.war'. Two port in the callBannerService(WebserviceDescriptionBean) has the same name {http://ic.ac.uk/AIAMetaData/AIAComponents/ApplicationObjectLibrary/Banner/V1/APIJavaAdapter/BannerAPIJavaAdapterWsdl}callBanner.
It is complaining that there is two ports in the application with the same name. But there isn't.
I have inspected the .war file that JDeveloper produces
The WEB-INF/web.xml has a single entry for the service
The WEB-INF/weblogic.xml is also correct and just specifies the context-root.
I have determined that somewhere in the weblogic servers there must be something with the end point that is not being cleared away when I delete the application.
I have checked the weblogic console user interface, gone through the list of web applications and services and confirmed it is not there.
Does the weblogic server have a deployment plan file or something simular it is picking up while deploying? If so where would this deployment plan be?
I don't think it is important but here is my web.xml:
<?xml version = '1.0' encoding = 'UTF-8'?>
<web-app 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"
xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
<servlet-name>callBanner</servlet-name>
<servlet-class>ic.ac.uk.ic.rjmtest.banner.adapter.gen.main.Main_ptImpl12</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>callBanner</servlet-name>
<url-pattern>/callBanner</url-pattern>
</servlet-mapping>
</web-app>
Also this is the weblogic.xml that appears in the war file. (It is not in my project but JDeveloper must generate it)
<?xml version = '1.0' encoding = 'UTF-8'?>
<weblogic-web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app">
<context-root>RJMTestBannerAdapter</context-root>
</weblogic-web-app>
I have also inspected the WSDL and there is only a single port.
I finally found the answer.
When I used JDeveloper to regenerate the classes for the service I must have changed the name somehow. This resulted in new java being built.
As I didn't delete the classes or deploy directory the old ones were still there in my war file. So I was trying to deploy two even though my .java files didn't reflect this.
Deleting the classes and deploy directories then recompiling resolved the issue.
This post might be useful for anyone else who hits this error!
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.
I have an EJB3 project to be deployed on JBoss 5.1.0 GA. I have Stateless EJBs being injected into other Stateless beans and Servlets.
I'm using the #EJB annotation without any parameters to inject the EJB beans, (i have a test project just to simulate the injection, which works).
When i try deploying i get the error below.
"Caused by: java.lang.RuntimeException: java.lang.IllegalStateException: Resolution should not happen via injection container"
I have searched but can't seem to find/pinpoint the cause of the error.
Update: 1
Both the EJB jar and WAR are deployed in the same EAR. I'm using the JEE5 archtype, http://code.google.com/p/javaee5-maven-archetype/ to create both the main project and test. The default code generated by the archtype works, and there is no need to specify the JNDI name in the #EJB injection.
Update: 2
The full deployment stacktrace, http://pastebin.com/CknXie13
Here's an oft overlooked gotcha: Make sure that you use the name of the Local Interface and not the implementation when declaring the class type of the EJB in the servlet or web service. So, the mappedName in JBOSS will point to the jndi binding for the implementation while the class type in the declaration will point to the interface. For example:
#EJB(mappedName="Foo/EmployeeManagerBean/local")
EmployeeManagerLocal manager;
Gotcha #2: Make sure that you are compiling with Java 1.6 or higher. This can be tricky in Eclipse. You have to check three places in Project->Properties to make sure: Project Facets, compiler compliance settings, and the build path.
Use the mappedName attribute of #EJB annotation, while injecting into the servlet
The attribute should contain the jndi name of the ejb.
Please check your web.xml version. Version 2.4 or earlier does not support dependency injection.
Here is the sample excerpt of version="2.5"
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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">
Are you putting your servlet in .WAR file? Put your servlet in .WAR file and your bean in .JAR file. Create and ear file and then deploy it
Known Issue;
http://community.jboss.org/message/8196#8196
https://jira.jboss.org/browse/JBAS-6332
I need to create a startup class in Websphere. This class is present in abc.jar. And also abc.jar requires log4j.jar at startup of server.
For above scenario, i have created the startup class with abc.jar in classpath in websphere console and I kept log4j.jar in ext folder of WAS. This works for me.
But problem is that the other profiles share same ext folder of WAS and does not able to start up due to Log4j.jar.
If I keep Log4j.jar in other place and keep that location in classpath. Startup class will not fails.Please help me.
If your application uses EJBs, then you can use a peculiar feature of WAS with the ibm-ejb-jar-ext.xml descriptor, which includes a start-at-app-start element:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-ext
xmlns="http://websphere.ibm.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-ext_1_1.xsd"
version="1.1">
<session name="TestBean">
<start-at-app-start value="true"/>
</session>
</ejb-jar-ext>
I'm not very familiar with WebSphere and maybe I do not fully understand your problem - but how about deploying a webapp with a startup servlet defined in web.xml?
Here's what I mean:
create a abc.war with abc.jar and log4j.jar copied to abc.war/WEB-INF/lib
define your startup class in abc.war/WEB-INF/web.xml as follows:
<web-app id="WebApp">
<display-name>abc.war</display-name>
<servlet>
<servlet-name>ABCStartupServlet</servlet-name>
<display-name>ABCStartupServlet</display-name>
<servlet-class>abc.ABCStartupServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
...
That way you have log4j.jar and abc.jar together in one place, you can use the WebSphere classloader settings if another log4j version causes problems and your class is called during the startup of the server.