snippetjournal

– notes, snippet codes, and my journal

Archive for the ‘Programming’ Category

[Oracle] ORA-02292 : Mencari Table Constraints dengan Constraints Name

leave a comment »

mencoba mengupdate salah satu column pada row, tetapi terkena error seperti ini :

update auth_users set username = ‘user1@test.co.id’ where name = ‘user@test.co.id’
Error report –
SQL Error: ORA-02292: integrity constraint (ADMIN.FK_2TUB76GCBJC6VCSO1FBE15L3P) violated – child record found
02292. 00000 – “integrity constraint (%s.%s) violated – child record found”
*Cause: attempted to delete a parent key value that had a foreign
dependency.
*Action: delete dependencies first then parent or disable constraint.

 

maka kita dapat mencari tahu, constraints name itu milik table siapa (FK_2TUB76GCBJC6VCSO1FBE15L3P). gunakan syntax berikut :

select table_name from user_constraints where constraint_name=’FK_2TUB76GCBJC6VCSO1FBE15L3P’;

Written by snippetjournal

January 4, 2016 at 10:26 am

Posted in Programming

Tagged with ,

Java Material : Conference, Seminar and Java Enthusiast you must stalk !

leave a comment »

Sebagai catatan, Java di indonesia di “musim trend Startup” indonesia seperti tidak terdeteksi atau seperti gerakan underground, sedangkan di US/Eropa mereka masih saja aktif dan teknologi java pun berjalan bersama sama dengan teknologi lain dan metode/konsep baru di bidang programming yang sedang trend.

Sebagai informasi kita bisa mengikuti web dan event dari pivotal, java zone, java one dan evangelist atau penggiat pengiat java di luar indonesia, mereka cukup aktif di twitter.

Written by snippetjournal

October 29, 2015 at 6:23 am

Posted in Programming

Tagged with

Jrebel Alternative – Alternative Faster HotSwap VM

leave a comment »

Saya hanya akan mencantumkan referensi link saja, karena pada setiap link sudah dijelaskan dengan jelas, berikut referensi :

Karena berdasarkan rekomendasi teman dan saya memakai eclipse STS dan development memakai spring, maka teman saya menyarankan memakai spring loaded, karena integrasi yang sangat mudah hanya menambahkan syntax argumen pada konfiguasi tomcat.

dan menurut teman saya, beberapa teman yang memakai DCEVM pada netbeans makin lama ia pakai, IDE nya makin terasa lebih berat. CMIIW.

berikut syntax agrument untuk meng-integrasikan agent spring loaded pada tomcat. :

java -javaagent:<pathTo>/springloaded-{VERSION}.jar -noverify SomeJavaClass

-Djavaagent:F:\AdityaSatrioNugroho\xxx\springloaded-1.2.4.RELEASE.jar

                

Written by snippetjournal

September 29, 2015 at 6:58 am

[Trivia] Showing date, column style, column number in Jasper report

leave a comment »

persoalan trivial sih, tapi gw sering lupa dan berakhir googling kesana kemari, karena klo soal jasper gatau harus cari dokumentasi kemana :(, ini sebagai pengingat aja, karena gw sering banget dapet bagian reporting maklum programmer newbie 😀

Show Date :

buat text field, klik 2x, maka akan muncul dialog expression. berikut syntax untuk menampilkan tanggal/date

new SimpleDateFormat(“dd-MM-yyyy”).format(new Date())

Column number :

buat text field, kemudian klik 2x, setelah muncul dialog expression editor masukan syntax berikut :

$V{REPORT_COUNT}

Column Style :

klik kanan pada icon style untuk membuat style baru, setelah terbentuk style baru, klik kanan create conditional style, masukan conditional expression seperti ini :

$V{REPORT_COUNT}%2 == 0

Written by snippetjournal

September 25, 2015 at 2:59 pm

Posted in Programming

Tagged with , ,

[Remainder] Maven – Dependency Scope

leave a comment »

Dependency scope is used to limit the transitivity of a dependency, and also to affect the classpath used for various build tasks.

There are 6 scopes available:

  • compile
    This is the default scope, used if none is specified. Compile dependencies are available in all classpaths of a project. Furthermore, those dependencies are propagated to dependent projects.
  • provided
    This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.
  • runtime
    This scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
  • test
    This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.
  • system
    This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
  • import (only available in Maven 2.0.9 or later)
    This scope is only used on a dependency of type pom in the <dependencyManagement> section. It indicates that the specified POM should be replaced with the dependencies in that POM’s <dependencyManagement> section. Since they are replaced, dependencies with a scope of import do not actually participate in limiting the transitivity of a dependency.

Each of the scopes (except for import) affects transitive dependencies in different ways, as is demonstrated in the table below. If a dependency is set to the scope in the left column, transitive dependencies of that dependency with the scope across the top row will result in a dependency in the main project with the scope listed at the intersection. If no scope is listed, it means the dependency will be omitted.

 

compile provided runtime test
compile compile(*) runtime
provided provided provided
runtime runtime runtime
test test test

 

(*) Note: it is intended that this should be runtime scope instead, so that all compile dependencies must be explicitly listed – however, there is the case where the library you depend on extends a class from another library, forcing you to have available at compile time. For this reason, compile time dependencies remain as compile scope even when they are transitive.

Written by snippetjournal

August 4, 2015 at 7:29 am

Posted in Programming

Tagged with

My Story of “Searching for JAVA CMS”

leave a comment »

Berawal mula dari ide untuk membuat web profile atau web semacam blog saya mencari cari CMS untuk mengakomodir ide saya tersebut (dikarenakan saya malas membuat dari nol/scratch 😀 ), tetapi setelah seharian googling saya memilih drupal dibanding wordpress karena banyak materi di internet yang mengatakan drupal mempunyai security dan kualitas source code yang lebih baik di banding wordpress. (feature dan seo friendly saya kesampingkan terlebih dahulu)

Tetapi karena basic saya programmer java, dan skill PHP saya hanya sebatas guest book vanilla PHP yang saya buat sewaktu kuliah, saya pun jadi ragu, kemudian saya putuskan mencari cari CMS dari bahasa JAVA :D. Dan saya pun menemukan beberapa link untuk lebih jauh mencari tahu bermacam macam CMS dari bahasa JAVA ini hehe.

Dari beberapa link diatas ternyata banyak sekali CMS berbasis Java yang sebenarnya cukup populer, stable, robust serta proven dan dapat di andalkan, dan populer disini artinya di luar sana, di luar indonesia :).

Di indonesia web profile atau web blog masih di dominasi oleh bahasa PHP beserta framework nya karena memang dari sisi teknologi sangat ramah dengan developer indonesia, dari sisi infratruktur, light dan harga (hosting), komunitas, kemudahan integrasi dari sisi design dan implementasi. karena memang dari sisi harga hosting, banyaknya penyedia hosting dan komunitas yang besar ini menjadi kekuatan PHP untuk menjadi anak emas di lingkungan small and light application.

Karena basic saya programmer java maka akhirnya saya menangguhkan mencoba drupal (PHP) dan memutuskan mencoba dengan teknologi java yang memang saya sudah sangat akrab, dan saya memutuskan untuk mencoba magnolia berdasarkan rating di web cms critics, serta review review di beberapa artikel di internet yang saya temukan, dan sepertinya (karena saya masih menduga-duga) lebih ringan dibanding liferay. Faktor terlalu banyak memakan resources ini pula lah yang menjadikan Java menjadi “kalah” dibanding PHP di sisi small and light application

Untuk saat ini saya hanya bisa berbagi pengalaman dalam proses pencarian saya dalam mencari CMS berbasis Java untuk kemudian review dari sisi pribadi saya masih belum bisa memberikan review, mungkin kemudian hari setelah benar benar mencoba dan meng-implementasikan insya allah akan saya tulis di blog saya ini 😀

Random Stuff 

saya membuat bagian ini karena ketika dalam proses pencarian saya menemukan link link yang menarik berkenaan dengan materi yang saya bahas di atas, ini juga sebagai catatan pribadi saya 🙂

catatan : saya menulis ini dengan bahasa indonesia karena, saya rasa dan memang dari hasil searching di google saya tidak banyak menemukan materi yang berkaitan dengan CMS JAVA dalam bahasa indonesia 😀

Written by snippetjournal

July 8, 2015 at 4:46 am

Posted in Collection Link, Opini, Programming

Tagged with , ,

Email Spoofing

leave a comment »

Secara singkat email spoofing artinya mengirim email dengan domain email address yang sebenar nya tidak pernah ada. misalnya ingin mengirim email dari ucup@bajajbajuri.com, padahal email dan domain dari bajajbajuri tidak pernah ada.

Feature email spoofing sangat bergantung dengan SMTP yang kita gunakan untuk mengirim email. saya mencoba dengan gmail dan tentu saja tidak bisa :D. jadi saran saya gunakan SMTP server yang lain, saya mencoba dengan SMTP server smtp2go, anda bisa mengambil paket gratis untuk uji coba.

berikut code java yang saya gunakan, hasil copas dari mkyong.com 😀


 //testing smtp2go
 final String username = "xx.xx@gmail.com";
 final String password = "xx";

 Properties props = new Properties();
 props.put("mail.smtp.auth", "true");
 props.put("mail.smtp.starttls.enable", "true");
 props.put("mail.smtp.host", "smtpcorp.com");
 props.put("mail.smtp.port", "2525");
 
 Session session = Session.getInstance(props,
 new javax.mail.Authenticator() {
 protected PasswordAuthentication getPasswordAuthentication() {
 return new PasswordAuthentication(username, password);
 }
 });

 try {

 Message message = new MimeMessage(session);
 //domain email address must exist
 InternetAddress from = new InternetAddress("no-reply@travel.com", "xx Travel Company");
 message.setFrom(from);
 message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("aditya.kaha@gmail.com"));
 message.setSubject("Testing Subject");
 message.setText("Dear Mail Crawler,"+ "\n\n No spam to my email, please!");

 Transport.send(message);

 System.out.println("Done");

 } catch (MessagingException e) {
 throw new RuntimeException(e);
 } catch (UnsupportedEncodingException e) {
 e.printStackTrace();
 }
 
 

Edit :

ternyata setelah dilakukan testing, jika kita melakukan email spoofing sudah dipastikan email dengan domain address hasil spoofing akan dikategorikan spam, karena penyedia layanan email seperti gmail dan yahoo sudah cukup canggih dan email spoofing ini memang biasanya di peruntukan untuk hal hal negatif seperti spamming.

Karena seingat saya pada waktu sekitar tahun 2006-2009 email spoofing masih bisa kita gunakan. cara lain untuk atau solusi lain adalah dengan menyediakan form user untuk meng-config email pribadi nya sebagai email broadcast dari sistem, kita cukup memberikan konfigurasi SMTP gmail dan yahoo sebagai email yang umum digunakan, selebihnya bisa diberikan menu advance/other untuk alamat email selain gmail dan yahoo agar user dapat meng-konfigurasikan SMTP emailnya masing masing.

sekian, byee, happy coding  😀

Written by snippetjournal

May 22, 2015 at 7:10 am

Session in Spring MCV

leave a comment »

It good article about session in spring mvc, so i bookmarked in my blog 😀

What is the HTTP session? What for it exist? I hope you know that HTTP is a stateless protocol, that’s mean that there is no permanent connection between a browser and server. And as the result server doesn’t know who is an initiator of a request, even if an application has just one user. The session is a tool for identifying of requests author. The previous sentence is rough enough, but it explains the main purpose of the sessions. Every user gets it own session with unique identifier when he visits site first time.

Written by snippetjournal

March 26, 2015 at 3:04 am

Posted in Programming

Tagged with ,

Spring 4 Maven Dependency : misbehaviors error spring mvc

with 3 comments

It was very late, almost midnight and I can not resist to write this problem that i got. Almost spent more than one hour to figure out what is wrong with this spring mvc error.

This is my second time develop java web from scratch using spring mvc and i use spring web version 4.x.x. After prepare all xml configuration, there is no problem. All went well until i want to redirect the url from index.jsp to another url that will invoke my controller and the confusion begin 😦

SEVERE: Servlet.service() for servlet [eleveniaTest] in context with path [/elevenia-test] threw exception [Servlet execution threw an exception] with root cause

java.lang.NoSuchFieldError: STANDARD_NUMBER_TYPES

at org.springframework.web.context.request.ServletRequestAttributes.(ServletRequestAttributes.java:55)

at org.springframework.web.servlet.FrameworkServlet.buildRequestAttributes(FrameworkServlet.java:1031)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:958)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:620)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)

…..

After goggling and trying figure out what the cause, some post in stackoverflow instruct to add maven dependency eclipse configuration, and refer the path web-inf/lib.

But it doesn’t solve my problem, because the configuration its already there and the culprit clearly not the maven lib config.

So after looking my previous spring 4.x project there is additional configuration in pom.xml that force all the spring libs 4.x to avoid this misbehavior

<dependencyManagement>
<dependencies>

<!-- Force the version of all the spring jars (core, beans, context, ...)
pulled by spring-data-jpa:1.3.4.RELEASE to 3.2.x when spring-data pulls the
3.1.x versions to prevent some misbehaviors of maven which sometimes pulls
both 3.2.x and 3.1.x versions of spring-core, spring-beans and spring-context -->

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring-framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring-framework.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

 

It is likely somehow the spring data jpa pulls between spring version 3.1.x or spring 3.2.x from spring core into libs. so caused above error

Written by snippetjournal

March 11, 2015 at 4:43 pm

Posted in Programming

Tagged with ,

Eclipse STS Trivial Configuration

leave a comment »

Lately i was using eclipse STS to develop some information system, after a long time using netbeans, using STS is so much painful for me.

Yes eclipse STS fan boy can hate me, hatters gonna hate after all …  😛

In netbeans some trivial things like deployment process using eclipse, synchronized source in tomcat, auto deploy, maven configuration, and another deployment issues in tomcat,  are never occur when i was using netbeans

That kinds of trivial thing some time are so painful, you must configure it so you will have good sleep at night. 😀 , in the netbeans this kind of configurations are the default configuration, and i can say that netbean have improve so much than STS, it more easier develop using netbeans :P. You can focus on development rather get confused by configure your IDE to behave like you want to.

this are some STS issue that sometime occur when i was using it for development.


java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:506)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:488)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:115)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4909)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

this error occur because your maven dependency or your libs that manage by maven didnt included in tomcat deployment. here the solution :

right click in your project, properties – deployment assembly : add java build path entries – maven dependencies – finish.

refresh your poject, re-build , clean your tomcat resources to make sure it will deploy your new source (right click in tomcat server – clean), after that run your project in tomcat server.

another error is un-synchronized source in your tomcat server when you trying to deploy it. i spent more than an hours facing this kind of issue, i try to clean the project using maven, clean – build project in STS, rebuild and clean tomcat resources for many times.

this probably occur because STS didnt refresh the resources in workspace and tomcat when the project rebuild in STS or netbeans.

the solution you must configure STS to automatically refresh the resources, go to preferences – workspace : checklist this options :

  • build automatically
  • refresh using native hooks or pooling
  • refresh on access
  • save automatically before build

and another tricks is when you have many resources file like CSS or java script you must configure STS memory more than the default memory, just change memory size in STS.ini in your STS installation location :

–launcher.XXMaxPermSize
512M

-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m

Written by snippetjournal

January 17, 2015 at 3:42 am

Posted in Programming

Tagged with , , , , ,