U Kvistborg

Greenhorn
+ Follow
since Oct 14, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by U Kvistborg

Thanks for the help,

Currently trying all sorts of stuff I never really did before, being the only person on a project, that gets to use what ever I like as long as it lives up to the requerenments :-)
14 years ago
Hi

I have created a jms bean, with the onMessage method, to send emails for me, but that does not matter.

I can in my log see that the sender only sends the message once, but I get the onMessage method called several times. I could imagine that this is a set up of WebSphere or something ?
This is my simple code to put the message onto the queue, I am using the default messaging in WebSphere


The above lod message is only printet once.

and my current onMessage method starts like this: Where I can see that it is the excact same message id I get printet more than once.


So how do I prevent my system from reciving the same message more than once ?
14 years ago
So what you are telling me is that I just aswell could try to send the message, and then see if it fails rather than doing a check for if the port is listening.
14 years ago
Set class to java.util.Map, and drop the type attribute.

guess you mean the other way around ? the class attribute means that it will if there is nothing in scope instantiate it.
But the thing is this map is only set to the request if there is any errors, if there is none or the first time I enter the page the map will not be there. And I can enter this jsp page from several ways.

And it just anoys me all the warnings some times. So I where wondering.
14 years ago
JSP
Hi,

I have a question, regarding this use and generics, or typed collections.

When I do this I ofcourse gets my HashMap, either a new one or if one allready is set on the request as that one.

But my editor keep telling me with a warning that I should parameterize the HashMap


Multiple annotations found at this line:
- HashMap is a raw type. References to generic type HashMap<K,V> should be
parameterized
- HashMap is a raw type. References to generic type HashMap<K,V> should be
parameterized



So my question is how do I do that ? I can not do it as in normal Java with the <> e.g.

guess the <> are seen by the jsp engine as some sort of xml tags within the
jsp:useBean tag.

and using the < and > instead of <> as below

I get this error.


Multiple annotations found at this line:
- Undefined type:
java.util.Map&&;lt;String,String&&;gt;
- Undefined type:
java.util.Map&&;lt;String,String&&;gt;



is it possible to have the Type on collections using useBean ?
14 years ago
JSP
I even tried this one:
for(int i = 0 ; i<=65535;i++){
InetSocketAddress inet = new InetSocketAddress("w3.company.com", i);
System.out.println("Port " + i + " open " + inet.isUnresolved());
}

And no ports on the server where unresolved, but I know it does not listen to evet port in the range 0-65535

So again how can I detmine that my mail server is listening on the specific smtp port ?
14 years ago
Hi

I am wondering if I am the only one with this specific problem, I whant to check if my smtp host is up and running before I attempt to send an email. Or is it better to see if I get an exception and then handles this ?
I have 3 different smtp hosts I can use, but I would preffer to test if they are running and ready to send my emails before I do it instead of using the exceptions. So my question is how do I do this ?
I did try InetAddress.getByName("w5.company.com").isReachable(1000) but they responds even if my smtp host is down, there are some webhosting here aswell.
14 years ago
Hi

I have a few tables, an example could be like I have a person that have many cars, a person table and a car table. Where the person have a pk as some id, and the cars have a fk to the persons pk.
Now if I wanna get the person bean I want the cars to be on the bean that the person owns. So I could say person.getCars() and get the collection with the Cars object belonning to this person.

There is ofcourse one solution and that is to have a domain object representing the person and for each person add the car objects. But is there any easier way to do this, e.g. via the eql. ? So I directly on my person bean have access to the cars ?

Brgds
Hi

I am getting an exception when trying to create a cmp 2.x instance of a bean that have the PK field in the database as autogenerated by the database.

I see that in this generated java file that it is an plain insert into statement where it sets the key value to java.sql.Types.BIGINT (-5 in this implementation), so how do I get around this ?

I want to have the db2 generate my key field, but if I do not set it during the create method for my bean, it fails with this exception. Is it even possible to have these fields in the database as PK's and still be able to get to use it as the beans pk ?

Currently I do not see anyway around this issue except having the code create the id, and not have an autogenerated pk in the table ?

Sorry for the danish, but DB2 did not get me to choose english during the installation.

---- Begin backtrace for Nested Throwables
com.ibm.db2.jcc.b.SqlException: Der opstod en fejl ved udførelse af en implicit systemhandling af typen "2". Den information, der er returneret om fejlen, indeholder SQLCODE "-798", SQLSTATE "428C9" og meddelelsessymbolerne "AVAILABILITYID".
at com.ibm.db2.jcc.b.zc.e(zc.java:1606)
at com.ibm.db2.jcc.b.ad.a(ad.java:1698)
at com.ibm.db2.jcc.a.db.a(db.java:200)
at com.ibm.db2.jcc.a.db.b(db.java:88)
at com.ibm.db2.jcc.a.r.b(r.java:60)
at com.ibm.db2.jcc.a.tb.d(tb.java:293)
at com.ibm.db2.jcc.b.ad.ab(ad.java:1691)
at com.ibm.db2.jcc.b.ad.db(ad.java:1762)
at com.ibm.db2.jcc.b.ad.d(ad.java:2203)
at com.ibm.db2.jcc.b.ad.V(ad.java:521)
at com.ibm.db2.jcc.b.ad.executeUpdate(ad.java:504)
at com.ibm.ws.rsadapter.cci.WSResourceAdapterBase.executeUpdate(WSResourceAdapterBase.java:450)
at com.incase.iss.ejb.cmp.websphere_deploy.DB2UDBNT_V82_1.AvailabilityBeanFunctionSet_d4aab7c6.Create(AvailabilityBeanFunctionSet_d4aab7c6.java:78)
14 years ago
But why is it often better to use the prepared statement, I mean it gets compiled, but compiled by what ? The database ?
Should a prepared statement then allways perhaps be in a static variable because it is then here precompiled and ready to get variables inserted and executed ?
Should I use a statement rather than a prepared statement if the sql differs, could be that the where clause is changed ?

Often the only reasonI like the prepared statement is because of the setter methods, especially when setting a date, and there is no problems with the ' and remembering these in the sql string and stuff like that. But if you do not know what is on the where claus you need to keep track on this while building the statement, and then after creating it the insertion.
This is because then I do not need to use like = '%' which makes the database a bit slower. So it is better to remove this from the where clause.

If that where part of an ordinarry statement I would properly more often need to use that compared to the prepared statement.

should a prepared statement really be one that is useable like a static virable to the class ?
Hi

I have the strangets issue I have ever come by, I have an application that builds and deployes fine in RSA 7.0 under websphere 6.1.0.2 build cf20633.22
I have now moved my application via an ear file export and earfile import to RAD 7.5 with websphere 6.1.0.19 build cf90836.04
and it allmost works.
In both cases I am using db2 as my database and they are both 8.2, and the database is a backup from the other installation.

But when I deployes my application, or starts it it fails because one and only one of the session beans is never found.
This particular bean references 2 entity beans.

There is no difference in my application from one environment to the other, and I even have deployed the application I am importing into my new environment in our production environment.

I then desided to try to remove the entity references, and now my code finds the session bean, and it does not matter which one of these references I tries to remove. But ofcourse I get another error later on, if this reference is not there, I never get the entity beans home interface.

Other of my session beans happily references several entity beans, even if I set one of my other to reference these two particular entity beans.

And I can with out problems references my other entities from this particular session bean.

I tried to reimplement one of the entity beans and that too failed.

So I find it really really strange this particular error, that I get on this websphere server running in this version of RAD.

Anyone got any ideas ?

any one needing more info just say so.

I can add that I have now tried to install the actual ear file, that works fine in my old environment and is installed on production, into the WAS6.1 that I have with RAD, and it gives the same error, so it must be something with the actual WebSphere server that does not work.

It seems that it where the feature pack for WAS 6.1 that caused the issue, after I removed this my app works fine and as expected.
14 years ago
Problem with my first ejb3 entity.

Hi I have just attempted to make my first ejb3 entity, but I get an error stating that it have not been enhanced. and I have no idea of what it is talking about ?
I have tried to search for an answer but still been unable to find any.

I get this error.

[09-03-19 09:19:50:380 CET] 00000026 SystemOut O StatelessUserBean:increment - caught unexpected exception: &amp;amp;lt;openjpa-1.0.3-SNAPSHOT-r420667:649224 nonfatal user error&amp;amp;gt; org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance &amp;quot;com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98&amp;quot; to PersistenceCapable failed. Ensure that it has been enhanced.
FailedObject: com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are &amp;amp;lt;openjpa-1.0.3-SNAPSHOT-r420667:649224 nonfatal user error&amp;amp;gt; org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance &amp;quot;com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98&amp;quot; to PersistenceCapable failed. Ensure that it has been enhanced.
FailedObject: com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4286)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2365)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2225)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1005)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ws.jpa.management.JPAExEmInvocation.persist(JPAExEmInvocation.java:348)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ws.jpa.management.JPAEntityManager.persist(JPAEntityManager.java:109)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.incase.orp.ejb.cmp.UsersSessionBean.update(UsersSessionBean.java:51)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at java.lang.reflect.Method.invoke(Method.java:618)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:547)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.incase.orp.ejb.cmp.Audit.methodChecker(Audit.java:15)

I have this method in a session bean:

and my interceptor is

and my bean is like this:

and with getters and setters for the rest of the fields aswell making them into the bean properties.

and my persistence xml looks like this:

I call it from a servlet, and this call seems to be fine, it is only in the em.persist that seems to fail, and I am at a loss as to why ?? and what is this enhancement the error is talking about ?
Problem with my first ejb3 entity.

Hi I have just attempted to make my first ejb3 entity, but I get an error stating that it have not been enhanced. and I have no idea of what it is talking about ?
I have tried to search for an answer but still been unable to find any.

I get this error.

[09-03-19 09:19:50:380 CET] 00000026 SystemOut O StatelessUserBean:increment - caught unexpected exception: &lt;openjpa-1.0.3-SNAPSHOT-r420667:649224 nonfatal user error&gt; org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98" to PersistenceCapable failed. Ensure that it has been enhanced.
FailedObject: com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are &lt;openjpa-1.0.3-SNAPSHOT-r420667:649224 nonfatal user error&gt; org.apache.openjpa.persistence.ArgumentException: Attempt to cast instance "com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98" to PersistenceCapable failed. Ensure that it has been enhanced.
FailedObject: com.incase.orp.ejb.cmp.JPAUserEntity@3b983b98
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.assertPersistenceCapable(BrokerImpl.java:4286)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2365)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2225)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1005)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:541)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ws.jpa.management.JPAExEmInvocation.persist(JPAExEmInvocation.java:348)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ws.jpa.management.JPAEntityManager.persist(JPAEntityManager.java:109)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.incase.orp.ejb.cmp.UsersSessionBean.update(UsersSessionBean.java:51)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at java.lang.reflect.Method.invoke(Method.java:618)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:547)
[09-03-19 09:19:50:380 CET] 00000026 SystemErr are at com.incase.orp.ejb.cmp.Audit.methodChecker(Audit.java:15)

I have this method in a session bean:
@Stateless
@Interceptors(Audit.class)
public class UsersSessionBean implements LocalUser, RemoteUser {

@PersistenceContext (unitName="User")
private EntityManager em;

public void update(Long id,
String userid,
String password,
String fname,
String lname,
String role1,
String loginstatus,
String email,
String country,
Long partner)
{

try {

JPAUserEntity user = null;//em.find(JPAUserEntity.class, id);

if ( user == null ){
user = new JPAUserEntity();
user.setId(System.currentTimeMillis());
user.setUserid(userid);
user.setPassword(password);
user.setFname(fname);
user.setLname(lname);
user.setRole1(role1);
user.setLoginstatus(loginstatus);
user.setEmail(email);
user.setCountry(country);
user.setPartner(partner);
em.persist( user );
} else{
user.setUserid(userid);
user.setPassword(password);
user.setFname(fname);
user.setLname(lname);
user.setRole1(role1);
user.setLoginstatus(loginstatus);
user.setEmail(email);
user.setCountry(country);
user.setPartner(partner);
em.persist( user );
}

em.flush();
em.clear();

} catch (Throwable t) {
System.out.println("StatelessUserBean:increment - caught unexpected exception: " + t);
t.printStackTrace();
}

return;
}

and my interceptor is

public class Audit implements Serializable {

private static final long serialVersionUID = 4267181799103606230L;

@AroundInvoke
public Object methodChecker(InvocationContext ic) throws Exception {
System.out.println("Audit:methodChecker - About to execute method: "
+ ic.getMethod());
Object result = ic.proceed();
return result;
}
}
and my bean is like this:

@Entity
@Table(name="USERS")
public class JPAUserEntity {
private static final long serialVersionUID = 1L;

@Id
private Long id;

private String userid;
private String password;
private String fname;
private String lname;
private String role1;
private String loginstatus;
private String email;
private String country;
private Long partner;


public void setId( Long newKey )
{
System.out.println ("JPAUserEntity:setPrimaryKey = '" + newKey + "'");
id = newKey;
}

public Long getId()
{
System.out.println ("JPAUserEntity:getPrimaryKey = '" + id + "'");
return id;
}
and with getters and setters for the rest of the fields aswell making them into the bean properties.

and my persistence xml looks like this:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"&gt;
&lt;persistence-unit name="User"&gt;
&lt;jta-data-source&gt;jdbc/ISSDS&lt;/jta-data-source&gt;
&lt;class&gt;com.incase.orpejb.cmp.JPAUserEntity&lt;/class&gt;
&lt;exclude-unlisted-classes&gt;true&lt;/exclude-unlisted-classes&gt;
&lt;/persistence-unit&gt;
&lt;/persistence&gt;

I call it from a servlet, and this call seems to be fine, it is only in the em.persist that seems to fail, and I am at a loss as to why ?? and what is this enhancement the error is talking about ?
I have found that on windows mobile 2003, that the Runtime.exec method is not really implemented, it simply returns the exception, unable to start program, does any one know if this is the case for the J9 on windows mobile 5 aswell ?
The reason for that it have not been implemented on windows mobile 2003 is that on this platform it is not possible to pass the file pointer for System.out and .err to a child process, as is typical for Runtime.exec.
16 years ago
Hi I have tried on my mobile device windows mobile 5 with jcl9 i think the jvm is called, but I am unable to start any external programs on this platform, I have done it several times on normal windows but I get an IOException on this particular platform.

java.io.IOException: Unable to start program

Runtime.getRuntime().exec("\\Windows\\welcome.exe");
I can start this program by clicking on the file in total commander but not with above line.

I am using eswt so perhaps there might be any other way of doing this ?
I do not nessesarly wanna start a program but a lnk would be just as fine.

Any one know how to perhaps ?
16 years ago