Handing over JAVA components to L3 support…

Java Specialist13:13

Hi

Udby, Jesper13:13

Hi

Java Specialist13:13

we are unable to build with existing set up

can you give us ear file to me

Udby, Jesper13:14

no, unfortunately not, I’m working from home today and do not have access to my dev env

Java Specialist13:14

i will put in weblogic server

Udby, Jesper13:14

I suggest you configure you’r maven setup to use the proper repo so you can build it. It has to be done anyways…

Java Specialist13:15

can you share your maven to me

_

folder

Udby, Jesper13:15

no… its on m dev env too…

the settings.xml linked from the document i sent you contains information about the repo – you should be able to use that?

which weblogic server btw?

Java Specialist13:18

weblogic server 11gR1

Udby, Jesper13:18

you have a local setup?

Java Specialist13:18

yes

Udby, Jesper13:18

nice:)

you got a local db setup too?

Java Specialist13:19

datasouce

Udby, Jesper13:20

yes, datasource. does it point to a local db or one of our dev environments?

Java Specialist13:20

yes

Udby, Jesper13:21

do you have a local db?

Java Specialist13:21

yes

Udby, Jesper13:21

nice:)

how’s the schema setup?

Java Specialist13:21

there

Udby, Jesper13:21

there?

Java Specialist13:21

yes

Udby, Jesper13:22

ok, i rephrase: how are the users/schemas, tables, sequences etc setup?

DDL

Java Specialist13:22

i will give schema name

usern and password

yes

Udby, Jesper13:23

i don’t know if you are aware of it, but “we” are using what is called “database migration” scripts to do the DDL

Java Specialist13:24

1 min

Udby, Jesper13:24

1 min what?

Java Specialist13:25

wait

database migration is no there with me

Udby, Jesper13:27

well thats not important if you are able to setup the schema/users, tables etc yourself

I was just wondering where you got the details from

Java Specialist13:28

webservice setup document

Udby, Jesper13:29

ok

Java Specialist13:31

Do you have this type of document with you_

Udby, Jesper13:32

nope, not here, might have it in the office…

Java Specialist13:32

ok

is there anu body who will share information_

Udby, Jesper13:33

what information?

Java Specialist13:34

regadring configuartion of java compenent with oSB

Udby, Jesper13:34

what component and what kind of configuration?

Java Specialist13:36

two ear file ie two java componet and after that i will confuge jMS queue with SFDC 

and OSB

Udby, Jesper13:36

first, there are more than two components, you need to tell me which components you need information about

then I can tell you which datasouces and jms queues are necessary

but you can see that in the code, if you like?

take the xxx-feed-parser (from memory, you can see the proper name in the poms/mail/source etc)

Java Specialist13:38

ok

Udby, Jesper13:38

it needs a jms queue, can’t remember the jndi name, but it’s in the annotation in the MDB

and it needs a datasource, can’t remember the jndi name, but its in the persistence.xml file

Java Specialist13:39

i have JMSQUEue is there with me

Udby, Jesper13:39

what?

Java Specialist13:40

while i am doing yYYY project

Udby, Jesper13:40

ok, good, but its probably not the same queue:)

Java Specialist13:41

ok

Udby, Jesper13:41

you can see the jndi name of the jms queue in the annotation in the mdb – message driven bean

Java Specialist13:44

1min

wait

i am opening weblogic server

Java Specialist13:53

yes

Udby, Jesper13:54

yes?

Java Specialist13:55

i am able to jndi nameof the JMS queue

for YYYY

Udby, Jesper13:55

ok

I wasn’t referring to the jndi name of the jms queue in yyyy

you do know what an annotation is, right?

Java Specialist14:00

no

Udby, Jesper14:00

ok, you are in trouble

do you know what a message driven bean is?

Java Specialist14:01

yes

Udby, Jesper14:03

good

in the mdb (aka message driven bean) there is an annotation that tells it which jms queue it should connect to

i can’t remember the proper name of it, but somewhere in the xxx-feed-ejb (i think it is) there is the java source of a message driven bean – I even think it is called something like Xxx…Mdb or similar. In that source you can find the annotation containing the name of the jms queue

also, in that project, there is a persistence.xml – you do know what that is?

Java Specialist14:06

jesper please share me the ear file to deploy javacomponents in weblogic server

Udby, Jesper14:06

sorry, i cant

you should configure your maven to use the proper repo, then you can build it yourself

btw: there is more than one ear

one component = one ear

 

Posted in Fun, Java | Leave a comment

Salesforce wsc (sfdc-wsc): new release 23 coming

The current situation is a mess. There are now 3 known versions of the sfdc-wsc tool:

I will try to merge relevant changes from the codebase at mvnrepository but please notice it has already forked. The code style at mvnrepository is slightly different to my style and I take the liberty to refactor stuff in order to keep classes clean and without too much responsibility (e.g. ConnectorConfig should not have the responsibility of creating connections, adding stream wrappers and what not).

Released – wsc-23.jar – with the following:
Continue reading

Posted in Java, Salesforce | Tagged , , , | Leave a comment

Salesforce wsc hacking: yet another Open Source encounter?

As I wrote in an earlier post I’ve volunteered to become a committer to the wsc tool and are in the progress of making minor tweaks and enhancements for a coming release 23.

My plan was that this release should be no more than a “maintenance” release covering most of the relevant issues. And I do have a number of ideas for major changes for a possible release 24, e.g.:

  • Fixing issue 51 – or at least provide a usable implementation hopefully inspired by input from Martin Haynes
  • Reworking/reimplementing the wsdlc tool and templating mechanism
  • Reworking infrastructure parts, possibly using JAXB/JAX-WS
  • Mavenize the build, divide build tools and infrastructure, 2 perhaps 3 artifacts
  • Adding unit tests

I stopped further developments on the “23 branch” when I realized that there apparently already was a “fork” on github.
Continue reading

Posted in Java, Open Source, Salesforce | Tagged , | Leave a comment

Salesforce wsc hacking: new committer

Ok, things change rapidly sometimes.

The short story is that I wrote directly to the Owners of the WSC tool in order to get some information about when changes could be expected.

The response was basically that they no longer maintain the WSC tool and if I was interested I could become a committer. I was and now I am 🙂

Currently working on wsc-23 to be released soon – probably by the end of January 2013.

Contains most of the stuff already discussed here and probably some other enhancements regarding the wsdlc tool.

Update 2013-01-31: There appear to be some confusion about the proper version/codebase of the wsc tool. I will not make a new formal release until I get some definitive answers… We might need to fork 🙂

Posted in Personal, Salesforce | Tagged , , | Leave a comment

Salesforce wsc hacking: getting rid of SessionTimedOutException

The SoapConnection java class sports a private static inner Exception, the SessionTimedOutException. This Exception is used internally only to quickly pass control from the parseDetail() method back to the send() method.

This is bad practice, using an Exception to control flow of execution. And in this case the infrastructure is doing exception handling in the first place… There has to be a better way.

Continue reading

Posted in Java, Salesforce | Tagged , , , | Leave a comment

Salesforce wsc hacking: adding RequestTimedOutException

I have a number of situations where a RequestTimedOutException would be appropriate instead of just a ConnectionException when SoapConnection.send() encounters a SocketTimeoutException.

This would ease retry implementations (related to timeouts) in that they would only have to consider a special type of exception and does not have to revert to parsing exception messages.

If a RequestTimedOutException extends ConnectionException the handling of SocketTimeoutException in the SoapConnection class can be done without changing the api. It is a simple matter of changing the type of exception thrown as response to SocketTimeoutExceptions.

E.g. in SoapConnection:

112
113
114
115
116
117
        } catch (SocketTimeoutException e) {
            long timeTaken = System.currentTimeMillis() - startTime;
            throw new RequestTimedOutException("Request to " + url + " timed out. TimeTaken=" + timeTaken +
                    " ConnectionTimeout=" + config.getConnectionTimeout() + " ReadTimeout=" + 
                    config.getReadTimeout(), e);
        }

And the RequestTimedOutException, e.g. at the bottom of SoapConnection:

    public static class RequestTimedOutException extends ConnectionException {
        private static final long serialVersionUID = 1L;
 
        private RequestTimedOutException(String message, Exception e) {
            super(message, e);
        }
    }

WSC issue 67.

Posted in Java, Salesforce | Tagged , , , | Leave a comment

Salesforce wsc hacking: removing compiler warnings

I hate compiler warnings. These little yellow warning signs in Eclipse annoys me. I will go far to avoid compiler warnings in my own code.

But what about generated code? Actually generated code is the worst as it does not make sense to correct the code to remove the warnings – they will reappear when the code is regenerated. And it demonstrates sloppiness in the code generation tool.

In this article I will work through and demonstrate how to remove the compiler warnings from the wsc generated code, and some of the infrastructure code as well.

Continue reading

Posted in Java, Salesforce | Tagged , , , | Leave a comment

Unit-testing time/timing dependent components

I’m often faced with developing components that are depending on time or timing, one way or the other.

An example can be a query that returns all “active” rows, given current date/time and where the rows have effective and expiry columns. Or components that report different state depending on time T, T+n, T+m etc.

Unit-testing components like these can be a nuisance, unless “current time” is part of the interface in the first place, and with some sleep() and stuff in the second situation. Not ideal.
Continue reading

Posted in Java | Tagged , , , , , , | Leave a comment

SimpleDateFormat instances are not thread-safe

It comes as a surprise to many developers that SimpleDateFormat instances are not thread-safe. Sometimes I encounter utility classes like below:

public class DateUtil {
	public static final SimpleDateFormat ISO_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
	public static final SimpleDateFormat SQL_TIMESTAMP_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
	// etc...
	public static Date parse(String date) throws ParseException {
		return ISO_DATE_FORMAT.parse(date);
	}
	public static String format(Date date) {
		return ISO_DATE_FORMAT.format(date);
	}
	// etc...
}

Looks innocent, but it will get you into trouble sooner or later if accessed by more than one thread at a time. And the problems are hard to find and debug, from strange dates in different application layers to strange exceptions where you’d expect none in a healthy system. And errors that only occurs very rare and more often when the system is under load…

Then what to do?
Continue reading

Posted in Java | Tagged | 5 Comments

Salesforce JAXB: Using wsimport to generate client artifacts

The Salesforce developer documentation provides JAVA examples based on WSC. WSC is a nice tool that makes interfacing to SFDC simple and easy, providing an EnterpriseConnection hiding all the details in calling SFDC.

But, WSC might not be for you:

  • Proprietary, not standards based
  • You might not be allowed to add third-party libraries to your application stack; or the process is too cumbersome…
  • Support, maintenance?

Unfortunately the wsimport tool that comes with the JDK does not “out of the box” like the Enterprise WSDL generated from Salesforce. Running it on the Enterprise WSDL from my test setup gives below output:

[jesper@linux3 ~]$ wsimport -keep enterprise.wsdl
parsing WSDL...
 
[WARNING] src-resolve: Cannot resolve the name 'tns:ID' to a(n) 'type definition' component.
  line 31 of file:/home/jesper/enterprise.wsdl#types?schema1
 
[ERROR] A class/interface with the same name "com.sforce.soap.enterprise.DescribeLayout" is already in use. Use a class customization to resolve this conflict.
  line 5952 of file:/home/jesper/enterprise.wsdl
 
[ERROR] (Relevant to above error) another "DescribeLayout" is generated from here.
  line 5620 of file:/home/jesper/enterprise.wsdl
 
[ERROR] Two declarations cause a collision in the ObjectFactory class.
  line 5952 of file:/home/jesper/enterprise.wsdl
 
[ERROR] (Related to above error) This is the other declaration.
  line 5620 of file:/home/jesper/enterprise.wsdl

Continue reading

Posted in Java, Salesforce | Tagged , , , | 2 Comments