Quantcast
Channel: Java mon amour
Viewing all 1124 articles
Browse latest View live

weblogic.utils.StackTraceDisabled.unknownMethod()

$
0
0
in recent (>= 12.1.2 ) versions of WLS, as stated in Oracle Doc ID 1624363.1:
"In production mode of WLS 12.1.2, the full Java exception stack trace is not returned to the ejb caller when an exception is thrown."
so all you get on the client is a "weblogic.utils.StackTraceDisabled.unknownMethod()"
Just add -Dweblogic.PrintStackTraceInProduction=true (I guess both on the client and on the server, if they are on different WLS instances...)

Java Mission Control JMC video training

$
0
0
Very good overall coverage of JMC features





Online Java Thread Dump Analyzer

org.eclipse.persistence.indirection.IndirectSet locking

$
0
0
one has to be careful with Lazy loading of entities (i.e. INDIRECTION)

http://grepcode.com/file/repo1.maven.org/maven2/org.eclipse.persistence/eclipselink/2.5.1/org/eclipse/persistence/indirection/IndirectSet.java#IndirectSet.getDelegate%28%29

in fact the getDelegate() code contains a synchronized clause, so one can easily end up in a series of blocked threads like the one below waiting on lock 0x0000000785157eb8 :


"[STUCK] ExecuteThread: '33' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f93100206f0 nid=0x17fc waiting for monitor entry [0x00007f9384ecb000]
java.lang.Thread.State: BLOCKED (on object monitor)
at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:373)
- waiting to lock <0x0000000785157eb8> (a org.eclipse.persistence.indirection.IndirectSet)
at org.eclipse.persistence.indirection.IndirectSet.hashCode(IndirectSet.java:419)
at java.util.WeakHashMap.hash(WeakHashMap.java:365)
at java.util.WeakHashMap.getEntry(WeakHashMap.java:494)
at java.util.WeakHashMap.containsKey(WeakHashMap.java:485)
at org.apache.commons.lang.builder.ToStringStyle.isRegistered(ToStringStyle.java:162)
at org.apache.commons.lang.builder.ToStringStyle.appendInternal(ToStringStyle.java:461)
at org.apache.commons.lang.builder.ToStringStyle.append(ToStringStyle.java:435)
at org.apache.commons.lang.builder.ToStringBuilder.append(ToStringBuilder.java:851)
at org.apache.commons.lang.builder.ReflectionToStringBuilder.appendFieldsIn(ReflectionToStringBuilder.java:606)
at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:765)
at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:287)
at org.apache.commons.lang.builder.ReflectionToStringBuilder.toString(ReflectionToStringBuilder.java:153)



"[STUCK] ExecuteThread: '50' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f931003e400 nid=0x2d37 runnable [0x00007f9371cf9000]
java.lang.Thread.State: TIMED_WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:349)
at com.lmax.disruptor.MultiProducerSequencer.next(MultiProducerSequencer.java:133)
at com.lmax.disruptor.MultiProducerSequencer.next(MultiProducerSequencer.java:102)
at com.lmax.disruptor.RingBuffer.next(RingBuffer.java:207)
....
at org.eclipse.persistence.logging.JavaLog.internalLog(JavaLog.java:290)
at org.eclipse.persistence.logging.JavaLog.log(JavaLog.java:261)
at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:3491)
at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4731)
at org.eclipse.persistence.internal.sessions.AbstractSession.log(AbstractSession.java:4705)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1839)
at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1786)
at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:129)
at org.eclipse.persistence.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:116)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
- locked <0x00000007811573d8> (a org.eclipse.persistence.internal.indirection.QueryBasedValueHolder)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiateImpl(UnitOfWorkValueHolder.java:173)
at org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:234)
at org.eclipse.persistence.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:89)
- locked <0x0000000785157ee8> (a org.eclipse.persistence.internal.indirection.UnitOfWorkQueryValueHolder)
at org.eclipse.persistence.indirection.IndirectSet.buildDelegate(IndirectSet.java:211)
at org.eclipse.persistence.indirection.IndirectSet.getDelegate(IndirectSet.java:375)
- locked <0x0000000785157eb8> (a org.eclipse.persistence.indirection.IndirectSet)
at org.eclipse.persistence.indirection.IndirectSet.hashCode(IndirectSet.java:419)
at java.util.WeakHashMap.hash(WeakHashMap.java:365)
at java.util.WeakHashMap.getEntry(WeakHashMap.java:494)
at java.util.WeakHashMap.containsKey(WeakHashMap.java:485)




My 2 cents: LAZY loading should NOT be really the default, unless you REALLY have performance issues (I know, EclipseLink site says the opposite). The effect of loading an object ANYWHERE in your code, while you are for instance in the middle of doing logging, can be really disruptive.

ThreadLogic!

Umlaut in emails

$
0
0
If in an email you see f�r instead of für, chances are that your weblogic/JavaMail is not using the right encoding (presumably UTF-8)

You can try several options:

-Dfile.encoding=UTF-8
change the template to use escaped (HTML) charachers
see https://issues.apache.org/jira/browse/GERONIMO-5022 :
message.setSubject(subject,"UTF-8");
message.setText(text, "UTF-8");
properties.setProperty("mail.mime.charset","UTF8");




Struts 1.2 in WebLogic 12.1.3, german characters encoding issue

$
0
0
"As of WebLogic Server 12.1.3, the default value of the encoding element for the jsp-descriptor element in weblogic.xml is UTF-8 for JSP pages. Prior to WebLogic Server 12.1.3, the default value for JSP encoding was ISO-8859-1."
If you have issues

1) Add <%@ page contentType="text/html;charset=UTF-8" %> line on top of every jsp page.

2) Add
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

In pom.xml

3) Add
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<mime-mapping>
<extension>jsp</extension>
<mime-type>text/html;charset=UTF-8</mime-type>
</mime-mapping>
In web.xml

4) Add
<jsp-config>
<jsp-property-group >
<url-pattern>*.jsp</url-pattern>
<page-encoding>UTF-8</page-encoding>
</jsp-property-group>
</jsp-config> in web.xml –

5) Add <constant name="struts.i18n.encoding" value="UTF-8"/> In struts-config.xml


6) change text encoding to UTF-8 in the properties file.

7) Add the below to your weblogic.xml.

<charset-params>
<input-charset>
<resource-path>/*</resource-path>
<java-charset-name>ISO8859-1</java-charset-name>
</input-charset>
</charset-params>


(see oracle Support "Default JSP Encoding Changed to UTF-8 (Doc ID 2053210.1)" )

(it should be ISO8859-1, not ISO8859_1)

Also, to determine which encoding you are actually using, check in your html for "<meta http-equiv="content-type" content="text/html; charset=utf-8" />" . And in the browser (IE in my case) you have a menu "view-encoding"...

javax.net.ssl.SSLHandshakeException: Server chose unsupported or disabled protocol: SSLv3

$
0
0
If you get this error message "javax.net.ssl.SSLHandshakeException: Server chose unsupported or disabled protocol: SSLv3",
chances are that your JVM, for vulnerability issues connected to SSLv3, is configured to disable this protocol.
If you REALLY need to support SSLv3, check which file you are using for -Djava.security.properties=/path/to/yourfile, then edit yourfile and make sure your property:
jdk.tls.disabledAlgorithms=SSLv3, DH keySize < 768
doesn't contain SSLv3 (make it jdk.tls.disabledAlgorithms=DH keySize < 768)

Happy 2016 to all JMA readers

BEA-2165021 ResourceManagement is not enabled in this JVM

$
0
0
Starting WLS 12.2.1 with a JDK 8 I get this INFO message:

<Info> <RCM> <BEA-2165021> <"ResourceManagement" is not enabled in this JVM. Enable "ResourceManagement" to use the WebLogic Server "Resource Consumption Management" feature. To enable "ResourceManagement", you must specify the following JVM options in the WebLogic Server instance in which the JVM runs: -XX:+UnlockCommercialFeatures -XX:+ResourceManagement.>

here https://docs.oracle.com/javase/8/docs/technotes/tools/enhancements-8.html they say "##The options -XX:+ResourceManagement and -XX:ResourceManagementSampleInterval=value have been added. Resource Management is a commercial feature."

I think this has nothing to do with the try-with-resources clause.

Euphemistically speaking, there doesn't seem to be lot of documentation on this -XX:+ResourceManagement flag...

File.getName() in windows and Unix

java.net.ProtocolException: Did not meet stated content length of OutputStream

$
0
0
We were getting this error:

java.net.ProtocolException: Did not meet stated content length of OutputStream: you wrote 139 bytes and I was expecting you to write exactly 153 bytes!!!
at weblogic.net.http.ContentLengthOutputStream.close(ContentLengthOutputStream.java:52)
at java.io.FilterOutputStream.close(FilterOutputStream.java:160)



There are a number of posts suggesting that one needs to change encoding.... also the Oracle doc "ProtocolException is thrown if multibyte characters is specified for HttpServletResponse.sendError method (Doc ID 1902525.1)" suggests the same.
However in our case upgrading the JVM fixed the issue. Probably the communication was happening between 2 versions of JVM using a different serialization strategy, who knows....
Thanks to Andrea for the resolution.

BEA-110433 Unable to obtain ownership of the transaction log

$
0
0
If you see "BEA-110433 Unable to obtain ownership of the transaction log", then


<Jan 12, 2016 3:41:57 PM CET> <Error> <JTA> <BEA-110433> <Unable to obtain ownership of the transaction log.>
<Jan 12, 2016 3:41:57 PM CET> <Critical> <JTA> <BEA-111009> <activateDeployments failed during initialization. Failing reason:
weblogic.server.ServiceFailureException: Cannot get ownership of Transaction Log. Make sure that the Transaction Recovery Migratable Service is migrated back to the current server before restarting it.

weblogic.server.ServiceFailureException: Cannot get ownership of Transaction Log. Make sure that the Transaction Recovery Migratable Service is migrated back to the current server before restarting it.
at weblogic.transaction.internal.TransactionRecoveryService.checkTransactionLogOwnership(TransactionRecoveryService.java:408)
at weblogic.transaction.internal.TransactionRecoveryService.resume(TransactionRecoveryService.java:183)
at weblogic.transaction.internal.TransactionRecoveryService.initialize(TransactionRecoveryService.java:443)
at weblogic.transaction.internal.StartupClass.main(StartupClass.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Truncated. see log file for complete stacktrace
>



then check your transaction-log-jdbc-store in the config.xml, make sure it's the same datasource used by data-source-for-automatic-migration, the auto-migration-table-name should be ACTIVE_SINGLETON_SERVICES, then drop this table and build it again with

CREATE TABLE ACTIVE_SINGLETON_SERVICES (
SERVER VARCHAR2(150) NOT NULL,
INSTANCE VARCHAR2(100) NOT NULL,
DOMAINNAME VARCHAR2(50) NOT NULL,
CLUSTERNAME VARCHAR2(50) NOT NULL,
TIMEOUT DATE,
PRIMARY KEY (SERVER, DOMAINNAME, CLUSTERNAME)
) ;


The root cause of this issue is often that the WLS servers are killed by operators rather than being "gracefully shutdown" as recommended by Oracle. For instance this happens when the Server is in Overload condition and the Graceful Shutdown times out (by default after 120 s). Thanks to Carlo for the explanation.

BEA-110503 JTA migration policy : The migrator is not available

$
0
0
We see this Warning message in the logs

<Warning> <JTA> <BEA-110503> <The migrator(the AdminServer for manual JTA migration policy, or the Singleton Master for automatic JTA migration policy) is not available. Will skip JTA TRS failback because isStrictOwnershipCheck is [false]. This may lead to potencial TLOG corruption if TRS of myserver has been migrated to backup server and the backup server is accessing the TLOG of myserver . More safety can be achieved by setting isStrictOwnershipCheck to [true].>

https://docs.oracle.com/cd/E24329_01/web.1211/e24425/service_migration.htm#CLUST286 here an explanation of the Service Migration Policy

"TRS" is JTA Transaction Recovery Service "The Transaction Recovery Service automatically attempts to recover transactions on system startup by parsing all transaction log records for incomplete transactions and completing them. "

isStrictOwnershipCheck http://docs.oracle.com/cd/E14571_01/apirefs.1111/e13945/weblogic/management/configuration/JTAMigratableTargetMBean.html#isStrictOwnershipCheck%28%29



I will elaborate more once I find out more.

X11 tunneling with Tectia SSH client

$
0
0
https://support.ssh.com/manuals/client-user/61/client-tunnel-x11.html

Do "Edit/Tectia Connections"



ssh-broker-config.xml is in several places, verify that all files contains this

<server-banners visible="yes" /> 
<forwards>
<forward type="x11" state="on"/>
<forward type="agent" state="on"/>
</forwards>


the files are:

  C:\Documents and Settings\PIPPO\AppData\Roaming\SSH\
29.09.15│ 5728│AI │ssh-broker-config.xml
C:\Documents and Settings\PIPPO\Application Data\SSH\
29.09.15│ 5728│AI │ssh-broker-config.xml
C:\Users\PIPPO\AppData\Roaming\SSH\
29.09.15│ 5728│AI │ssh-broker-config.xml
C:\Users\PIPPO\Application Data\SSH\
29.09.15│ 5728│AI │ssh-broker-config.xml


Unhappy with your work? You can change!

$
0
0
before and after


An ex-colleague of mine - a woman - moved from an engineering job to a health sector job - earning a very difficult university degree - at the age of 50.

I have always thought that engineering work is mainly for males, because males are good at shooting and hunting while females are more oriented to social work. And even that it takes a special kind of males, mostly unsympathetic, unemotional, un-compassionate, uninterested in the world... to be happy about staring a computer screen the whole day, it takes rather dull people. So I always encourage everybody that I like in IT to quit this job.

I have asked a few questions:

Q: have you always disliked engineering or it took you some time to mature this feeling?

A: It took me a while. At the beginning I was enjoying making many fun calculations , it was making me feel smart... Then gradually the doubt emerged that all this was totally useless. but as long as I was having fun, the doubt was being removed. Then I started having less fun, but anyway I liked the people I was working with, so things were still going decently. Then I went into the phase where I was saying "well, maybe it's useless, but at least it's useful to me, to make a career etc. Also this last illusion died and I have eventually understood: OK it's useless and I don't like it.

Q: which events have pushed you to the decision to change job?

A: a thousand reasons, it's not at all clear to me... I would need a psychologist to understand it

Q: among your university colleagues, have you been treated with diffidence due to the age difference? How about the teachers?

A: with my school mates, after a first phase or embarassment (mine) and diffidence (their) I have been very warmly welcome, with sincere admiration and almost affection. With some of them I have matured a true friendship. The teachers have always treated me with fairness, if they had curiosity about me they have hidden it very well. As far as I am concerned I have always been very discrete about my strange condition.

Q: what advice would you give to women who find themselves doing a job "sterile" as Engineering or IT? To ignore the uneasiness and expect it to go away one day and you will get used? or rather "listen to your heart, he knows what is best for you"?

A: To my children I have always told to listen to their heart and be answerable only to themselves. In fact one is now in Australia working as a waiter, the other is a sportsman, the little one wants to be a Natural Park Guard to protect the animals on the mountains. They don't seem to be unhappy.

Q: what is your opinion about Engineers, compared to other professions?

A: I don't think anything. I think you can't generalize. A bit conceited, yes they are.

Q: how do you compare the world of Health Care with the world of Engineering?

A: in the hospital, everybody works VERY hard...from the chief of surgery to the last of the students. Outside of the hospital, it's all the same...

rpm

$
0
0

This is to list the content of a rpm file without installing it:
rpm -q -filesbypkg -p filename.rpm

Same classloader for EJB and WAR

$
0
0
https://docs.oracle.com/middleware/1212/wls/WLPRG/classloading.htm#WLPRG293

you can alter the weblogic-application.xml with this


<classloader-structure>
<module-ref>
<module-uri>ejb1.jar</module-uri>
</module-ref>
<module-ref>
<module-uri>web1.war</module-uri>
</module-ref>
</classloader-structure>


however it's recommended to either put your shared classes in APP-INF/lib, or remove circular dependencies if any

Singleton service in cluster to consume JMS messages with disaster recovery

$
0
0
"We consume messages from a (MQ) queue
We have two servers. One is the primary and consumes the messages. The secondary does not normally consume messages.
If the primary server falls over (DR), then the secondary should start consuming the messages.
How to implement this?
"

register a custom Singleton service (message listener) on a cluster, as JMS listener of the Queue, with automated migration: assign it by default to a specific instance: if this instance fails, the singleton is reassigned to another instance. Automated migration is ensured by the DB leasing mechanism.

http://docs.oracle.com/cd/E24329_01/web.1211/e24425/service_migration.htm#CLUST373
https://docs.oracle.com/middleware/1212/wls/WLACH/taskhelp/clusters/ConfigureSingletonService.html
http://docs.oracle.com/cd/E24329_01/apirefs.1211/e24391/weblogic/cluster/singleton/SingletonService.html
http://developsimpler.blogspot.ch/2012/03/weblogic-clusters-and-singleton-service.html

EJB and JNDI, or how to lookup a EJB from a JSP

$
0
0


package ejb3.bean;

import javax.ejb.LocalBean;
import javax.ejb.Stateless;

@Stateless(mappedName = "HelloEjb")
@LocalBean
public class HelloEjb implements HelloEjbRemote, HelloEjbLocal {

public HelloEjb() {
}

public String printHello(String name) {
return "Hello " + name;
}

}



package ejb3.bean;

import javax.ejb.Remote;

@Remote
public interface HelloEjbRemote {
String printHello(String name);
}


package ejb3.bean;

import javax.ejb.Local;

@Local
public interface HelloEjbLocal {
String printHello(String name);
}




The LocalBean means a no-interface view .

This is what I find in JNDI tree:

Binding Name: HelloEjb#ejb3.bean.HelloEjbRemote (this is from @Remote)
Class: com.sun.proxy.$Proxy208


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjb (this is from @LocalBean )
Class: ejb3.bean.HelloEjb_n3seu_NoIntfViewImpl


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjbLocal (this is from @Local)
Class: ejb3.bean.HelloEjb_n3seu_HelloEjbLocalImpl


Binding Name: java:global.PVHelloEJBEAR.PVHelloEJB.HelloEjb!ejb3.bean.HelloEjbRemote (this is from @Remote again)
Class: com.sun.proxy.$Proxy208



where PVHelloEJBEAR.PVHelloEJB.HelloEjb are respectively: application name (from application.xml), ejb module name (from application.xml), ejb name (mappedName)
To lookup the EJB interface from a JSP:

HelloEjbRemote helloEjb = (HelloEjbRemote) context.lookup("HelloEjb#ejb3.bean.HelloEjbRemote");

or (it works also in a servlet) if the JSP is in a WAR the same EAR as the EJB module you can use the no-interface @LocalBean trick :

@EJB
private HelloEjb helloEjb;


If you provide a @EJB in the JSP/Servlet without having a @LocalBean annotation, you get this error:

Module named 'PVHelloEJBEAR' failed to redeploy. See Error Log view for more detail.
weblogic.management.DeploymentException: weblogic.application.naming.ReferenceResolutionException: [J2EE:160200]Error resolving ejb-ref "ejb3.bean.HelloEjb3Servlet/helloEjb" from module "PVHelloWAR.war" of application "PVHelloEJBEAR". The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the "ejb3.bean.HelloEjb" interface. Link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
Exception received from deployment driver. See Error Log view for more detail.



This is the documentation of @EJB : https://docs.oracle.com/javaee/6/api/javax/ejb/EJB.html

So if from your Servlet/JSP you want to access a REMOTE EJB (i.e. without LocalBean) you must change your @EJB lookup to:

@EJB(lookup="HelloEjb#ejb3.bean.HelloEjbRemote")
private HelloEjbRemote helloEjb;


or using the @Local interface:

@EJB
private HelloEjbLocal helloEjb;


Sample project available:

git clone https://github.com/vernetto/JavaMonAmour
cd JavaMonAmour\jeesamples\HelloEJB


Viewing all 1124 articles
Browse latest View live