How to debug web service with Eclipse Websphere liberty - java

First thing's first: I'm trying to develop an web service that is integrated with third party JCE(using Security.addProvider to use that jar which is packed into my WAR), but somehow when I deploy the WAR on my Websphere 8(with Java 1.8), it keep telling me that it cannot find the specified algorithm(AES) that I need unless I drag the JCE into Websphere's JRE and change its java security configurations.
Since I have no idea about the root cause, so I installed light-weighted websphere using the Eclipse's plugin install manager. Then I start the light-weighted server, select my web project and set it to debug on this server. But the Next screen I saw is "Context Root Not Found", even I changed the URL to the servlet.
I'm not familiar with WAS and it's liberty plugin, but isn't it suppose to run my project on it? like the Tomcat? Can anyone tell me how to run my WAR in it, so I can debug it? please?

First off, it looks like there is a misunderstanding on what Liberty is. When you say "light-weighted server" I'm assuming you mean Liberty, which is accurate -- Liberty is indeed a light-weight server.
However, WebSphere traditional and Liberty are two different products/servers. Liberty is not a plugin for WebSphere traditional.
A Java EE application running on WAS should behave very similarly to an application running on Liberty, because they are both Java EE compliant application servers. Since debugging and developing an application on Liberty will be easier/faster than on WAS, I would recommend using Liberty.
To debug your application on Liberty using the Eclipse WDT plugin:
Open eclipse with the WebSphere Developer Tools (WDT) plugin installed (you can get WDT here).
Follow this article to create a server using WDT. You can skip the parts about creating a sample application since you already have one.
Open the "Servers" view (using Window->Show View->Other...->Servers) and find your server:
Right click the server and do Add and remove... then add your application to the server
Set a breakpoint in your application code in Eclipse
Start the server in debug mode (by pressing the bug icon shown in step 3)
In the Eclipse menu, select Debug->Debug As->Debug on Server:

Related

Liferay IDE portlet changes not synchronized on the server

Platform
Liferay 6.2 EE Tomcat bundle deployed locally
Liferay 1DE - various version in the past 1 year
Liferay 6.2 EE plugins SDK
JDK 6 or 7
Mac OSX or Windows
Problem
We run into an issue intermittently with the Liferay IDE where a portlet java class changes are do show up the Tomcat server.
The setup is as follows:
A portlet is deployed on the server and is also configured to publish and synchronize on the local server (by drag and drop).
Any changes saved to any of the java class result in a expected publish to the server automatically without a need to do a ant deploy/ Liferay -> SDK -> deploy.
These changes can be seen in the browser after the publish
Intermittently, this automatic publish sync of the java classes does not work and the changes can't be seen in the browser.
Stopping and starting the server seem to have no effect.
Has anyone see this behavior?
I am working with a similar platform
Liferay 6.2 EE Tomcat bundle
Liferay Developer Studio 2.2.2
Liferay 6.2 SDK
JDK 7
Windows 10
To "synchronize" the changes in your IDE with your local server is about the way in which you deploy your portlet.
Although these initially steps are not explicitly necessary - I strongly recommend them for consistency
The first steps to clean your local environment
Stop the local server
Right click the server and clean
Empty your webapps folder leaving only root
Empty your temp folder
Remove all files and directories from tomcat-X.x.x/work/Catalina/localhost except _
Next open your local server settings by double clicking on your local server instance. In the top right corner you should see a publishing fold. Click to expand and select the following options
Automatically publish when resources change
Update context path
Under the Liferay Settings fold (bottom left) you should have the following setting selected
Development (portal-developer.properties)
Enabling Developer Mode turns off certain caching options that default to true when operating in standard mode. Despite the official documentation it does not eliminate the need "to redeploy to see your portal modifications".
Instead of direct deploying from ANT, right click on your server -> add -> then select your desired portlet
This creates a directory in webapps with your portlet similar to ANT direct deploy - this is the only way automatic publishing will work.
The problem above happened to a few of my team members local Liferay environments.
I have been able to work around this by following the steps below:
Undeploy the portlet by removing the portlet from the Tomcat home/webapps/ folder
Stop the Tomcat server Liferay IDE
Cleanup the temp folder under Tomcat home/tmp/ folder related the portlet in question
Start the tomcat server via the Liferay IDE
Deploy the portlet to the Tomcat server
The publish sync process seems to start to work after these steps.
I am not sure if there is a better solution.
Hope this helps someone.

Auto deploy changed java code in Maven, Eclipse, Glassfish

I am new very much new to maven and spring technologies. I want to know how can we auto deploy the java server code without rebuilding the maven or without restarting the glass fish server? Currently I have to restart the server if any change I do in java code. I have also use one option in Eclipse to "Automatically publish when resources change" but no use.
You may want to take a look at JRebel, it reloads changes made to your code instantly without having to restart your application server.
The recent version of HotSwap Agent works very well for me with Eclipse and Payara Server (server derived from and compatible with GlasFish).
It's free and opensource and supports Java 8, including lambdas. It supports reloading of resources in a webapp running on GlassFish/Payara, including JAX-RS annotations, CDI bean definitions etc., without restarting whole application.
The only drawback is that you need to install the DCEVM plugin into the JDK, which has to be activated by a command line argument -XXaltjvm=dcevm. But this isn't intrusive and doesn't affect your JDK if you avoid the argument - you can activate it just for GlassFish/Payara Server when you add it to the JVM options in the domain configuration. When adding the -XXaltjvm=dcevm option, you also have to remove -client and -server option, because they take precedence.
So, essentially these steps are needed with the recent version of HotSwap agent and practically with any version of GlassFish and Payara Server:
install DCEVM as altvm into the JDK (run the installer with admin rights)
copy the hotswap-agent.jar into lib/ext in your domain directory
add the following arguments as JVM options in your domain configuration: -XXaltjvm=dcevm -javaagent:/path/to/hotswap-agent.jar
run the server in debug mode from your IDE
in Eclipse, all works out of the box, just avoid using the Publish button for the server. Check that "Never Publish automatically" is checked in the server Overview, when you double click on the server in the Servers view
in Netbeans, you need to disable "Deploy on save" in project configuration and enable "Apply code changes after save" in global Java Debugger options
There is some information in this Payara issue, although it isn't an easy to follow guide. Some more info in this HotSwap issue.

How to run an OpenShift JBoss AS 7 app on localhost through Eclipse(Kepler)?

I tried to run an OpenShift JBoss AS 7 app through Eclipse as a normal JBoss AS 7 App but it doesn't seem to work. I have the OpenShift JBoss Tools installed in eclipse.
However when I try to run it through Run As --> Run on Server and then selecting the "jboss-as-7.0.1.Final Runtime Server" listed in the "Servers" view, I get the error
"the selection does not contain any resources that can run on a server".
To solve this I changed the project facet to Dynamic Web Module, then I again tried running it on JBoss server, but the application doesn't deploy and I get a 404 error on accessing its localhost url.
I also noticed that the JBoss Server's status in my eclipse "Servers" view is always shown as "Starting"(doesn't change to "Started"), although the Console shows something like "JBoss AS 7.0.1.Final "Zap" started in 2236ms"
Take a look at https://www.openshift.com/blogs/day-28-openshift-eclipse-integration-for-java-developers. That should point you in the right direction.
I am doing right now, what you want to do. I have a Project which is deployable on OpenShift and on my local installation of the jboss 7.1.
It is very strange that eclipse shows your jboss as always starting. I would recommend to delete the server in eclipse and try to add it again. Also you can add the project in the servers view. For that you right click your server and choose "Add and Remove...". You can choose the Project, add it to the server and eclipse is deploying it.
Which version of JBoss Tools are you running ? There have been some issues with detection of the server running in past where you can workaround this issue of the server not launching by changing the "Startup poller" to "web poller" or "timeout poller".
btw. if you needed to change your project to be a dynamic web project that indicates to me you have not actually imported the project as a maven project and had all of JBoss Tools installed (or at least M2e-wtp) which would normtally automatically make the import of the default openshift apps into a dynamic web project.

Setting up Eclipse and Glassfish offline

I have a Glassfish 3.1 server set up running on my development machine, and I'm trying to write a Java application that uses the OpenMQ JMS server built into Glassfish. I'm using Eclipse EE 3.6 for development (and have to as the application I'm developing is a plug-in for a Eclipse framework application - no changing to NetBeans!).
The problem is that my development machine isn't connected to the internet, so I can't download the Glassfish adapter from within Eclipse as told to do so in pretty much every online tutorial and guide I've found.
Is it possible to download the adapter on another computer, transfer it to the development machine, and install it into Eclipse 'offline'? And if so, how?
If adapter is available as a eclipse plugin(it must be available, if it can be updated via eclipse plugin update site) you can just download and keep it # eclipse_home/plugin folder and restart the eclipse.

Tomcat 6.0 and Eclipse. Multiple instances of the server behave differently

I have Tomcat 6.0 installation on my Win7 PC. I used 64/32bit windows installation.
In Eclipse I was able to set paths and set server to use my Tomcat installation. Everything seems working fine until I run server from inside Eclipse.
I noticed that http://localhost:8080/index.html page is not available (Tomcat default home page). I also can't access http://localhost:8080/axis2. I have Axis2 installed too.
Since I am struggling to make simple axix2 web service for long time, I am thinking maybe this Eclipse instance of Tomcat is adding to my issues?
When I start Tomcat from windows GUI everything works as I expect.
Any ideas?
Thanks.
Eclipse does by default not take control over the Tomcat installation and all of its pre-deployed webapps, instead it just uses its sole server engine and uses the workspace metadata as deploy space. When you start such a server configuration from inside Eclipse, all of the pre-deployed webapps will just be plain ignored, including Tomcat's default homepage.
To let Eclipse take control over the Tomcat installation, you need to doubleclick the Tomcat server entry in Servers view to get its configuration, then at the left column, under Server Locations, you need to select Use Tomcat installation (note, when it is grayed out, read the section leading text! It needs to be published without any projects).
Yes, this is normal. In the Package Explorer, you can click the Servers folder and view the configuration files that the Eclipse instance is using, specifically server.xml and context.xml. You can edit this configuration to match your specific requirements.
You may also want to check out the section titled Tomcat Publishing Options in this link here: http://www.eclipse.org/webtools/releases/2.0/newandnoteworthy/server.php
I favor this approach because when WTP inevitably corrupts my configuration once every two weeks, I don't have to reinstall Tomcat, I can just delete the server and reconfigure it.

Categories

Resources