During EJB project creation in eclipse, it created following projects
MyEjbProj
MyEjbProjClient
MyEjbProjEAR
The interfaces and implementations are created in 'MyEjbProj'. The MyEjbProjClient suppose to have interfaces which can be shared to the clients. How to generate/retrieve the jar which can be given to the Clients to use the interfaces.
It should be creating interface in client project only. I have same setup and Eclipse does create interfaces in client project for me. Problem should be either with your facets settings or with module settings. Check following things:
Are you selecting EAR and Client project option while creating EJB project.
If answer of above question is yes, then check if client and EJB project are shown in deployment assembly settings of EAR.
Check if client project have correct facets settings. It must have Java and Utility 2.0 facets.
Check if ejb-jar.xml file contains an entry specific to client project. See in following example I have tag with name of client project:
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd" version="3.1">
<display-name>TestEJB </display-name>
<ejb-client-jar>TestEJBClient.jar</ejb-client-jar>
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.
There are some libraries in ORACLE_HOME/oracle_common folder which are creating issues with our deployment (EAR). (in particular jps-ee.jar file).
How do I overwrite my weblogic server (not via web.xml) to not use the libs available (particularly jps-ee.jar) for my EAR Deployment.
We need to disable it from the weblogic end so that we can test that , this jps-ee.jar is the root cause of our issue.
So how can we do it from the weblogic end ?
And docs or steps by step guide ?
Found solution to this problem, weblogic is configured to use oralce_common using setDomainEnv.sh (or setDomainEnv.cmd based on OS)
/%ORACLE_HOME%/Middleware/user_projects/domains/%WEBLOGIC_DOMAIN%/bin/setDomainEnv.sh
This file defines the class path to be used for starting up a domain.
This file is called in by startWeblogic script to set up domain related settings.
Which loads the class paths and pass it to JVM when running the weblogic server.
If you want the weblogic server to start looking for some dependency packages from your ear/war file first, then you must use application.xml or weblogic.xml depending on whether your archive is an ear or a war.
Here is an example;
application.xml
<?xml version = '1.0' encoding = 'UTF-8'?>
<weblogic-application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-application http://www.bea.com/ns/weblogic/weblogic-application/1.0/weblogic-application.xsd" xmlns="http://www.bea.com/ns/weblogic/weblogic-application">
<prefer-application-packages>
<package-name>oracle.toplink.*</package-name>
<package-name>oracle.sql.*</package-name>
<package-name>oracle.jdbc.*</package-name>
</prefer-application-packages>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
<weblogic-version>12.1.3.0.0</weblogic-version>
<context-root>sth</context-root>
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>oracle.toplink.*</package-name>
<package-name>oracle.sql.*</package-name>
<package-name>oracle.jdbc.*</package-name>
</prefer-application-packages>
<prefer-application-resources>
</prefer-application-resources>
</container-descriptor>
prefer-application-packages and prefer-application-resources are the two tools you can use for this purpose in weblogic environments. Weblogic first uses these packages in your archive file when looking a class and if not found, then it uses its embedded dependencies.
Good luck!
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!
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.
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