Jaxb in websphere - java

Hi I have developed the web application to marshall and unmarshall using JAXB. The web application is working in tomcat without any issues. But when I tried in Websphere 7.0.0.13 its returning null object.Please help me on this issue.

I had the same problem. Under this link is solution that help me.
What i did:
1. In the administrative console, click Applications > Application Types > WebSphere enterprise applications > app-name > Class loading and update detection.
2. Under Class reloading options, select Override class reloading settings for web and EJB modules .
3. Under Class loader order, select Class loader order property to Classes loaded with local class loader first (parent last).
4. Click OK, and then Save to save your changes.
After that:
1. In the Administration Console select Servers
2. Expand Server Type and select* WebSphere application servers *
3. Click on the name of your server
4. Expand Java and Process Management and select* Process Definition.*
5. Under the Additional Properties section, click Java Virtual
Machine.
6. Scroll down and locate the textbox for Generic JVM arguments.
ADD: -Djavax.xml.bind.JAXBContext=com.sun.xml.internal.bind.v2.ContextFactory
In the end restar web server and cluster.

WebSphere Application Server v7+ contains an optimized JAXB implementation that will often be used instead of the JAXB implementation that's built into the Java SDK. If you notice a difference in behaviour between WebSphere and Tomcat (or some other runtime) that is affecting your application, as a workaround you can often resolve the issue by setting the system property com.ibm.xml.xlxp.jaxb.opti.level=0 in WebSphere. Using this setting will cause the JAXB reference implemenation to be used for unmarshalling and marshalling instead of the WebSphere JAXB implementation.
More information on the com.ibm.xml.xlxp.jaxb.opti.level system property is available here.

Related

How do i create a data source in WebSphere Liberty via JMX

I am unable to find a code snippet for creating a datasource in Liberty via a Java Client. I looked up the ConnectionManagerMbean, but its documentation says that the Mbean instance wont be available until it is first used.
Can someone point me in right direction. I am kinda new to both Liberty and JMX so please bear with me if this sounds kinda rookyish.
Thanks in advance.
The reason you are unable to locate any examples of creating a Liberty data source via JMX is because it is not possible in Liberty to create data sources via JMX. In Liberty, data sources can be created via server configuration - the dataSource element - or via the #DataSourceDefinition annotation within an application component or <data-source> element within a deployment descriptor (such as web.xml) of an application.
Once you have created the data source, as you mentioned from the ConnectionManagerMBean documentation, you will need to use the data source first (access it from an application) before the MBean is made available. This aligns with Liberty's goals of having fast startup time and only loading/initializing what applications actually use. The behavior you observe sounds consistent with this, and you just need to perform an operation within your application first, and then you should hopefully be able to access the MBean.

Websphere Server Profile for different node and cell name

I'm relatively new to Websphere. I have created a WAS ( Websphere Application Server 8.5) profile configuration on local, manually from scratch which contains multiple data sources, queues, connection factories and activation specifications. ( Windows 7 PC). I backed this up using backupConfig.bat. I wish to replicate this profile configuration on another system where the Websphere Application Server (installation cannot be altered) has a different Node and Cell name. Is there a way where I can replicate it , without having to manually create the resources again,one-by-one , in the local WAS profile on the new system? When I googled this, it threw up the manageprofiles command, though I am not sure if it's backup option will work in my case. Thanks in advance.
If these are simple queues, datasource etc you can use Property based configuration - see Using properties files to manage system configuration.
You export configuration from one cell and import to the other.
If you have few elements you can use WebSphere Configuration Migration Tool (Eclipse plugin), which will allow you to select graphically which resources to move - it generates jython script that you can execute on target environment.

Loading data source for #DataSourceDefinition from application in Liberty

For usage with #DataSourceDefinition I'd like to have the DataSource class loaded from the application that uses this #DataSourceDefinition annotation (or equivalent data-source element in a deployment descriptor).
This works for basically every server as per the test I added in the Java EE 7 samples project.
For example, considering this data source definition in web.xml:
<data-source>
<name>java:app/MyApp/MyDS</name>
<class-name>org.h2.jdbcx.JdbcDataSource</class-name>
<url>jdbc:h2:mem:test</url>
</data-source>
The jar containing org.h2.jdbcx.JdbcDataSource would reside in WEB-INF/lib.
This is very convenient in CI testing when testing against a server that's automatically downloaded, and where the name of the deployed .war is unknown in advance (since controlled by say Arquillian).
While nearly every server supports this, Liberty 16.0.2 throws the following exception for either java:app/MyApp/MyDS or java:global/MyDS:
CWNEN0011E: The injection engine failed to process bindings for the
metadata due to the following error:
java.sql.SQLNonTransientException: J2CA8022E: Application xyz23-zvf does
not have any shared libraries that provide org.h2.jdbcx.JdbcDataSource
for dataSource java:global/MyDS.
The IBM instructions refer to setting up a shared library that lives on the local file system, but for several classes of data sources (e.g. those that only have internal meaning to the application), as well as for the mentioned CI testing this is not practical.
Is there any way to let Liberty load the data source from the application like most other Java EE servers do?

Coherence config default override path

I've already spent more than 2 days trying to make this work without any result. The server is WebLogic 12c with embedded Coherence server. It is important to mention that I do not run Coherence in standalone mode, instead it starts automatically alongside the application server that has access to Coherence via JNDI context. I am trying to implement POF serialization approach using PortableObject interface to serialize certain objects I save in Coherence. I've also created the corresponding pof-config.xml registering the objects I'm planning to serialize. The only problem is: How do I add the override to the coherence class path?
According to http://docs.oracle.com/cd/E24290_01/coh.371/e22837/gs_config.htm#COHDG5014 I can use the following system property:
java -Dtangosol.pof.config=MyPOF.xml -cp COHERENCE_HOME;COHERENCE_HOME\lib\coherence.jar com.tangosol.net.DefaultCacheServer
The only problem here is that I have no idea which sh/cmd file to edit, since all edits I made to the files in Oracle_Home\coherence\bin\ had no effect.
Also the same article says that there is a way to confirm the pof-config override:
The output for a Coherence node indicates the location and name of the POF configuration deployment descriptors that are loaded at startup. The configuration messages are among the messages that display after the Coherence copyright text is emitted and are associated with the cache service that is configured to use POF. The output is especially helpful when developing and testing Coherence applications and solutions.
Loading POF configuration from resource "file:/D:/coherence/my-pof-config.xml"
But I couldn't find any of the mentioned lines in the logs produced by the server instance.
Any ideas?
Instead of editing files inside of your Oracle_Home, try the following inside of the weblogic admin console:
Login to admin console
Servers link -> Server Name
Click the Server Start tab
Edit the Arguments: text box and add in -Dtangosol.pof.config=MyPOF.xml
You can also change the classpath, Class Path: box, here if you need to
Every time your server starts it should have that property. If you are not using the nodemanager to start your server, you should do the following instead. Keep in mind this will change the properties for every server in your weblogic domain:
Navigate to your <domain home>/bin directory
Edit startWebLogic.sh/cmd
Edit the JAVA_OPTIONS= line and add in -Dtangosol.pof.config=MyPOF.xml
You can also change the classpath CLASSPATH= here if you need to

Cannot debug Java Web application from Netbeans

I have a Java EE 5 application which consists of three web projects. I'm using JBoss 5.1 web server and NetBeans 7.2 IDE.
I have the following problems:
I cannot start application in Debug mode. That I know of, there are two (best) approaches in NetBeans and Java: Remote debugging and debugging via shared memory. I read this post How to debug JBOSS application in netbeans? and I set debug parameters in Jboss configuration(I also know there are different parameter sets for shared memory and remote debugging), but when I go to attach debugger I got following errors:
If I use remote debugging I got error "Connection refused";
If I use shared memory I got error similar to this text "dt_shmem:file path could not be found".
These errors occur when I start JBoss by running run.bat file. If I start JBoss from Netbeans IDE, I can attach to remote process (still have problem with shared memory approach), but then I have other problems, regarding variable primitives and model binding in page life cycle (I will not write about that now).
How can I solve these problems so I can debug application? At least, how can I find a better error message when it fails. I could not find too much on the Net by looking for "Connection refused" error only.
Why I cannot just press run main project(or web project) and that netbeans start application, open it in new browser tab(as localhost) and start debug mode? I'm coming from .net background and VS is offering this as out of the box tool (called ASP .NET development server). Why I have to use external web server and with every change deploy new application and then attach to it? Why Netbeans cannot by default use JVM for running application, and later when I deploy application I will choose which web server to use!?
I hope someone will make this clear to me :)
Thanks
added Note at 03.01.2013.
Well, when I changed VM options in project.properties file of web project (added run.args.extra=-J-Xms256m -J-Xmx756m), I succeeded to debug application and heat breakpoint when executing the code. However, I still have strange problem with Managed Bean properties. I have select list on page, and it is connected to Boolean property. When nothing is selected it should be set to null value by default (and it is when I start JBoss server by running run.bat file), but its value is by default set to false! I checked parameters post values in firebug and there is no problem in posting parameters to bean. It looks to me that problem is when JSF framework is trying to map post values to Managed Beans properties, but I cannot find out why this is happening. I also checked faces-config.xml, but did not find any specific rule for mapping to this specific property. Any tips?

Categories

Resources