Posts Tagged ‘Java’

<BEA-000000> <java.lang.NegativeArraySizeException

17 December 2015 Leave a comment

If you get this error with WebLogic’s admin server

####<2015-12-17 14:30:14 EET> <Critical> <EmbeddedLDAP> <> <AdminSOA> <VDE Replication Thread> <<anonymous>> <> <9f23d04b03212987:b0dda39:151a2d3b538:-8000-0000000000004207> <1450355414644> <BEA-000000> <java.lang.NegativeArraySizeException
	at com.octetstring.vde.EntryChanges.readBytes(
	at com.octetstring.vde.EntryChanges.<init>(
	at com.octetstring.vde.replication.BackendChangeLog.getChange(
> )

chances are that there are corrupted LDAP files in the <domain home>/servers/<server name>/data/ldap/ldapfiles folder. One possible solution is to delete the and changelog.index files (take a backup first of these two files) and restart the admin server.

Categories: Java, ldap, Oracle, WebLogic Tags: , , ,

How to issue a JSON POST request to Spring Data Rest with a JPA relation

25 November 2014 Leave a comment

Lets say we have a class Company which has a relation to a class User

@Table(name = "company")
public class Company implements {

	private static final long serialVersionUID = 1L;
	private Long id;
	private String name;
	private User user;

	public Company() {

	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {

	public void setId(Long id) { = id;

	@Column(name = "name", nullable = false, length = 200)
	public String getName() {

	public void setName(String name) { = name;

	@ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity=my.example.User.class)
	@JoinColumn(name = "user_id")
	public User getUser() {
		return user;

	public void setUser(User user) {
		this.user = user;

and their corresponding repositories:

@RepositoryRestResource(collectionResourceRel = "company", path = "company")
public interface CompanyRepository extends JpaRepository<Company, Long>  {

@RepositoryRestResource(collectionResourceRel = "user", path = "user")
public interface UserRepository extends JpaRepository<User, Long> {


In order to add a user to the company (let’s say we want to link this company to the user with id of 2) you will need to issue the following JSON request to the company repository:

"name" : "a company name",
"user" : "http://localhost:8086/user/2"

The “user” variable should be the URL that is pointing to the user repository.

Categories: Java, Spring, Spring Data Rest Tags: ,

There Will Be Code

30 September 2013 Leave a comment

“One might argue that a book about code is somehow behind the times—that code is no
longer the issue; that we should be concerned about models and requirements instead.
Indeed some have suggested that we are close to the end of code. That soon all code will
be generated instead of written. That programmers simply won’t be needed because business people will generate programs from specifications.

Nonsense! We will never be rid of code, because code represents the details of the
requirements. At some level those details cannot be ignored or abstracted; they have to be
specified. And specifying requirements in such detail that a machine can execute them is
programming. Such a specification is code.

I expect that the level of abstraction of our languages will continue to increase. I
also expect that the number of domain-specific languages will continue to grow. This
will be a good thing. But it will not eliminate code. Indeed, all the specifications written
in these higher level and domain-specific language will be code! It will still need to
be rigorous, accurate, and so formal and detailed that a machine can understand and
execute it.

The folks who think that code will one day disappear are like mathematicians who
hope one day to discover a mathematics that does not have to be formal. They are hoping
that one day we will discover a way to create machines that can do what we want rather
than what we say. These machines will have to be able to understand us so well that they
can translate vaguely specified needs into perfectly executing programs that precisely meet
those needs.

This will never happen. Not even humans, with all their intuition and creativity,
have been able to create successful systems from the vague feelings of their customers.
Indeed, if the discipline of requirements specification has taught us anything, it is that
well-specified requirements are as formal as code and can act as executable tests of that

Remember that code is really the language in which we ultimately express the requirements.
We may create languages that are closer to the requirements. We may create tools
that help us parse and assemble those requirements into formal structures. But we will
never eliminate necessary precision—so there will always be code.”

Robert C. Martin – Clean Code. A Handbook of Agile Software Craftmanship.

Well said Robert. This summarises, in a few paragraphs, how important code is in our every day activities.

Categories: Books, Java Tags: ,

How to programmatically add a a4j:commandButton and a4j:actionparam

2 April 2013 Leave a comment

After spending a few hours I finally managed to programmatically add an ajax command button and action parameter to JSF (1.2) components. So the following

<a4j:commandButton value="Click Me"
	styleClass="buttons" rendered="true" immediate="true"
	id="buttonId" actionListener="#{newRequestBean.doSomething}"
	<a4j:actionparam name="theVat" id="vatId" value="IComeFromTheBean" assignTo="#{newRequestBean.vat}" noEscape="false"/>

translates to

MethodExpression methodExpression = application.getExpressionFactory().createMethodExpression(
                                new Class[0]);
HtmlAjaxCommandButton button = (HtmlAjaxCommandButton) application.createComponent(HtmlAjaxCommandButton.COMPONENT_TYPE);
button.setValue("Click Me");

ValueBinding vb = context.getApplication().createValueBinding("#{newRequestBean.vat}");
HtmlActionParameter param = (HtmlActionParameter) application.createComponent(HtmlActionParameter.COMPONENT_TYPE);


Things to notice:

1) The last parameter of the method expression should be an empty array (new Class[0]), otherwise you will get the exception “java.lang.IllegalArgumentException: wrong number of arguments“. Your method should have no parameters.
2) You should add the HtmlActionParameter as the action listener of the command button. This is an absolutely essential step in order to make it work (well, this is only if you want to pass parameters to the call). It took me literally hours to figure this out.
3) The context variable is a FacesContext.

Categories: Java, JSF, RichFaces Tags: , ,

SOAPException: faultCode=SOAP-ENV:Client; msg=For input string: "3773 "; targetException=java.lang.NumberFormatException

7 December 2012 1 comment

I get this warning with JMeter

WARN - jmeter.protocol.http.sampler.WebServiceSampler: [SOAPException: faultCode=SOAP-ENV:Client; msg=For input string: "3773 "; targetException=java.lang.NumberFormatException: For input string: "3773 "]

every time I try to test a web service by running a WebService(SOAP) Request. Strange it might seem, but I found out that the error is actually a network error; to be more specific an HTTP/1.1 504 Proxy Timeout ( The connection timed out. ). The original error is totally misleading.

The connection times out, so I get no SOAP response back. What I get though is the headers, the content and the content length back. But for some reason the content length is padded with some spaces at the end and when the HTTPUtils (the class that handles the SOAP request/response) tries to parse it with this statement


it fails. I had to rebuild jmeter and step through it with breakpoints in order to see what’s going on. The solution is as simple as adding a trim to the statement (a couple of lines above the offending statement):

String value = valuebuf.toString().trim();

This fixes the issue and you get the actual response back which is

Error Code 10060: The gateway could not receive a timely response from the website you are trying to access. This might indicate that the network is congested, or that the website is experiencing technical difficulties..

Android INSTALL_FAILED_CONTAINER_ERROR on installing an application

28 April 2012 4 comments

I got this error while I rebooted my android device in the middle of installing an application (it was taking ages so I assumed that it was stuck). It seems that android did not have time to clean the file system, so every time i was trying to install an application I was getting the error:

ASEC file ‘/mnt/secure/asec/smdl2tmp1.asec’ currently exists – destroy it first! (Address already in use)

The solution to this is actually very simple. Make sure that you have connected your device to your computer and that it’s running on debug mode (it’s not mounted). Open a command window, go to your Android\android-sdk\platform-tools and type adb shell. This should open the adb shell and connect as root. Then simply type rm /mnt/secure/asec/smdl2tmp1.asec and the problem should go away.


Categories: Android Tags: , ,

How to debug your Android application on an Archos 7 internet tablet

27 February 2012 2 comments

You can find information on how to debug on a real device on the Using Hardware Devices page. But since this is missing information about the Archos Internet Table 7 (the device I am using) I will post here how you can do it (on Windows).

First of all you need to download the Archos ADB drivers from the archos site. Install it by following the instructions on the Google USB Driver page.

Then you need to edit the adb_usb.ini file (it should be in your home directory, under the .android folder) and add the following line: 0x0e79. You should get something like the following:

# USE 'android update adb' TO GENERATE.

You must kill and restart the adb server by running: adb kill-server and adb start-server (adb is in android-sdk\platform-tools). You can also run adb devices to make sure your device is listed. You should see something like the following:

List of devices attached
A70-3A860001-9FF80000-015DB7D4-???????? device

(the ?????? is probably a name in non-Latin characters that the command window does not recognise).

Once you’ve set it up configure your application and your device to be debugable by following the instructions on the Using Hardware Devices page.

If you have done everything correctly next time you run Eclipse you should see that it’s synchronising the application to your device

[2012-02-27 19:44:16 - Lexicon] Performing sync
[2012-02-27 19:44:16 - Lexicon] Automatic Target Mode: using device 'A70-3A860001-9FF80000-015DB7D4-????????'
[2012-02-27 19:44:16 - Lexicon] Uploading TestApp.apk onto device 'A70-3A860001-9FF80000-015DB7D4-????????'
[2012-02-27 19:44:17 - Lexicon] Installing TestApp.apk...
[2012-02-27 19:44:25 - Lexicon] Success!
[2012-02-27 19:44:26 - Lexicon] \TestApp\bin\TestApp.apk installed on device
[2012-02-27 19:44:26 - Lexicon] Done!

You are ready to start debugging your application on a real android device.

Categories: Android Tags: , , ,