I am migrating my RESTful web application from GlassFish4.1 to WildFly9.0 for the first time.
Initially, I suffered deployment issues due Jersey dependencies. To overcome that problem, I simply replaced said project dependencies with RESTEasy equivalents inside of the pom.xml file. In doing so, my application became deployable -- and according to (WildFly_base)/standalone/log, and the applications themselves -- are working as expected.
Additionally, I added a jboss-web.xml configuration file to my WEB-INF folder:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "http://www.jboss.org/j2ee/dtd" "http://www.jboss.org/j2ee/dtd/jboss-web_5_0.dtd">
<jboss-web>
<context-root>myprojectstart</context-root>
</jboss-web>
The hello-world page can be reached # http://ipaddress:8080/myprojectstart.
... however, I cannot view my web services # http://ipaddress:8080/myprojectstart/getData, just like I could when using GlassFish-4.1.
So; what am I missing?
Note: I use #annotations like:
#ApplicationPath("/*")
#Path("/getData")
No seperate .xml business here
I don't think RestEasy supports * in ApplicationPath. If you remove that it should work fine.
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!
There is an ear deployed into WebSphere WAS. It contains 3 portlets. I imported XML descriptor for this app to the WebSphere Portal and put the portlets on portal pages. It was working.
Unfortunately I removed one of the portlets from web modules in portal administration. Because of this portlet was removed from all pages also. I can't find the portlet in portlets list, so I can't put it to the pages again.
How can I reestablish the removed portlet to portal without uninstalling and deploying whole ear application to application server again.
I tried to import portlet XML to portal again. But it didn't help
UPDATE
here is the XML
<?xml version="1.0" encoding="UTF-8"?>
<request xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PortalConfig_7.0.0.xsd" type="update" create-oids="true">
<portal action="locate">
<web-app action="update" active="true" domain="rel" predeployed="true" removable="true" uid="kz.edu.nu.world.roomreservation.RoomReservationPortlet.4207700365webmod">
<url>file://localhost/opt/IBM/WebSphere/wp_profile/installedApps/Cell01/RoomReservationEAR.ear/RoomReservation.war</url>
<context-root>/.RoomReservation</context-root>
<display-name>.RoomReservation</display-name>
<portlet-app action="update" active="true" defaultlocale="en" domain="rel" name="kz.edu.nu.world.roomreservation.RoomReservationPortlet.4207700365" uid="kz.edu.nu.world.roomreservation.RoomReservationPortlet.4207700365">
<portlet action="update" active="true" defaultlocale="en" domain="rel" name="RoomReservation" provided="false">
<localedata locale="en">
<title>RoomReservation</title>
</localedata>
<localedata locale="ru">
<title>RoomReservation</title>
</localedata>
<localedata locale="kk">
<title>RoomReservation</title>
</localedata>
</portlet>
</portlet-app>
</web-app>
</portal>
</request>
Sorry to be the bearer of bad news, but you will need to update the ear. I don't think you have to uninstall the ear, just update it and import xml again.
Is it possible to override the root context specified in WEB-INF/jboss-web.xml at deploy time?
I have this jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<context-root>my-context</context-root>
</jboss-web>
And I want to be able to deploy the application with different root context in in e.g. /another-context for some of my environments, but keep /my-context in other environments.
You can do this via WildFly Maven Plugin (as part of your CI job) or using the WildFly CLI.
The maven variant would be like the following command:
org.wildfly.plugins:wildfly-maven-plugin:deploy-only
-Dwildfly.deployment.filename=app.war
-Dwildfly.deployment.runtime.name=appcontext.war
The app will be deployed under /appcontext.
Note, you should remove the context-root from your jboss-web.xml otherwise this value will win always.
The CLI variant could look like (documentation):
[dply#as wildfly-8.2.0.Final]$ bin/jboss-cli.sh
You are disconnected at the moment. Type 'connect' to connect to the server or 'help' for the list of supported commands.
[disconnected /] connect
[standalone#localhost:9990 /] deploy /path/to/app.war --runtime-name=appcontext.war
For doing this, you could combine maven profiles (e.g. "my-context" and "another-context") and maven resource filtering as explained here: Maven resource filters
It certainly takes a little bit of time until everything works as expected.
if you have a EAR file you need to define it at your application.xml
<module>
<web>
<web-uri>webapp.war</web-uri>
<context-root>/my-context</context-root>
</web>
</module>
I have created a EJB, created a jar of it( containing required ejb-jar.xml and weblogic-ejb-jar.xml files).
when i add this jar to weblogic server 12c, using admin console, i get following issue-
Issues were encountered while parsing this deployment to determine module type. Assuming this is a library deployment.
Due to this my ejb is not shown in jndi tree view. So I am not able to do my jndi lookup. Please rectify my error.
ejb-jar.xml-
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>ProductManager</display-name>
<enterprise-beans>
<session>
<ejb-name>Product</ejb-name>
<home>rohit.ProductHome</home>
<remote>rohit.ProductRemote</remote>
<ejb-class>rohit.ProductBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<ejb-client-jar>ProductManagerClient.jar</ejb-client-jar>
</ejb-jar>
weblogic-ejb-jar.xml-
<?xml version=“1.0? encoding=“UTF-8??>
<weblogic-ejb-jar
xmlns=“http://www.bea.com/ns/weblogic/90? xmlns:j2ee=“http://java.sun.com/xml/ns/j2ee” xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=“http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd”>
<welogic-enterprise-bean>
<ejb-name>Product</ejb-name>
<jndi-name>Product</jndi-name>
<stateless-session-descriptor></stateless-session-descriptor>
</welogic-enterprise-bean>
</weblogic-ejb-jar>
Contrary to what you seem to be thinking, the ejb-jar.xml and weblogic-ejb-jar.xml files are not required. As primary deployment descriptors they are ancient artifacts from 2004.
Your ProductHome class should also be removed if you value your sanity. This is an EJB2 artifact that's completely and utterly unnecessary this time of age.
To get started with EJB, all you need is a POJO with an #Stateless annotation:
#Stateless
public class ProductBean {
// ...
}
Jar this up and deploy it. That's all. You don't have to explicitly name your bean (it will get a name) and you certainly don't have to declare its existence in some XML file.
The ejb-jar.xml is mandatory when deploying an application as a jar file. The correct place to put it is in the META-INF in the jar.
Yes, annotations are definitely nice and easier to maintain. Try this by leaving the ejb-jar.xml minimal.
I always package my applications in EAR with the jars inside. In this case an application.xml file is needed.
It sounds like the container does not recognize the jar as an application. Check the position of the ejb-jar.xml or use EAR packaging.
Oracle recommends that even standalone EJBs be packed as an EAR file. The EJB descriptors should be inside the META-INF of the ejb-module.
See this link for the EAR structure for more details.
http://docs.oracle.com/cd/E24329_01/web.1211/e24368/splitcreate.htm#i1103260